I have a question about making plugins for discourse.
Iran calendar is Solar hijri or jalali, I want to make a converter to change gregorian date to jalali on view layer of discourse (without changing database).
wordpress has a plugin that convert all dates on website to jalali.
I want to do exact same thing and globally override the date method on view layer and display jalali date if forum language is persian.
How can I do this without changing discourse core codes and database ?
Iāve looked at a few sites here that I thought might be using different calendars.
A Chinese site is using English and Gregorian dates.
Hebrew sites look to be using Hebrew month names with Gregorian years.
Iām guessing this hasnāt come up before because much of the world uses Gregorian / countries with alternate calendar systems also understand Gregorian?
I know the database has a great many timestamp fields, I wouldnāt mess with those.
Sorry, but I am completely ignorant about converting one calendar to another.
Do you know of any Gems that do this?
You are right, a lot of countries use gregorian dates. But most people (I guess +99%) of people in Iran use jalali calendar.
I found this gem called parsi date but Iām not familiar with ruby language and I donāt know how to use it.
as I said before, I donāt want to change discourseās core or database. just changing the dates on view layer would be great.
ps : jalali date is not just about month names. years and month length are different too.
for example :
29
Apr
2017
to jalali :
09
Ų§Ų±ŲÆŪŲØŁŲ“ŲŖ ( ordibehesht )
1396
all the post information exists there! if you search for ā2017ā youāll find some dates there, and you can then use some third party calendars and change between the two.
so far weāve used this simple way a lot. itāll work for short-time until you learn ruby+discourse!
So not try to change the source code.
You just need a javascript to select the date element at your page and change it and add it to your page.
I think Topic controller is making this for you but for changing this you need to know some Ruby.
I suggest you to create a very simple plugin and change the date by selecting elements completely in javascript
Discourse invia giĆ date Gregoriane normali al tuo browser; questo script non modifica i dati, ma sostituisce solo il modo in cui il testo della data viene visualizzato sulla pagina, convertendolo in Shamsi (Jalali) utilizzando il browser stesso.
Cosa fa lo script (a grandi linee)
Trova quegli elementi time
Legge la data Gregoriana reale da datetime
La converte in Shamsi
Sostituisce solo il testo visibile
Ripete questa operazione ogni volta che vengono caricati nuovi post