Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Underscores and hyphens #31

Closed
mcfilib opened this issue Jun 3, 2016 · 0 comments
Closed

Underscores and hyphens #31

mcfilib opened this issue Jun 3, 2016 · 0 comments

Comments

@mcfilib
Copy link
Contributor

mcfilib commented Jun 3, 2016

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

  1. 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).
  2. 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant