python dict get default_Python locale.getdefaultlocale方法代碼示例
本文整理匯總了Python中locale.getdefaultlocale方法的典型用法代碼示例。如果您正苦於以下問題:Python locale.getdefaultlocale方法的具體用法?Python locale.getdefaultlocale怎麽用?Python locale.getdefaultlocale使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在模塊locale的用法示例。
在下文中一共展示了locale.getdefaultlocale方法的22個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Python代碼示例。
示例1: launch
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def launch(name, *args):
"""Executes a script designed specifically for this launcher.
The parameter "name" is the name of the function to be tested
which is passed as an argument to the script.
"""
filename = os.path.join(os.path.dirname(__file__), '_launch_widget.py')
command = ['python', filename, name]
if args:
command.extend(args)
output = subprocess.check_output(command)
try:
output = output.decode(encoding='UTF-8')
except:
try:
output = output.decode(encoding=locale.getdefaultlocale()[1])
except:
print("could not decode")
return output
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:23,
示例2: user_set_encoding_and_is_utf8
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def user_set_encoding_and_is_utf8():
# Check user's encoding settings
try:
(lang, enc) = getdefaultlocale()
except ValueError:
print("Didn't detect your LC_ALL environment variable.")
print("Please export LC_ALL with some UTF-8 encoding.")
print("For example: `export LC_ALL=en_US.UTF-8`")
return False
else:
if enc != "UTF-8":
print("zdict only works with encoding=UTF-8, ")
print("but your encoding is: {} {}".format(lang, enc))
print("Please export LC_ALL with some UTF-8 encoding.")
print("For example: `export LC_ALL=en_US.UTF-8`")
return False
return True
開發者ID:zdict,項目名稱:zdict,代碼行數:19,
示例3: setencoding
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def setencoding():
"""Set the string encoding used by the Unicode implementation. The
default is 'ascii', but if you're willing to experiment, you can
change this."""
encoding = "ascii" # Default value set by _PyUnicode_Init()
if 0:
# Enable to support locale aware default string encodings.
import locale
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
if 0:
# Enable to switch off string to Unicode coercion and implicit
# Unicode to string conversion.
encoding = "undefined"
if encoding != "ascii":
# On Non-Unicode builds this will raise an AttributeError...
sys.setdefaultencoding(encoding) # Needs Python Unicode build !
開發者ID:glmcdona,項目名稱:meddle,代碼行數:20,
示例4: test_option_locale
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def test_option_locale(self):
self.assertFailure('-L')
self.assertFailure('--locale')
self.assertFailure('-L', 'en')
lang, enc = locale.getdefaultlocale()
lang = lang or 'C'
enc = enc or 'UTF-8'
try:
oldlocale = locale.getlocale(locale.LC_TIME)
try:
locale.setlocale(locale.LC_TIME, (lang, enc))
finally:
locale.setlocale(locale.LC_TIME, oldlocale)
except (locale.Error, ValueError):
self.skipTest('cannot set the system default locale')
stdout = self.run_ok('--locale', lang, '--encoding', enc, '2004')
self.assertIn('2004'.encode(enc), stdout)
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:19,
示例5: _get_user_locale
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def _get_user_locale():
"""
| Gets the user locale to set the user interface language language.
| The default is set to english if the user's system locale is not one of the translated languages.
:return: string.
The user locale.
"""
if 'Windows' in platform.system():
import ctypes
windll = ctypes.windll.kernel32
default_locale = windows_locale[windll.GetUserDefaultUILanguage()]
else:
default_locale = getdefaultlocale()
if default_locale:
if isinstance(default_locale, tuple):
user_locale = [0][:2]
else:
user_locale = default_locale[:2]
else:
user_locale = 'en'
return user_locale
開發者ID:SekouD,項目名稱:mlconjug,代碼行數:25,
示例6: language_code
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def language_code(self, language_code):
is_system_locale = language_code is None
if language_code is None:
try:
language_code, _ = locale.getdefaultlocale()
except ValueError:
language_code = None
if language_code is None or language_code == "C":
# cannot be determined
language_code = DEFAULT_LANGUAGE
try:
self.language, self.country = self._parse_locale_code(language_code)
self._language_code = language_code
except LookupError:
if is_system_locale:
# If the system locale returns an invalid code, use the default
self.language = self.get_language(DEFAULT_LANGUAGE)
self.country = self.get_country(DEFAULT_COUNTRY)
self._language_code = DEFAULT_LANGUAGE_CODE
else:
raise
log.debug("Language code: {0}".format(self._language_code))
開發者ID:streamlink,項目名稱:streamlink,代碼行數:25,
示例7: aliasmbcs
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def aliasmbcs():
"""On Windows, some default encodings are not provided by Python,
while they are always available as "mbcs" in each locale. Make
them usable by aliasing to "mbcs" in such a case."""
if sys.platform == "win32":
import locale, codecs
enc = locale.getdefaultlocale()[1]
if enc.startswith("cp"): # "cp***" ?
try:
codecs.lookup(enc)
except LookupError:
import encodings
encodings._cache[enc] = encodings._unknown
encodings.aliases.aliases[enc] = "mbcs"
開發者ID:QData,項目名稱:deepWordBug,代碼行數:18,
示例8: setencoding
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def setencoding():
"""Set the string encoding used by the Unicode implementation. The
default is 'ascii', but if you're willing to experiment, you can
change this."""
encoding = "ascii" # Default value set by _PyUnicode_Init()
if 0:
# Enable to support locale aware default string encodings.
import locale
loc = locale.getdefaultlocale()
if loc[1]:
encoding = loc[1]
if 0:
# Enable to switch off string to Unicode coercion and implicit
# Unicode to string conversion.
encoding = "undefined"
if encoding != "ascii":
# On Non-Unicode builds this will raise an AttributeError...
sys.setdefaultencoding(encoding) # Needs Python Unicode build !
開發者ID:QData,項目名稱:deepWordBug,代碼行數:21,
示例9: _translate_msgid
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def _translate_msgid(msgid, domain, desired_locale=None):
if not desired_locale:
system_locale = locale.getdefaultlocale()
# If the system locale is not available to the runtime use English
if not system_locale[0]:
desired_locale = 'en_US'
else:
desired_locale = system_locale[0]
locale_dir = os.environ.get(domain.upper() + '_LOCALEDIR')
lang = gettext.translation(domain,
localedir=locale_dir,
languages=[desired_locale],
fallback=True)
if six.PY3:
translator = lang.gettext
else:
translator = lang.ugettext
translated_message = translator(msgid)
return translated_message
開發者ID:nttcom,項目名稱:eclcli,代碼行數:23,
示例10: run_mod
點讚 6
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def run_mod(self, log):
language_code, encoding = locale.getdefaultlocale()
now = time_op.now()
info = KInformation().get_info()
info["time"] = time_op.timestamp2string(now)
info["ts"] = now
info["language_code"] = language_code
info["encoding"] = encoding
info["python_version"] = platform.python_version()
info["data"] = log
encrypt = Ksecurity().rsa_long_encrypt(json.dumps(info))
net_op.create_http_request(constant.SERVER_URL,
"POST",
"/upload_logs",
encrypt)
開發者ID:turingsec,項目名稱:marsnake,代碼行數:19,
示例11: __init__
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def __init__(self, firstweekday=0, locale=None):
TextCalendar.__init__(self, firstweekday)
if locale is None:
locale = _locale.getdefaultlocale()
self.locale = locale
開發者ID:war-and-code,項目名稱:jawfish,代碼行數:7,
示例12: _language
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def _language():
try:
language = locale.getdefaultlocale()
except ValueError:
language = DEFAULT_LOCALE_LANGUAGE
return language
開發者ID:cls1991,項目名稱:ng,代碼行數:9,代碼來源:ng.py
示例13: get_string
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def get_string(self):
output = launch('get_string')
if sys.version_info < (3,):
output = output.encode(encoding=locale.getdefaultlocale()[1])
self.label['get_string'].setText("{}".format(output))
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:7,
示例14: get_password
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def get_password(self):
output = launch('get_password')
if sys.version_info < (3,):
output = output.encode(encoding=locale.getdefaultlocale()[1])
self.label['get_password'].setText("{}".format(output))
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:7,
示例15: get_username_password
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def get_username_password(self):
output = launch('get_username_password')
if sys.version_info < (3,):
output = output.encode(encoding=locale.getdefaultlocale()[1])
self.label['get_username_password'].setText("{}".format(output))
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:7,
示例16: get_many_strings
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def get_many_strings(self):
output = launch('get_many_strings')
if sys.version_info < (3,):
output = output.encode(encoding=locale.getdefaultlocale()[1])
self.label['get_many_strings'].setText("{}".format(output))
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:7,
示例17: get_date
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def get_date(self):
output = launch('get_date')
if sys.version_info < (3,):
output = output.encode(encoding=locale.getdefaultlocale()[1])
self.label['get_date'].setText("{}".format(output))
開發者ID:aroberge,項目名稱:easygui_qt,代碼行數:7,
示例18: configure
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def configure(self, lang=None):
"""
Configures the funcion "_" for translating the texts of Wapiti,
this method loads the language indicated as parameter or if the
parameter is not specified, it will take the default language
of the operating system.
"""
if lang is None:
# if lang is not specified, default language is used
defLocale = locale.getdefaultlocale()
langCounty = defLocale[0] # en_UK
lang = langCounty[:2] # en
if lang not in self.AVAILABLE_LANGS:
# if lang is not one of the supported languages, we use english
print("Oups! No translations found for your language... Using english.")
print("Please send your translations for improvements.")
print("===============================================================")
lang = 'en'
lan = gettext.translation('wapiti',
self.LANG_PATH,
languages=[lang],
codeset="UTF-8")
lan.install(unicode=1)
#funcion which translates
def _(key):
return lan.lgettext(key)
開發者ID:flipkart-incubator,項目名稱:watchdog,代碼行數:29,
示例19: select_language
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def select_language(lang_code=""):
if not lang_code:
default_locale = locale.getdefaultlocale()[0]
lang = default_locale.split("_")
lang_code = lang[0] if len(lang) else "en"
if lang_code in Translation.available_languages():
Translation.lang_code = lang_code
else:
Translation.lang_code = "en"
Translation._load_lang(Translation.lang_code)
開發者ID:chr314,項目名稱:nautilus-copy-path,代碼行數:14,
示例20: safeExpandUser
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def safeExpandUser(filepath):
"""
@function Patch for a Python Issue18171 (http://bugs.python.org/issue18171)
"""
retVal = filepath
try:
retVal = os.path.expanduser(filepath)
except UnicodeDecodeError:
_ = locale.getdefaultlocale()
retVal = getUnicode(os.path.expanduser(filepath.encode(_[1] if _ and len(_) > 1 else UNICODE_ENCODING)))
return retVal
開發者ID:vulscanteam,項目名稱:vulscan,代碼行數:16,
示例21: insert_new_collection_entry
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def insert_new_collection_entry(self, coll_uuid, title):
locale_lang = locale.getdefaultlocale()[0]
timestamp = int(time.time())
json_dict = {
"insert":
{
"type": "Collection",
"uuid": str(coll_uuid),
"lastAccess": timestamp,
"titles":
[
{
"display": title,
"direction": "LTR",
"language": locale_lang
}
],
"isVisibleInHome": 1,
"isArchived": 0,
"mimeType": "application/x-kindle-collection",
"collections": None
}
}
if self.is_cc_aware:
json_dict["insert"].update(
{
"collectionCount": None,
"collectionDataSetName": str(coll_uuid),
"isArchived": 1
})
self.commands.append(json_dict)
開發者ID:barsanuphe,項目名稱:librariansync,代碼行數:34,
示例22: to_calibre_plugin_json
點讚 5
# 需要導入模塊: import locale [as 別名]
# 或者: from locale import getdefaultlocale [as 別名]
def to_calibre_plugin_json(self):
if self.original_ebooks == []:
return {}
else:
return {
"%s@%s" % (self.label, locale.getdefaultlocale()[0]):
{
"items": self.build_legacy_hashes_list(),
"lastAccess": int(time.time())
}
}
# it would be very, very unlucky to have a collision
# between collection uuid & label...
開發者ID:barsanuphe,項目名稱:librariansync,代碼行數:17,
注:本文中的locale.getdefaultlocale方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。
python dict get default_Python locale.getdefaultlocale方法代碼示例相关推荐
- python markdown2 样式_Python markdown2.markdown方法代碼示例
本文整理匯總了Python中markdown2.markdown方法的典型用法代碼示例.如果您正苦於以下問題:Python markdown2.markdown方法的具體用法?Python markd ...
- python unescape函数_Python escape.url_unescape方法代碼示例
本文整理匯總了Python中tornado.escape.url_unescape方法的典型用法代碼示例.如果您正苦於以下問題:Python escape.url_unescape方法的具體用法?Py ...
- python linspace函数_Python torch.linspace方法代碼示例
本文整理匯總了Python中torch.linspace方法的典型用法代碼示例.如果您正苦於以下問題:Python torch.linspace方法的具體用法?Python torch.linspac ...
- python socketio例子_Python socket.SocketIO方法代碼示例
本文整理匯總了Python中socket.SocketIO方法的典型用法代碼示例.如果您正苦於以下問題:Python socket.SocketIO方法的具體用法?Python socket.Sock ...
- python wheel使用_Python wheel.Wheel方法代碼示例
# 需要導入模塊: from pip import wheel [as 別名] # 或者: from pip.wheel import Wheel [as 別名] def from_line(cls, ...
- python psutil.disk_Python psutil.disk_partitions方法代碼示例
本文整理匯總了Python中psutil.disk_partitions方法的典型用法代碼示例.如果您正苦於以下問題:Python psutil.disk_partitions方法的具體用法?Pyth ...
- python datetime datetime_Python datetime.tzinfo方法代碼示例
本文整理匯總了Python中datetime.datetime.tzinfo方法的典型用法代碼示例.如果您正苦於以下問題:Python datetime.tzinfo方法的具體用法?Python da ...
- python terminator_Python turtle.Terminator方法代碼示例
本文整理匯總了Python中turtle.Terminator方法的典型用法代碼示例.如果您正苦於以下問題:Python turtle.Terminator方法的具體用法?Python turtle. ...
- python execute_command err_Python management.execute_from_command_line方法代碼示例
本文整理匯總了Python中django.core.management.execute_from_command_line方法的典型用法代碼示例.如果您正苦於以下問題:Python manageme ...
最新文章
- 解读思科2014-19年全球移动互联网发展趋势报告(1)
- Kafka-Monitor
- linux下mysql安装
- 技术应用丨DWS 空间释放(vacuum full) 最佳实践
- vivo又有新机跑分曝光 机海战术要来了?
- 单机版kubernetes1.13安装
- ANSYS Workbench 目标参数优化案例分析
- 测试用例(功能用例)——资产类别、品牌、取得方式
- 教你如何使用github+jsDelivr搭建免费图床
- used in key specification without a key length
- 计算机毕业设计Javahtml5健身房信息管理系统(源码+系统+mysql数据库+lw文档)
- ArcGIS图层标注显示(将图层属性名字显示出来)
- jmeter beanshell关于小数参数定义转化
- 微信小程序之PHP后端服务器数据库的连接处理
- html向下滚动条,《html》不显示滚动条,鼠标滑轮可以控制向下滚动是怎么回事?...
- IDEA配置远程debug调试
- 经典励志名言100余句
- 跟我学ABAP/4-初识ABAP
- 翻译www.djangobook.com之第四章:Django模板系统
- java 解析Json对象(嵌套json数组)