jquery-timeago icon indicating copy to clipboard operation
jquery-timeago copied to clipboard

How can I add translation for months' names?

Open JarisGV opened this issue 4 years ago • 6 comments
trafficstars

Hello.

I'd like to type the date in 'title' in english i.e.: title="July 17, 2008" and I'd like to add the translation for the name of the 12 months in a script, i.e. July: "Julho", as we have in locale files, so when I set up the locale to portuguese the user would get the date not as July 17, 2008 but Julho 17, 2008. Is there a way to do it?

Example

Translating months' names

Best regards.

JarisGV avatar Apr 18 '21 20:04 JarisGV

https://github.com/rmm5t/jquery-timeago/tree/master/locales

Best regards!!

Sartharian avatar May 05 '21 16:05 Sartharian

I didn't find anything related to the name of the months in 'locale'. I don't want to use short version like '1d, 1m...', I'd like to use the name of months but translated. I.e. (es) Enero 27... (fr) Janvier 27... (pt) Janeiro 27...

JarisGV avatar May 05 '21 17:05 JarisGV

Okay, I just solve it by adding this code:

image,

View on CodePen

JarisGV avatar May 06 '21 01:05 JarisGV

the locale js files adds a customization support for the relative time text! u 're making a mistake, 'cause this plugins only converts the iso to a relative time text. perhaps u're confusing w/ the examples... the locale info comes from ur data or info actually showing. no need to replace the eng notations :)

Sartharian avatar May 08 '21 19:05 Sartharian

in othr words, u can set the title attr w/ the text u wanna show... =) <time class="timeago" datetime="[dateisoformat]" title="[Custom user text]">... and this text is edited from the plugin using the locales</time>

Sartharian avatar May 08 '21 20:05 Sartharian

in othr words, u can set the title attr w/ the text u wanna show... =) <time class="timeago" datetime="[dateisoformat]" title="[Custom user text]">... and this text is edited from the plugin using the locales</time>

But that's the problem. I wanna show the text in title attr in multiple languages. I want to show it by default in english, but the user can define the language he will see (es, fr, pt...). That's the reason I translated the names of the months. Perhaps this is not the right way to do it, but the problem is solved, and sincerely I didn't find how to solve it using your instructions.

JarisGV avatar May 08 '21 22:05 JarisGV