Skip to content
This repository has been archived by the owner on Apr 18, 2023. It is now read-only.

Translate into a locale other than the current one #298

Closed
digitalcora opened this issue Aug 31, 2015 · 6 comments
Closed

Translate into a locale other than the current one #298

digitalcora opened this issue Aug 31, 2015 · 6 comments

Comments

@digitalcora
Copy link
Contributor

i18n gem has this:

I18n.t('some.key', locale: 'en')

It would be nice to have something similar for ember-i18n. For instance, I have a locale picker that displays each language as that language's name for itself (i.e. English, Español, Français). To have this display correctly in all languages, I need to duplicate that list of languages in all of my locales. It would be cleaner if each locale only stored its own name, and I could call t('name', { locale: 'en' }).

(technically that approach would be backward-incompatible with any translations that legitimately had an interpolation named locale in them, but that is how the i18n gem handles it)

@jamesarosen
Copy link
Owner

Can you link to the relevant Ruby?

@digitalcora
Copy link
Contributor Author

This is the part of the i18n gem that picks up the locale from the translate options:

https://github.com/svenfuchs/i18n/blob/b1200f0289a59ba0368f800473d8ac79f713bc26/lib/i18n.rb#L148

Strangely the method's documentation does not mention this behavior, but the docs for the transliterate method immediately below it do include an example.

@jamesarosen
Copy link
Owner

This seems like a fairly unlikely key for a translation to have. Still, it might be good to introduce a flag. Something like

i18nService.set('CROSS_LOCALE_LOOKUP', true);

I would suggest three options:

  1. warn: treat locale as a special key, warn if a translation uses it; default
  2. true: treat locale as a special key, silence warnings
  3. false: treat locale as a regular key, silence warnings

@digitalcora
Copy link
Contributor Author

Sounds good to me, although I imagine you'd eventually want to remove the warning/option and have locale always be special (perhaps in the next major version bump). Since there is ENV.i18n already, should the option go there?

@jamesarosen
Copy link
Owner

I imagine you'd eventually want to remove the warning/option and have locale always be special (perhaps in the next major version bump)

Exactly.

Since there is ENV.i18n already, should the option go there?

Sure. The service:i18n can pull it off there.

@jamesarosen
Copy link
Owner

jamesarosen/ember-i18n has been deprecated in favor of ember-intl.

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

No branches or pull requests

2 participants