0

I need help on building and deploying angular app with builtin i18n. I am able to build for multiple languages. My dist folder structure is like this

dist /app/es

the app folder contains default language bundle(en). I am able to switch to different languages by changing the url i.e /es the problem is I have to decide the language after the user logs in. from the login response I have to load the proper language from login.component.ts file. How do I achieve this? or what would be the best approach

Arul Rozario
  • 679
  • 1
  • 9
  • 20
  • It make no sense to translate after logged in only. I think you should translate the whole app, even login page. – PierreD Jan 10 '20 at 15:14
  • Yeah. it's a multi-tenant app. we decide the tenant after the user logs in. It's just a temporary solution for demo purposes. – Arul Rozario Jan 10 '20 at 15:17
  • If you want to change the language while the app is running the NGX-Translate thirdparty library may be a good choice: http://www.ngx-translate.com/. However this way you don't have different urls for different languages. – Milan Tenk Jan 10 '20 at 15:18
  • our requirement is to have built in i18n considering the future. I am ok to reload the page after login to load as it's for demo purposes. – Arul Rozario Jan 10 '20 at 15:22
  • 1
    Translating with multiple builds is so weird. You can update the url (the only one solution I see) or use a ngx-translate as said above. – PierreD Jan 10 '20 at 15:25
  • 1
    multiple builds is the limitation we have with angular's built in i18n. Angular 9 or above will support dynamic translations. ngx-translate may be deprecated. That's the reason why I am sticking to builtin i18n. – Arul Rozario Jan 10 '20 at 15:29

0 Answers0