From 3260deeafa382937d7044402506ae4b790d573fa Mon Sep 17 00:00:00 2001 From: Antonia van Eek Date: Mon, 2 Sep 2024 09:15:13 +0200 Subject: [PATCH] Add hint in documentation how to change an app's locale --- docs/tutorials/HowToTranslateAnApp.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/docs/tutorials/HowToTranslateAnApp.md b/docs/tutorials/HowToTranslateAnApp.md index 16d7cf5..1322563 100644 --- a/docs/tutorials/HowToTranslateAnApp.md +++ b/docs/tutorials/HowToTranslateAnApp.md @@ -684,6 +684,25 @@ function ServiceI18nExample() { The complete app `i18n-howto` can be found in the `samples` folder. +## Changing the application's locale + +It is possible to change the application's locale to a specific locale using the `setLocale` method on the `ApplicationContext`. + +Example: + +```ts +import { ApplicationContext } from "@open-pioneer/runtime"; + +const appCtx: ApplicationContext = ...; // injected +appCtx.setLocale("en-US"); +``` + +Limitation: +Currently, this requires a full restart of the application. +Please create an issue or PR if you need support for changing the locale without restart. + +For more information refer to the API of the `core-packages` `runtime` package. + ## Further reading - [FormatJS Documentation](https://formatjs.io/docs/getting-started/installation)