M
M
mkrichet2019-09-12 10:18:18
JavaScript
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)
P
Pavel Pikat, 2019-09-12
@mkrichet

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

H
hack504, 2019-09-12
@hack504

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

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question