We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to get the user country?

I need a way to know the user country to make the routing according the language of user and after make the translation to your language

    Ex: 
    mysite.com/en/page
    mysite.com/fr/page

How do i make this?

The language should be to getting automatically and the user redirected to your correspondence language if this version exist, case not there's, the user may be redirect to default language, for example english



7.9k
Accepted
answer

You can use HTTP header accept_language or you can use maxmind to detect user country based on their IP address. Here is some refrence https://stackoverflow.com/questions/10987646/accuracy-of-accept-language-to-detect-country