Skip to content

Commit

Permalink
Add hint in documentation how to change an app's locale
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniave committed Sep 2, 2024
1 parent 6f1e2fa commit 3260dee
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/tutorials/HowToTranslateAnApp.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 3260dee

Please sign in to comment.