0

How do I get accept-language header in Angular +2? I'm using JIT and would like to load given language accordingly.

I have tried to get locale on bootstrap with:

const translations = require(`raw-loader!./locale/messages.${(window.clientInformation && window.clientInformation.language) || window.navigator.languages[1] || ''}.xlf`);

And it works to some degree, but dosen't take every browser into account. Any help is appreciated.

Wimza
  • 61
  • 1
  • 1
  • 5
  • [This article](https://www.techrepublic.com/article/detect-foreign-language-support-using-javascript/) should cover your question about the browsers compatibility –  Jul 23 '18 at 07:55
  • Hmm thanks for your reply, but I don't want to be limted to X browsers. I think I should be able to see my accept language headers when loading, but I can't seem to find any help on how to get accept headers, only set. – Wimza Jul 23 '18 at 10:59
  • You can't get a header that doesn't exist ... Angular makes HTTP requests with headers, but it's your server that serves the `index.html` page first. You'll have to handle this on server side if you want youe header. –  Jul 23 '18 at 11:03

0 Answers0