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
Once useLocales(...some locales...) is called, calling useLocales([]) retains the existing locales (though I would expect it to override them and force no translation). I haven't tested what happens when a different set of locales is used in the second call.
The use case for this is responding to dynamic changes to the UI language (such as the languagechange event). For example, given a project where untranslated strings are in English:
addLocale('zh-CN',require('./zh-CN.po.json'));functionchangeLocale(){// Remove any locales after any locales after any English locale to prevent them from overriding the source English text.constpreferredOverEnglish= ...
// on the first call: preferredOverEnglish = ['zh-CN']// on the second call: preferredOverEnglish = []useLocales(preferredOverEnglish);}// To begin, navigator.languages is ['zh-CN', 'en-US']changeLocale();window.addEventListener('languagechange',changeLocale);// Now the user moves en-US to the top of their preferences, navigator.languages is ['en-US', 'zh-CN'], the languagechange event fires, and changeLocale() gets called.
The text was updated successfully, but these errors were encountered:
Once
useLocales(...some locales...)
is called, callinguseLocales([])
retains the existing locales (though I would expect it to override them and force no translation). I haven't tested what happens when a different set of locales is used in the second call.The use case for this is responding to dynamic changes to the UI language (such as the
languagechange
event). For example, given a project where untranslated strings are in English:The text was updated successfully, but these errors were encountered: