Reputation: 11
I am using angular's build in i18n language translation. The way this blog post explains but I want to switch the language by default looking into browser's default language. If my browser locale is French (fr) and when I browse my site as https://www.myi18nexample.com, content of the page should get loaded with french language labels/constants/strings. Can you please suggest how can I achieve this ?
Other few points to consider:
Can it behave as we deploy with ngx-translator library used.
Can we differentiate what is possible and what is not possible with i18n and ngx-translate. Compare both as apple to apple comparison.
browserlocale, localization by default browser language, no slash in url for language change, should behave as we deploy without localization
thanks
Upvotes: 1
Views: 1239
Reputation: 1185
Angular i18n does not behave like ngx-translate. If you want that kind of behavior you should use it or have a look at Transloco.
You get build time translations and each language gets deployed in its own app, hence the URL paths to different languages.
The Angular docs when it comes to i18n are comprehensive and have examples of how you can set up the redirect to the browser language: https://angular.io/guide/i18n#configuring-servers
Upvotes: 0