6

I am developing a web app and I need to add multi-language support. I went through the Angular documentation and I noticed that the translation was occurring at build time. I was curious if we can develop it in a way that the app translates into different a language at run-time. I did some research but I could not find a proper answer.

So my question is, can I add at dropdown language selector at the top in the menu and change the language during runtime?

Missak Boyajian
  • 1,965
  • 7
  • 32
  • 59

1 Answers1

5

The one and only:

http://www.ngx-translate.com/

Im using it in all of my projects.

I don't like the i18n of Angular it need for every language a separated compilation and can't change at runtime.

Demo: https://stackblitz.com/github/ngx-translate/example

Seryoga
  • 793
  • 6
  • 15
  • Does it have any performance issues? Anything should I take into consideration before diving into it? – Missak Boyajian Jan 23 '20 at 13:02
  • I didn't found a way how to split the language files in multiple json files so i can load only the needed files via lazy loading. I have to load the full language file on startup and it could take some time to load it by bigger projects ... – Seryoga Jan 23 '20 at 13:05
  • 2
    In Angular 9 its possibile to change the language on runtime but i didn't tried it yet because im using angular 7: https://blog.ninja-squad.com/2019/12/10/angular-localize/ – Seryoga Jan 23 '20 at 13:09
  • 2
    @seryoga It's possible to change language at runtime but it's not possible without refreshing the browser. Useless. – Gaetano Piazzolla Feb 12 '20 at 11:00
  • 1
    i posted an example where its possibile to change it without refreshing ... – Seryoga Feb 12 '20 at 13:21