alexanderwallin / node-gettext

A JavaScript implementation of gettext, a localization framework.
Other
188 stars 37 forks source link

Add default locale option #36

Closed elusiveunit closed 4 years ago

elusiveunit commented 7 years ago

Since the strings defined in the source are likely in the default language, one should be able use that locale without errors.

I feel that this should be a constructor option rather than a method like setLocale, since changing it dynamically shouldn't be needed. This made the tests a bit awkward though, do you want them structured some other way? I'm not really used to OOP testing.

ArmorDarks commented 7 years ago

Note, that it will deviate behavior of gettext from GNU-one.

elusiveunit commented 7 years ago

I'm not too familiar with GNU gettext unfortunately, how is it handled there? Adding a translation for the default locale that's just the same strings?

ArmorDarks commented 7 years ago

To be honest, I've never used native GNU Gettext (only their xgettext), so I've studied it through their documentation.

As far as I've understood, in gettext there is no means to set default locale, since it will be always defined by OS.

It might be worth to go through my notes in this issue https://github.com/alexanderwallin/node-gettext/issues/31

elusiveunit commented 7 years ago

I see! As discussed in your linked issue, it seems locale and message handling is already quite different from GNU gettext and must be so due to different environments. I feel that adding something that isn't really relevant to native gettext anyway should be fine.

ChristophWurst commented 4 years ago

Hi @alexanderwallin :v:

would it be possible to have this patch reviewed? We're using your lib in Nextcloud and see many warnings when the lang is set to English as we don't provide translations for the source language (ref #49).

I'm happy to help with the integration if this library is still actively maintained.

Cheers

alexanderwallin commented 4 years ago

Holy moly, now this one was left in the attic. Of course we should have this!

ChristophWurst commented 4 years ago

Thanks a lot :rocket:

alexanderwallin commented 4 years ago

Renamed it to sourceLocale and published 2.1.0

int-ua commented 4 years ago

Not a user here, just came from Google search results for "gettext non-English default". I'm curious, do you support more than two plural forms in ngettext? Assuming that you have ngettext but I can't imaging how would it work otherwise.

Because gettext developers refused to support non-English defaults https://savannah.gnu.org/bugs/index.php?49598