M2 Download Center
Download Here ( Internal )
Hello, i maked a simple script for get initial lang... the proposite is automate the choice of the languaje (for servers internationals).
Unknown if there will be something similar
Source:
import requests
class CurrentPositionForLang:
# Code langs
__LANGS_AVAILABLES = ("ES", "EN", "FR", "TR",)
# County with lang
__COUNTRY_CODES_WITH_LANG = (
("MX", __LANGS_AVAILABLES[0]),
("US", __LANGS_AVAILABLES[1]),
("FR", __LANGS_AVAILABLES[2]),
("ES", __LANGS_AVAILABLES[0]),
("TR", __LANGS_AVAILABLES[3])
)
@staticmethod
def get_lang():
lang = "US" # Default lang for errors
try:
r = requests.get("[Hidden Content]")
if r.status_code != 200:
return lang
countryCode = r.json()["countryCode"]
for country, langCountry in CurrentPositionForLang.__COUNTRY_CODES_WITH_LANG:
if countryCode == country:
return langCountry
# If not finded return default
return lang
except requests.exceptions.ConnectionError:
return lang
For utilicy this class only call this method:
CurrentPositionForLang.get_lang()
this return only String "US, ES..."
If you need add more langs, in this fields add the country and the code.
__LANGS_AVAILABLES = ("ES", "EN", "FR", "TR",)
# County with lang
__COUNTRY_CODES_WITH_LANG = (
("MX", __LANGS_AVAILABLES[0]),
("US", __LANGS_AVAILABLES[1]),
("FR", __LANGS_AVAILABLES[2]),
("ES", __LANGS_AVAILABLES[0]),
("TR", __LANGS_AVAILABLES[3])
)
This is the standar for code countrys:
[Hidden Content]