Submit Search
Upload
I18n
•
7 likes
•
1,556 views
Tim (文昌)
Follow
i18n for Django and python in taipei.py
Read less
Read more
Technology
Report
Share
Report
Share
1 of 31
Download now
Download to read offline
Recommended
Sv presentation
Sv presentation
Tatsuya Hanyu
STIMA Congress 2015 Nir Eyal: Hooked
STIMA Congress 2015 Nir Eyal: Hooked
BAM - Belgian Association of Marketing
Tugas 1 Artificial inteligence - Tes turing dan istilah AI
Tugas 1 Artificial inteligence - Tes turing dan istilah AI
sindhubairewi
Webinar jan 28 2016 learn to improve period-end close process with effecti...
Webinar jan 28 2016 learn to improve period-end close process with effecti...
Adil Khan
Mobile Marketing
Mobile Marketing
PSAMA
Tugas mandiri pengolahan citra digital
Tugas mandiri pengolahan citra digital
Fauji Gabe
Соответствие между тех. специализациями и продуктами Trend Micro. 17 ноября 2011
Соответствие между тех. специализациями и продуктами Trend Micro. 17 ноября 2011
Валерий Коржов
Etsy v jet.com
Etsy v jet.com
Arylee McSweaney, MBA
Recommended
Sv presentation
Sv presentation
Tatsuya Hanyu
STIMA Congress 2015 Nir Eyal: Hooked
STIMA Congress 2015 Nir Eyal: Hooked
BAM - Belgian Association of Marketing
Tugas 1 Artificial inteligence - Tes turing dan istilah AI
Tugas 1 Artificial inteligence - Tes turing dan istilah AI
sindhubairewi
Webinar jan 28 2016 learn to improve period-end close process with effecti...
Webinar jan 28 2016 learn to improve period-end close process with effecti...
Adil Khan
Mobile Marketing
Mobile Marketing
PSAMA
Tugas mandiri pengolahan citra digital
Tugas mandiri pengolahan citra digital
Fauji Gabe
Соответствие между тех. специализациями и продуктами Trend Micro. 17 ноября 2011
Соответствие между тех. специализациями и продуктами Trend Micro. 17 ноября 2011
Валерий Коржов
Etsy v jet.com
Etsy v jet.com
Arylee McSweaney, MBA
Pharma customer experience: A conversation
Pharma customer experience: A conversation
COUCH Health
How to Use HTP to Complete the Close Process Puzzle
How to Use HTP to Complete the Close Process Puzzle
Alithya
Yellowfin 7.3 launch presentation slides
Yellowfin 7.3 launch presentation slides
Yellowfin
Enterprise Performance Management - HFM
Enterprise Performance Management - HFM
Codec-dss UK
Thermodynamics - Experiment 2
Thermodynamics - Experiment 2
syar2604
Capgemini Kpn Presentation Obug 2009
Capgemini Kpn Presentation Obug 2009
mdekam
2 Team Dynamics
2 Team Dynamics
Mary Anne (Riyan) Portuguez
Presentation & communication skills
Presentation & communication skills
gihan aboueleish
SIKOLOHIYANG PILIPINO
SIKOLOHIYANG PILIPINO
Mary Anne (Riyan) Portuguez
Service Chaining Current and Future
Service Chaining Current and Future
Kentaro Ebisawa
Python的50道陰影
Python的50道陰影
Tim (文昌)
Frontend django, Django Web 前端探索
Frontend django, Django Web 前端探索
Tim (文昌)
Profile django
Profile django
Tim (文昌)
Introduction to protocol buffer
Introduction to protocol buffer
Tim (文昌)
Mock Introduction
Mock Introduction
Tim (文昌)
Ml weka
Ml weka
Tim (文昌)
Tainan.py, Experience about package
Tainan.py, Experience about package
Tim (文昌)
Performance Enhancement Tips
Performance Enhancement Tips
Tim (文昌)
pygame sharing pyhug
pygame sharing pyhug
Tim (文昌)
More Related Content
Viewers also liked
Pharma customer experience: A conversation
Pharma customer experience: A conversation
COUCH Health
How to Use HTP to Complete the Close Process Puzzle
How to Use HTP to Complete the Close Process Puzzle
Alithya
Yellowfin 7.3 launch presentation slides
Yellowfin 7.3 launch presentation slides
Yellowfin
Enterprise Performance Management - HFM
Enterprise Performance Management - HFM
Codec-dss UK
Thermodynamics - Experiment 2
Thermodynamics - Experiment 2
syar2604
Capgemini Kpn Presentation Obug 2009
Capgemini Kpn Presentation Obug 2009
mdekam
2 Team Dynamics
2 Team Dynamics
Mary Anne (Riyan) Portuguez
Presentation & communication skills
Presentation & communication skills
gihan aboueleish
SIKOLOHIYANG PILIPINO
SIKOLOHIYANG PILIPINO
Mary Anne (Riyan) Portuguez
Service Chaining Current and Future
Service Chaining Current and Future
Kentaro Ebisawa
Viewers also liked
(10)
Pharma customer experience: A conversation
Pharma customer experience: A conversation
How to Use HTP to Complete the Close Process Puzzle
How to Use HTP to Complete the Close Process Puzzle
Yellowfin 7.3 launch presentation slides
Yellowfin 7.3 launch presentation slides
Enterprise Performance Management - HFM
Enterprise Performance Management - HFM
Thermodynamics - Experiment 2
Thermodynamics - Experiment 2
Capgemini Kpn Presentation Obug 2009
Capgemini Kpn Presentation Obug 2009
2 Team Dynamics
2 Team Dynamics
Presentation & communication skills
Presentation & communication skills
SIKOLOHIYANG PILIPINO
SIKOLOHIYANG PILIPINO
Service Chaining Current and Future
Service Chaining Current and Future
More from Tim (文昌)
Python的50道陰影
Python的50道陰影
Tim (文昌)
Frontend django, Django Web 前端探索
Frontend django, Django Web 前端探索
Tim (文昌)
Profile django
Profile django
Tim (文昌)
Introduction to protocol buffer
Introduction to protocol buffer
Tim (文昌)
Mock Introduction
Mock Introduction
Tim (文昌)
Ml weka
Ml weka
Tim (文昌)
Tainan.py, Experience about package
Tainan.py, Experience about package
Tim (文昌)
Performance Enhancement Tips
Performance Enhancement Tips
Tim (文昌)
pygame sharing pyhug
pygame sharing pyhug
Tim (文昌)
More from Tim (文昌)
(9)
Python的50道陰影
Python的50道陰影
Frontend django, Django Web 前端探索
Frontend django, Django Web 前端探索
Profile django
Profile django
Introduction to protocol buffer
Introduction to protocol buffer
Mock Introduction
Mock Introduction
Ml weka
Ml weka
Tainan.py, Experience about package
Tainan.py, Experience about package
Performance Enhancement Tips
Performance Enhancement Tips
pygame sharing pyhug
pygame sharing pyhug
I18n
1.
Django, i18N, l10N
2.
今天 • 什麼是 i18N
跟 l10N • Python 怎麼做 • Django 怎麼做
3.
i18n, 國際化 • internationalization •
太⻑⾧長了, 就改成 iXXn, XX 就是⻑⾧長度
4.
l10N 本地化 • localization
⽐比照辦理
5.
詳細的意義 • (From Wiki) •
國際化(i18n) 意味著產品有適⽤用於任何地⽅方的「潛 ⼒力」 • 在地化(l10N)則是為了更適合於「特定」地⽅方的使 ⽤用
6.
簡化版 i18N +
l10N simple.py
7.
python simple.py Hi 世界 LANG=en_US.UTF-8
python simple.py Hello World 簡化版 i18N + l10N
8.
實務上需要的功能 • 單數複數? • May
是五⽉月天還是五⽉月花? Order 是順序還是訂 單? • ⼯工作流程如何標準化? • 數字,⽇日期的格式
9.
更難的問題 • ⽂文化,圖⽚片,習慣 • ⽂文字⽅方向
10.
Gnu gettext • gnu
的 gettext 可以幫助我們做 i18N, l10N。並且 可以⽀支援 C, Java, Python, PHP… 等等語⾔言 • 使⽤用 gettext 可以⾃自已建⽴立 i18N, l10 的流程 • django 基於 gettext,有⼀一套很簡潔的流程
11.
Gettext 包含 • xgettext
讀取你的程式,產⽣生訊息檔 • msgfmt 把訊息檔變成 2 進位格式,供你的程式 讀取
12.
訊息檔
13.
使⽤用 gettext 的流程 •
寫好程式,程式內使⽤用字串的地⽅方,請⽤用 _() 圍住 • 執⾏行 xgettext 新增/更新訊息檔 • 使⽤用 msgfmt 編譯訊息檔 • 執⾏行程式看看
14.
xgettext and python example.py
15.
訊息以語系做分別 . ├── example.py └── zh_TW.UTF-8 └──
LC_MESSAGES └── example.mo
16.
指令 • 產⽣生訊息 xgettext
-p zh_TW.UTF-8/LC_MESSAGES/ -d example example.py • 加⼊入新字串 • 更新訊息 xgettext -j -p zh_TW.UTF-8/LC_MESSAGES/ -d example example.py • 編譯訊息 msgfmt zh_TW.UTF-8/LC_MESSAGES/ example.po -o zh_TW.UTF-8/LC_MESSAGES/ example.mo
17.
DEMO • 程式碼是 pure_python/example.py
18.
xgettext 的貼⼼心 • 若是有漏翻的,會先以
key 擋著 • 可以簡易做出訊息檔
19.
Used In Django •
剛剛有點苦, Django 會幫你簡化使⽤用⽅方式
20.
Django Django locale settings LocaleMiddleWare 存放訊息檔 LOCALE_PATHS LANGUAGE_CODE Request get user language preference
21.
基本 setting LOCALE_PATHS: 每個 app
可以有⾃自已的訊息檔,我們也可以⾃自已增加額外 的訊息檔的位置。 設定⽅方式跟 TEMPLATE_DIR 很像 LANGUAGE_CODE: 如果你的網站的使⽤用者沒有設定語⾔言,就以這個做預設值。 在 1.8 之後 中⽂文是 zh-Hant ,規則是 語⾔言-字體 1.7 以前,是⽤用 zh-TW (可以不⽤用管⼤大⼩小寫 ) 這個設定 dash 是擺中間
22.
Middleware session middle ware
要擺第⼀一,因為才能知道 user 的選擇 locale middle ware 會分析 accept langue request header
23.
Template 實做 記得 load
i18n trans 後⾯面加 key
24.
Used With View import
ugettext as _ 習慣使⽤用 _ , ⽤用 ugettext 也是可以的
25.
Used With Model 再把
admin.py 補起來。 你會發現 Order 沒有如你所願翻成功 要改⽤用 ugettext_lazy
26.
Why • Python 的運作模式,是⼀一開始⼀一定會執⾏行程式⼀一 次。 •
verbose_name 在⼀一開始啟動,就被決定了... • lazy 結尾的版本,會每⼀一次存取都取值
27.
DEMO • demo flow •
demo with Browser language order • Make Message: • django-admin.py makemessages -l zh_TW • Compile Message • django-admin.py compilemessages
28.
Used With javaScript •
⼤大家已經有概念,所有的字串都要即時取值。 • django 可以幫你產⽣生合適的 js code. 讓你使⽤用⽅方 式跟剛剛講的幾呼⼀一樣。
29.
• django-admin makemessages
-d djangojs -l zh_TW • djangojs 很重要,是指定 domain. 除了產⽣生的訊 息檔案不同之外,他不會去掃描 python 檔了,⽽而 是掃 javaScript 檔
30.
DEMO • Demo of
JS
31.
Further Reading • 單複數的處理 •
django-statici18n
Download now