How to properly display jalali dates for Persian language

I have installed discourse on Ubuntu and docker.
I want to change template dates to jalali dates and I don’t know where to start.

1 Like

I’m trying to make a plugin to convert gregorian dates to jalali date.
this is what I’ve done so far :
plugin.rb file :

# name: تاریخ شمسی
# about: تاریخ شمسی Discourse
# version: 1.0
# authors: l3est

# javascript
register_asset "javascripts/moment-jalaali.js", :server_side

this is moment-jalaali.js file :

and added translated date formats:
YYYY MM changes to jYYYY jMM

and there is assets\javascripts folder in plugin main folder, this is the plugin structure:

Hey @erlend_sh. Is this the kind of translation that should be in core?

I think it should be for persian language files (client.fa_IR.yml and server.fa_IR.yml) . but no others.

Does anyone know how can I change formatter.js.es6 dates to jajali with plugin ?
the moment-jalali library works on chrome console when website loads.

In case you haven’t seen it yet, this might be useful:


thanks for the link. I’ve seen this before.
I know how to make plugins. I just don’t know where I can edit dates before it gets to user browser.

You don’t…

I believe (hopefully someone will correct me if I’m wrong)…

…for the most part dates and times are stored in UTC/GMT server side and translated to the local user’s time zone in the browser (client side).


I think I’m not explaining well.

I’m looking for specific files that format dates before sending it to browser, so I’ll be able to add moment-jalali or other jalali date converters to it to get jalali date in browser.

I found this file:

this is the file that returns date to web browser. the question is how can I add the moment-jalali.js file to this? then everything will be ok.
client.fa_IR.yml file has ‘jYYYY jMM jD’ format instead of ‘YYYY MM D’ (for fa_IR language only)
here’s an example how moment-jalali works:
m.format('jYYYY/jM/jD [is] YYYY/M/D') // 1360/5/26 is 1981/8/17

I haven’t done translations before, however - my understanding is that…

All translations are supplied via Discourse localization

This at some point then is migrated into client and server files in the Discourse repo where the English versions are these:

This topic covers this in more detail:

Note that there is a whole dates section in each of these files which comes from Transiflex:

Again hopefully someone with more knowledge will correct me if wrong…

As I see it you should submit the "jYYYY etc translations to Discourse localization

Moment.js will then be called with the right “jYYYY” etc instead of “YYYY”

Then you need to submit two extra code patches / Pull Requests to Discourse to add and call the extra libraries as needed:

  1. One Pull Request to add and load moment-jalaali if, an only if “jYYYY” etc are used.
  2. 2nd Pull Request for handling any dates etc which are handled via Ruby.

Following the translation and then first pull request should get you most of the way there.

One of the Discourse team will read this at some point (they read everything here) and may comment on if this is acceptable or if they have a better idea for a way forward.


Thanks for all the information. I think plugin would be better for this problem.
if I add the jYYYY to translation files, it won’t parse correctly.
jYYYY jMM jD will turn into j2017 jMay j7

still and the main question is, how to add moment-jalaali.js to formatter.js.es6 (ECMA Script 6 file) ?

This topic was automatically opened after 29 hours.

How to change the processmaker 3.2 environment to Hijri or Jalali Calendar?
The processmaker has been used by Moment.js , I want to use moment-jalaali.js.
for example : I want use Jalali Calender in “Inbox,Draft,Participation,Last Modified,Due Date,Summeary,…”

@Osama any ideas about what we should offer here?

It looks like there are moment.js plugins for Hijri and Jalali calenders: Moment.js | Docs

To see how easy it’s to use, I cloned the Hijri plugin into vendor folder and changed the dates formats in according to the plugin documentation and I got it to display Hijri dates in a few places:

(July 2017 is in 1438 Hijri year)

I’m guessing it didn’t display Hijri dates in all places because those were using different core methods for displaying dates and might need to be tweaked a bit to display Hijri dates correctly.

Overall I think Hijri support should be done in a plugin and in a new separate Arabic locale to let people choose between Hijri or Gregorian.


The plugin could either create a new locale that falls back to the existing Arabic locale or it could simply override the existing locale. In either case, the locale files in the plugin would only need to contain the new date formats. See: Add a new locale from plugin


Hi, is there any solution for Jalali calendar in discourse? I find many different source code but there are not stable. Could you help me in this moment?
I just mentioned some previous responses’ members which maybe find a well-known solution.
@pfaffman @l3est

I want Jalali calendar in timeline dates but I didn’t find any good solutions…

Dear Mahdi, did you find that? @l3est