-
Posts
4 -
Joined
-
Last visited
-
Feedback
0%
Content Type
Forums
Store
Third Party - Providers Directory
Feature Plan
Release Notes
Docs
Events
Posts posted by mesterlum
-
-
hace 3 horas, Kori dijo:
Yes I have a Compiler for my phone and the app have many modules but not this sorry for my mistake
Np bro.
-
i do not understand buddy, if you refer for "requests" is a module from python API. But, my idea is establish initial lang automatic.
- 1
-
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("http://ip-api.com/json/") 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:
- 1
- 1
- 2
PY Get Initial Lang
in Programming & Scripts
Posted
good job my friend, and thanks for complete the script for clients.