FriendsOfFlarum / realtimedate

Makes the human time (ex. 2 minutes ago) update in real time.
MIT License
2 stars 1 forks source link

Doesn't work well in other languages #9

Open clarkwinkelmann opened 3 years ago

clarkwinkelmann commented 3 years ago

Some of the text isn't translated in other languages when used with language packs.

The issue seems to be that we define additional keys for relativeTime, and since those keys aren't part of the standard DayJS, language packs don't translate it.

For example for seconds there is only s by default, but this extension ads ss, which won't be translated by any extension.

https://github.com/FriendsOfFlarum/realtimedate/blob/65fb3dcab6875f0c58880fa265e3b415c07279ad/js/src/forum/index.js#L31-L32

Bizarrely in the report here https://discuss.flarum.org/d/23211-friendsofflarum-real-time-date/22 it seems like the s translation defaults to English, while it should be the only one with a French translation available, and I'd expect ss to default to English :thinking:

Translations registered by language pack https://github.com/qiaeru/lang-french/blob/bd0d01dc8fedbb04d8184b9ce9c892e874151a0a/locale/config.js#L23 which is copied verbatim from https://github.com/iamkun/dayjs/blob/dev/src/locale/fr.js

We should either use only translations available in the base DayJS, or gracefully fallback from "x seconds ago" to "a few seconds ago" if "x seconds ago" isn't translated in the current language.

Ralkage commented 3 years ago

We should either use only translations available in the base DayJS, or gracefully fallback from "x seconds ago" to "a few seconds ago" if "x seconds ago" isn't translated in the current language.

@clarkwinkelmann which method do you prefer/suggest?

clarkwinkelmann commented 3 years ago

I haven't studied this in enough details to really say.

It seems to me that DayJS should have a way to translate "x seconds", but from my quick look at the translation files, it doesn't seem they do.

That probably leaves a proper fallback the best option, but I'm not sure if that's easy to do, or if DayJS already tries to fallback to something when a key doesn't exist.