How can I dynamically change the i18n language in an OpenSearch plugin?

In my OpenSearch application, I have a plugin that uses two languages: Japanese (ja) and Spanish (sp). Consequently, my plugin’s .i18nrc.json file looks like this:

{
  "translations": [
    "translations/ja.json",
    "translations/sp.json"
  ]
}

When the language in the plugin matches the one specified in opensearch_dashboards.yml under
i18n.locale: 'ja'

everything works correctly in Japanese. However, if I try to switch to the other language (for example, Spanish) while i18n.locale: 'ja' is still set, all the text becomes English, because that’s the defaultMessage fallback for missing or non-matching keys.

When i change locale, after this i do window.location.reload() .At the same time, if I log i18n.getLocale() to the console on the frontend, it shows sp, which is correct. But it’s not clear why the language does not actually switch to Spanish translations.

The language switch may not be fully applied because the i18n configuration isn’t updating the translations after the reload. Ensure the translation files are properly loaded after switching locales and check for any caching issues.