折腾:
期间,关于设置locale:
Formatting Python Dates According to Locale | skybert.net
感觉设置local的参数:
# python3 import locale import datetime dt = datetime.datetime(2015, 11, 15, 16, 30) locale.setlocale(locale.LC_ALL, “en_GB.utf8”) print(dt.strftime(“%A, %d. %B %Y %I:%M%p”)) ‘Tuesday, 15. November 2015 04:30pm’ locale.setlocale(locale.LC_ALL, “nb_NO.utf8”) print(dt.strftime(“%A, %d. %B %Y %I:%M%p”)) ‘tirsdag, 15. november 2015 04:30’ |
感觉是:
en_GB.utf8
nb_NO.utf8
想要设置中文应该是:
zh_cn.utf8
?
但是也看到了:
localization – What is the correct way to set Python’s locale on Windows? – Stack Overflow
-》
微软的MSDN中:
缩写都不太一样啊。。
还是想要更完整,更权威的国家的字符缩写列表
想起来了:
去看locale函数参数,应该可以有说明
python locale setlocale
22.2. locale — Internationalization services — Python 2.7.12 documentation
->
RFC 1766 – Tags for the Identification of Languages
“In the primary language tag:
– All 2-letter tags are interpreted according to ISO standard
639, “Code for the representation of names of languages” [ISO
639].
– The value “i” is reserved for IANA-defined registrations
– The value “x” is reserved for private use. Subtags of “x”
will not be registered by the IANA.
– Other values cannot be assigned except by updating this
standard.
The reason for reserving all other tags is to be open towards new
revisions of ISO 639; the use of “i” and “x” is the minimum we can do
here to be able to extend the mechanism to meet our requirements.
In the first subtag:
– All 2-letter codes are interpreted as ISO 3166 alpha-2
country codes denoting the area in which the language is
used.
– Codes of 3 to 8 letters may be registered with the IANA by
anyone who feels a need for it, according to the rules in”
22.2. locale — Internationalization services — Python 2.7.12 documentation
“locale.LC_TIME
Locale category for the formatting of time. The function time.strftime() follows these conventions.
locale.LC_ALL
Combination of all locale settings. If this flag is used when the locale is changed, setting the locale for all categories is attempted. If that fails for any category, no category is changed at all. When the locale is retrieved using this flag, a string indicating the setting for all categories is returned. This string can be later used to restore the settings.”
locale 中文 utf8
“编辑配置文件,将zh_US.UTF-8改为en_US.UTF-8,zh改为en
zh_CN.utf8”
ubuntu服务器中设置locale为中文仍然无效的解决方法 – Penguin
“安装中文语言包
apt-get install language-pack-zh-hans
然后添加中文支持
locale-gen zh_CN.UTF-8
zh_CN.utf8
LANG=”zh_CN.uft8″
LANGUAGE=”zh_CN.utf8″”
-》此处并不需要去修改此处的微信公众号的Python的Flask所在的CentOS服务器中的locale
-》只是去把time格式化输出时,用到locale即可。
ISO 639
Lists of ISO 639 codes – Wikipedia, the free encyclopedia
List of ISO 639-1 codes – Wikipedia, the free encyclopedia
“
Language family | Language name | Native name | 639‑1 | 639‑2/T | 639‑2/B | 639‑3 | 639‑6 | Notes | |
Sino-Tibetan | Chinese | 中文 (Zhōngwén), 汉语, 漢語 | zh | zho | chi | zho + 13 | macrolanguage |
“
List of ISO 639-2 codes – Wikipedia, the free encyclopedia
“
zho / chi* | zho | zh | Chinese | Macrolanguage | Living |
“
ISO 639-3 – Wikipedia, the free encyclopedia
“
Chinese | zh | chi/zho[4][5] | macro | zho |
Mandarin | individual | cmn | ||
Cantonese | individual | yue | ||
Minnan | individual | nan |
“
“国际标准化组织的ISO 3166国际标准针对国家和地区编代码,有三部分:
ISO 3166-1有国际标准化组织(ISO)的标准国家代码。有二位字母代码、三位字母代码、以及三位数字代码。1974年首次出版。
ISO 3166-2定义国家或地区的主要行政区代码。
ISO 3166-3定义被取代的ISO 3166-1代码的代码。1998年首次出版。”
“
CN | CHN | 156 | ISO 3166-2:CN | 中国 |
“
ISO 3166-2:CN – Wikipedia, the free encyclopedia
ISO 639 vs 3166
截止目前,还没完全搞懂
只搞懂一部分:
CN:是ISO 3166-2中定义的,中国China的两位字母的缩写
-》对应的三位字母缩写是:CHN
有空再去深究。