So I’ve been able to figure out how to use gettext to translate for a certain language, setting the setlocale, how can I figure out what user probably want for language to be set?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In this order:
Remember the user’s choice.
Accept-Languagerequest header ($_SERVER['HTTP_ACCEPT_LANGUAGE']).Pick the first option that makes sense for you. Always allow the user to switch to another language easily. Usually through links in the page header or footer.
The URL should contain the language choice. I.e. ultimately the current URL is the deciding factor for the language, the above options just redirect the user to the appropriate URL. You can use domains/subdomains for this (
example.com,example.de,example.jp,en.example.com,de.example.com,ja.example.com) or make it part of the path (example.com/en,example.com/de,example.com/ja).A forth option is to geolocate the user based on his IP, but I would really discourage that, since location doesn’t have much to do with language.