# How to properly display jalali dates for Persian language

**URL:** https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157
**Category:** Translations
**Created:** [May 5, 2017, 10:15am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157 "2017-05-05T10:15:46Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 5, 2017, 10:15am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/1 "2017-05-05T10:15:46Z")

</div>

I’m a new rails/discourse developer. I’m wondering if someone could tell me about discourse structure.  
I wanted to edit some view files so I edited discourse/app/views/[view-folder]/[\*.html.erb] files and nothing changed, even static text like ‘test’ didn’t show up in website.  
could you tell me which files can change things on website template?

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 5, 2017, 1:19pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/2 "2017-05-05T13:19:03Z")

</div>

Did you set up a development server? Also, if you are going to make changes and ever want to upgrade Discourse, you should develop plugins.

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 5, 2017, 1:59pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/3 "2017-05-05T13:59:45Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 5, 2017, 6:37pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/4 "2017-05-05T18:37:54Z")

</div>

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 :

> **[moment-jalaali/build at master · jalaali/moment-jalaali](https://github.com/jalaali/moment-jalaali/tree/master/build)**
>
> master/build

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:  
jalaali-date  
plugin.rb  
-assets  
–javascripts  
—moment-jalaali.js

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [May 5, 2017, 11:24pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/5 "2017-05-05T23:24:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 6, 2017, 6:05am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/6 "2017-05-06T06:05:37Z")

</div>

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.

![](https://global.discourse-cdn.com/meta/original/3X/1/5/1529c3f20b1d912662bf82971223e56f33b85e84.png)

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [May 6, 2017, 11:33am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/7 "2017-05-06T11:33:57Z")

</div>

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

> [@Developing Discourse Plugins - Part 1 - Create a basic plugin](https://meta.discourse.org/t/beginners-guide-to-creating-discourse-plugins-part-1/30515):
>
> Building a plugin in Discourse can be really simple, once you learn a couple of quirks. The goal of this post is to create a skeleton plugin and introduce you to the basics. Your development environment Make sure you have a development environment of Discourse running on your computer. I recommend you use [the appropriate setup guide](https://meta.discourse.org/tag/dev-install) and come back when you’re done. plugin.rbtada Use [GitHub - discourse/discourse-plugin-skeleton: Template for Discourse plugins · GitHub](https://github.com/discourse/discourse-plugin-skeleton) to create a complete di…

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 6, 2017, 7:15pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/8 "2017-05-06T19:15:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 6, 2017, 7:29pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/9 "2017-05-06T19:29:02Z")

</div>

> [@l3est](#):
>
> 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).

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 6, 2017, 7:38pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/10 "2017-05-06T19:38:03Z")

</div>

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](https://github.com/jalaali/moment-jalaali/) or other jalali date converters to it to get jalali date in browser.

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 6, 2017, 7:59pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/11 "2017-05-06T19:59:39Z")

</div>

I found this file:  
discourse/app/assets/javascripts/discourse/lib/formatter.js.es6

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`

---

<div class="post-metadata">

### Author: ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)
#### Post date: [May 6, 2017, 8:16pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/12 "2017-05-06T20:16:18Z")

</div>

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

All translations are supplied via [https://www.transifex.com/discourse/discourse-org/](https://www.transifex.com/discourse/discourse-org/)

This at some point then is migrated into client and server files in the Discourse repo where the English versions are these:  
[discourse/config/locales/client.en.yml at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/config/locales/client.en.yml)  
[discourse/config/locales/server.en.yml at main · discourse/discourse · GitHub](https://github.com/discourse/discourse/blob/master/config/locales/server.en.yml)

This topic covers this in more detail:

> [@Contributing translations to Discourse](https://meta.discourse.org/t/contribute-a-translation-to-discourse/14882):
>
> bookmark This document provides a guide on how to contribute translations to the Discourse platform using Crowdin. person_raising_hand Required user level: Anyone can contribute translations Translating Discourse into different languages is essential for its global adoption. Contributing as a translator or proofreader is greatly appreciated and helps in making Discourse accessible to a broader audience. Summary This guide covers: Translating Discourse using Crowdin. Becoming a proofr…

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

> <https://github.com/discourse/discourse/blob/main/config/locales/client.en.yml#L39-L65>

> <https://github.com/discourse/discourse/blob/main/config/locales/server.en.yml#L18-L44>

* * *

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

As I see it you should submit the "jYYYY etc translations to [https://www.transifex.com/discourse/discourse-org/](https://www.transifex.com/discourse/discourse-org/)

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](https://github.com/jalaali/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.

---

<div class="post-metadata">

### Author: ![l3est](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/l3est/32/172909_2.png) [@l3est](https://meta.discourse.org/u/l3est)
#### Post date: [May 7, 2017, 6:41am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/13 "2017-05-07T06:41:31Z")

</div>

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) ?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 7, 2017, 9:02am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/16 "2017-05-07T09:02:28Z")

</div>



---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [May 8, 2017, 3:00pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/17 "2017-05-08T15:00:06Z")

</div>

This topic was automatically opened after 29 hours.

---

<div class="post-metadata">

### Author: ![satoshi\_download](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@satoshi\_download](https://meta.discourse.org/u/satoshi_download)
#### Post date: [July 16, 2018, 8:08am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/18 "2018-07-16T08:08:40Z")

</div>

Hi  
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,…”

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [July 16, 2018, 8:32am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/19 "2018-07-16T08:32:06Z")

</div>

@Osama any ideas about what we should offer here?

---

<div class="post-metadata">

### Author: ![Osama](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osama/32/98013_2.png) [@Osama](https://meta.discourse.org/u/Osama)
#### Post date: [July 17, 2018, 6:33am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/20 "2018-07-17T06:33:10Z")

</div>

It looks like there are moment.js plugins for Hijri and Jalali calenders: [Moment.js | Docs](https://momentjs.com/docs/#/plugins/jalaali/)

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

 ![image](https://global.discourse-cdn.com/meta/original/3X/b/a/ba951d96b0ac0c9ad0770c2a055b9e385323ff0f.jpg)  
(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.

---

<div class="post-metadata">

### Author: ![gerhard](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/gerhard/32/119479_2.png) [@gerhard](https://meta.discourse.org/u/gerhard)
#### Post date: [July 17, 2018, 9:38am UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/21 "2018-07-17T09:38:37Z")

</div>

> [@Osama](#):
>
> in a **new** separate Arabic locale

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](https://meta.discourse.org/t/add-a-new-locale-from-plugin/78962)

---

<div class="post-metadata">

### Author: ![daanaa](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/daanaa/32/184393_2.png) [@daanaa](https://meta.discourse.org/u/daanaa)
#### Post date: [June 18, 2020, 12:50pm UTC](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157/22 "2020-06-18T12:50:43Z")

</div>

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  
Thanks

[Next page](https://meta.discourse.org/t/how-to-properly-display-jalali-dates-for-persian-language/62157.md?page=2)
