mkrichet2019-09-12 10:18:18
mkrichet, 2019-09-12 10:18:18

Angular: how to switch language?

Good time of the day!
I need to implement language switching (by a button in the application itself) without reloading or redirecting. I did not find such functionality in the i18n documentation .
Is there a built in angular engine for this task? If there is no such mechanism, what is better to use?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Pavel Pikat, 2019-09-12

No way. i18n does not currently support changing the language on the fly. Angular compiles separate bundles for each language and the whole application will be reloaded when changing the language.
To change the language on the fly, use ngx-translate or wait for Ivy - they promised to implement in the new engine

hack504, 2019-09-12

you need to configure the server, since localization is picked up by Angular by url (like /ru/, /fr/, etc.). Here is a configuration guide:

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question