question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Manage locales dynamicaly (migrating from i18n)

See original GitHub issue
  • [jup ] I am on the latest ember-intl version
  • [jup ] I have searched the issues of this repo and believe that this is not a duplicate

Environment

  • Ember Version: 3.5.0
  • Ember CLI Version: 3.5.0
  • Ember Intl Version: 3.5.0
  • Browser(s): chromium (v68.0.3440.106)
  • Node Version: 8.11.3

I’m migrating my project from ember i18n to ember intl (deprectation ember i18n). The issue is that I used to add my locales dynamicaly, depending on which language options were checked in the CMS behind my ember application, my locales were added by detecting the languages with translations that were stored in localforage using

this.set('i18n.locales', myLanguageArray);

This is no longer possible in ember-intl, searching the docs I found out that the locales are readOnly. Is there another way to set the locales apart from hardcoding it in the environment/config file?

Thanks in advance

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
makepaniccommented, Nov 19, 2018

If you only want to configure the locales, then use the setLocale method:

intlService.setLocale(myLocalesArray)

See https://github.com/ember-intl/ember-intl#setting-locale See also https://github.com/ember-intl/ember-intl/blob/master/docs/asynchronously-loading-translations.md if you want to load the translation strings asynchronously

0reactions
BHuyscommented, Nov 19, 2018

I’m now solving it by putting all the possible languages in the locales array as you are suggesting, when I load my data I only addTranslations for the enabled languages (my data is coming from an api, not a file). This works for me now, just need to remember to add the language in the array each time I need to support a new language.

Thanks for the help and suggestions @makepanic @Turbo87 @buschtoens

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code-splitting react-i18n locales using dynamic imports
Hence, a better solution would be to load only the required locale files or load them on demand. And this can be achieved...
Read more >
Vue 3 with dynamic locales · Issue #240 · intlify/vue-i18n-next
Migration of previously working state. What is actually happening? Cannot access translations in Vue components. I am using webpacker WITHOUT ...
Read more >
Beyond YML Files - dynamic translations - Collective Idea
The locale-specific translations are stored in the translations table, so you need to write a migration to create this table. $ rails g...
Read more >
Advanced Features: Internationalized Routing - Next.js
js has built-in support for internationalized (i18n) routing since v10.0.0 . You can provide a list of locales, the default locale, and domain-specific...
Read more >
I18n in Go: Managing Translations - Alex Edwards
This is because using a dynamic locale as the first part of a URL path is likely to result in conflicts with other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found