You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I opened an issue in grosser/fast_gettext#81 noting that fast_gettext, the underlying library used in gettext_i18n_rails, doesn't let you use IETF Language Tags because it formats hyphens as underscores when calling .set_locale.
I discovered this whilst trying to use gettext_i18n_rails_js by following the examples in the documentation in the README.
In the documentation, gettext_i18n_rails_js you have the following example.
%html{ manifest: "", lang: I18n.locale }
Since gettext_i18n_rails monkey patches I18n to replace underscores with hyphens, this can result in a situation where lookups will always fail on the front end.
Reproduction Steps
FastGettext.available_locales to something like ["en_GB"]
Add a translation for en_GB.
Run rake gettext:po_to_json
Attempt a lookup.
This is because the JSON that gets dumped by gettext_i18n_rails_js have the keys with underscores but I18n.locale will have keys with hyphens.
Possible solutions
Update the documentation to set the lang attribute to use FastGettext.locale rather than I18n.locale (I'm unsure if this results in any other issues in the browser, though).
Update gettext_i18n_rails_js to convert hyphens to underscores when pulling the lang attribute out of the DOM.
Question
Do you have any thoughts or preferences as to how you'd like to solve this? I'm open to feedback and happy to submit a patch.
The text was updated successfully, but these errors were encountered:
I opened an issue in grosser/fast_gettext#81 noting that
fast_gettext
, the underlying library used ingettext_i18n_rails
, doesn't let you useIETF Language Tags
because it formats hyphens as underscores when calling.set_locale
.I discovered this whilst trying to use
gettext_i18n_rails_js
by following the examples in the documentation in the README.In the documentation,
gettext_i18n_rails_js
you have the following example.Since
gettext_i18n_rails
monkey patchesI18n
to replace underscores with hyphens, this can result in a situation where lookups will always fail on the front end.Reproduction Steps
FastGettext.available_locales
to something like["en_GB"]
en_GB
.rake gettext:po_to_json
This is because the JSON that gets dumped by
gettext_i18n_rails_js
have the keys with underscores butI18n.locale
will have keys with hyphens.Possible solutions
FastGettext.locale
rather thanI18n.locale
(I'm unsure if this results in any other issues in the browser, though).gettext_i18n_rails_js
to convert hyphens to underscores when pulling the lang attribute out of the DOM.Question
Do you have any thoughts or preferences as to how you'd like to solve this? I'm open to feedback and happy to submit a patch.
The text was updated successfully, but these errors were encountered: