0

What is the best way to detect the language of User? I have in my application a dropdownlist where the User can select the application language (English or Portuguese), internationalization works well, however only after logging in.

I would like the login screen, the system was already presented in the correct User language (for example based on browser language).

Is it correct to do so? How could it be done?

EDIT

I got following this article: https://github.com/samdark/yii2-cookbook/blob/master/book/i18n-selecting-application-language.md

gugoan
  • 770
  • 2
  • 11
  • 35

1 Answers1

0

Is it correct to do so? You can also check use ip and check country from where it come. The worst case is when you are not able to switch language.

Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
  • Using the country to determine the language is not really safe. That's why browsers use the ```Accept-Language``` header, so I would still get the site of the OP in English, even when I am in Portugal when I visit the site. Also, using the country will fail when you target countries that have multiple official languages (such as Belgium or Switzerland). – Arjan Aug 30 '15 at 22:37