国际化和本地化的目标是让同一站点为不同的用户提供定制化的语言和格式服务。
Django 完整支持 翻译文本, 格式化日期,时间和数字 以及 时区。
实际上,Django 做了两件事:
翻译依赖于目标语言,而格式化规则依赖于目标国家。此信息由浏览器的 Accept-Language
头提供。但是,时区并不容易获得。
单词国际化(internationalization)和本地化(localization)总是令人迷惑;以下是个简单的定义:
更多细节请查阅 W3C Web Internationalization FAQ , Wikipedia article 或 GNU gettext documentation 。
下面是一些术语,可以帮助我们处理通用语言:
ll
or a
combined language and country specification of the form ll_CC
.
Examples: it
, de_AT
, es
, pt_BR
, sr_Latn
. The language
part is always in lowercase. The country part is in titlecase if it has
more than 2 characters, otherwise it's in uppercase. The separator is an
underscore.Accept-Language
HTTP header 里发送浏览器接受的语言名。比如:it
, de-at
, es
, pt-br
。语言代码一般用小写表示,但是 HTTP Accept-Language
header 不区分大小写。用破折号来间隔。.po
。10月 22, 2020