SlideShare a Scribd company logo
1 of 26
Download to read offline
GH – "Global" Hack!
國際化開源專案:技術實務與經驗分享
2016-04-07 | PCMan@NTHU
洪任諭 <http://pcman.im/>
2
講者經歷
•
PCMan BBS/telnet client 全系列
•
LXDE / LXQt 桌面環境
•
新酷音輸入法 Windows port (C++ & Win32 IME & TSF)
•
PIME 輸入法平台 (C++ & python)
•
IE Tab Mozilla Firefox plugin/ 套件 (C++ & ATL &
Javascript)
• 前風濕免疫科醫師
• 台大資訊工程所碩士班
Part I:
I18n (internationalization) 技術議題
多國語言支援
● Locale
– 文字
– 數字
– 日期
– 金額
● 顯示 : RTL
● 編碼 : unicode
● 輸入
Unicode 編碼
● UTF-16 (byte order: BE or LE)
● UTF-32 (BE or LE)
● UTF-8 (no byte order)
● BOM (byte order mark)
https://en.wikipedia.org/wiki/Byte_order_mark
UTF-8
● Multi-byte characters ( 中文 3 - 6 bytes)
● 無 byte order 問題,適合 data exchange
– 但 Windows 下還是經常要求需要加 BOM
● ( 部份 ) 相容原有 C 語言 strxxx() 函數,但 ...
– 字元數 != 位元組數 (strlen)
– 移到下一字元,不能直接 pointer++
– 通常需專用 library 處理 ( 例 glib 的 g_utf8_* API)
● g_utf8_next_char()
● g_utf8_strlen()
● g_utf8_strstr()
各種編碼轉換
● GNU iconv: command line tool and library
– https://www.gnu.org/software/libiconv/
● LibICU (C++ lib, 龐大 )
– http://site.icu-project.org/
● 繁簡中文轉換 : OpenCC
– https://github.com/BYVoid/OpenCC
Locale
● Locale 名稱 :
– 國名 _ 地區 . 編碼 ( 例 : zh_TW.UTF-8)
– Windows 有時用 LCID / LANGID
● 數字格式
● 字元分類 / 大小寫轉換
● 日期時間
● 排序 (collate)
● 金額 (currency)
POSIX LC_* 環境變數
● LANGUAGE
● LC_ALL: override 其他 LC_* 變數
● LC_*
– LC_COLLATE: 字元排序
– LC_CTYPE: 字元分類 / 大小寫轉換
– LC_MESSAGES: 文字訊息
– LC_NUMERIC: 數字格式
– LC_TIME: 日期時間
● LANG
● POSIX setlocale() 函數
字串排序
● strcmp()? ASCII code 字典序? → NO!!!
● 符合語言學的順序 (collate)
– LibICU: Ucollator
– Glib: g_utf8_collate() (fast approximation)
– Qt 5: QCollator (libICU based)
– POSIX: strcoll()
RTL Layout 問題 (BiDi 支援 )
● 文字 ( 例 : 希伯來、阿拉伯 )
● 圖示 ( 箭頭方向 )
● UI layout
翻譯字串
● GNU gettext
– API: gettext(), dgettext()...
– *.po file → *.mo file
● Qt Linguist
– QObject::tr()
– *.ts → *.qmo
● Android:
– strings.xml
GNU gettext
#include <libintl.h>
#define _(String) gettext (String)
int main (int argc, char *argv[])
{
…
setlocale (LC_ALL, "");
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
…
}
GNU gettext
●
不同語言複數型 (plural forms) 不同, code 不能寫死
● API: ngettext (msgid1, msgid2, n)
– msgid1: 英文單數型 (n=1)
– msgid2: 英文複數型 (n > 1, 通常是字尾加 s)
– n: 數字
●
例 : ngettext ("%d file removed", "%d files removed", n)
●
C printf() 參數順序,翻譯後可能改變
– 英文 : "String `%s' has %d characters"
– 德文 : "%d Zeichen lang ist die Zeichenkette `%s'"
– GNU 擴充 : "%2$d Zeichen lang ist die Zeichenkette `%1$s'"
https://www.gnu.org/software/gettext/manual/gettext.html
線上翻譯系統
● Pootle (http://pootle.translatehouse.org/)
● Transifex (https://www.transifex.com/)
● Launchpad (https://launchpad.net/)
● 翻譯和 code 分開維護 (developer/translator
各自管理 )
使用者界面尺寸
● 字串翻譯後寬度和高度會發生變化
https://www.w3.org/International/articles/article-text-size.en
文字輸入
●
中日韓 – 輸入法 (input method editor)
– Windows: TSF, imm32 (deprecated)
– UNIX-like:
●
底層 : gtk+ 2/3 IM modules, Qt 4/5 IM modules, xinput
●
框架 : ibus, fcitx, scim, gcin, uim...
●
西方國家 – Keyboard layouts
– 特殊按鍵:
● Alt-Gr key 常用右 Alt ( 例 : AltGr + C → ©, AltGr + 4 → € )
●
Dead key ( 例 : 法文 ` A → à )
● 設定程式熱鍵小心和輸入法衝突
Part II:
從台灣到國際 – 經驗分享
19
LXDE+Razor-Qt = LXQt
20
Jerome
(Razor-qt)
Julien
(Lubuntu)
媽我在這裡 !
21
跨國開發有文化差異,但是 C 是共通語言
建議當成第二外語學習 XD
22
跨國合作
●
I18n 議題
● 文化差異
●
來自世界各國 , 各行各業的「人」
●
Version control systems
●
讀懂別人的 code ,並且修改
●
外國人也想參加我們的專案 !
23
國際化,你需要 ...
●
英文專案首頁 ( 必備 !)
●
英文 source code 註解和文件
● 良好的多國語言支援
●
Mailing list ( 溝通、克服 Time-zone 問題 )
●
Packages ( 和主流 distros 合作 , 建 ppa)
● 傳教士
●
運氣,以及 coding 直到世界末日的堅持
24
免費廣告通路
●
各大 Linux distro 之討論區及 mailing list
●
阿宅新聞 Slashdot 投稿
●
各大 free software 下載網站 ( 例 :qt-apps.org)
●
寫 Blog 等別人轉貼
●
Linux Action Show
●
投稿 conference
25
如何開始 ?
● 公開自己的專案
– 注意 coding style, license (MIT, GPL, LGPL, Apache?...)
– 多寫文件 / comments
– Marketing!
● 加入現有的專案
– 下載 source code
– 回報 bug
– 貢獻 Patch / 文件
– Mailing list / IRC 討論
← 免費的最難賣
2016-04-07-清大-國際化開源專案技術實務與經驗分享

More Related Content

What's hot (8)

Using vim
Using vimUsing vim
Using vim
 
MPI use c language
MPI use c languageMPI use c language
MPI use c language
 
Rootkit tw(0224)
Rootkit tw(0224)Rootkit tw(0224)
Rootkit tw(0224)
 
Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10Guide to GStreamer Application Development Manual: CH1 to CH10
Guide to GStreamer Application Development Manual: CH1 to CH10
 
Golangintro
GolangintroGolangintro
Golangintro
 
Hello world 的一生
Hello world 的一生Hello world 的一生
Hello world 的一生
 
igdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT introigdshare 110220: LuaJIT intro
igdshare 110220: LuaJIT intro
 
Android C Library: Bionic 成長計畫
Android C Library: Bionic 成長計畫Android C Library: Bionic 成長計畫
Android C Library: Bionic 成長計畫
 

Similar to 2016-04-07-清大-國際化開源專案技術實務與經驗分享

數位出版2.0 it
數位出版2.0 it數位出版2.0 it
數位出版2.0 it
志賢 黃
 
基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计
Hengyi
 
Erlang开发及应用
Erlang开发及应用Erlang开发及应用
Erlang开发及应用
litaocheng
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log Analysis
Xiaoming Chen
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
維佋 唐
 

Similar to 2016-04-07-清大-國際化開源專案技術實務與經驗分享 (20)

Hcsm lect-20120913
Hcsm lect-20120913Hcsm lect-20120913
Hcsm lect-20120913
 
COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺COSCUP2016 - LLVM框架、由淺入淺
COSCUP2016 - LLVM框架、由淺入淺
 
COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺COSCUP 2016 - LLVM 由淺入淺
COSCUP 2016 - LLVM 由淺入淺
 
數位出版2.0 it
數位出版2.0 it數位出版2.0 it
數位出版2.0 it
 
基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计基于嵌入式系统的Avs P10编码系统设计
基于嵌入式系统的Avs P10编码系统设计
 
Erlang开发及应用
Erlang开发及应用Erlang开发及应用
Erlang开发及应用
 
Baidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log AnalysisBaidu LSP and DISQL for Log Analysis
Baidu LSP and DISQL for Log Analysis
 
LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發LinkIt Smart 7688程式開發
LinkIt Smart 7688程式開發
 
2010 08-14 web-sitei18n
2010 08-14 web-sitei18n2010 08-14 web-sitei18n
2010 08-14 web-sitei18n
 
Go集成c&c++代码
Go集成c&c++代码Go集成c&c++代码
Go集成c&c++代码
 
建置Python開發環境
建置Python開發環境建置Python開發環境
建置Python開發環境
 
2018 VLSI/CAD Symposium Tutorial (Aug. 7, 20:00-21:00 Room 3F-VII)
2018 VLSI/CAD Symposium Tutorial (Aug. 7, 20:00-21:00 Room 3F-VII)2018 VLSI/CAD Symposium Tutorial (Aug. 7, 20:00-21:00 Room 3F-VII)
2018 VLSI/CAD Symposium Tutorial (Aug. 7, 20:00-21:00 Room 3F-VII)
 
Tcfsh bootcamp day2
 Tcfsh bootcamp day2 Tcfsh bootcamp day2
Tcfsh bootcamp day2
 
COSCUP 2014 : open source compiler 戰國時代的軍備競賽
COSCUP 2014 : open source compiler 戰國時代的軍備競賽COSCUP 2014 : open source compiler 戰國時代的軍備競賽
COSCUP 2014 : open source compiler 戰國時代的軍備競賽
 
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
Accelerating or Complicating PHP execution by LLVM Compiler Infrastructure
 
函数调用关系工具-2011-孙光福
函数调用关系工具-2011-孙光福函数调用关系工具-2011-孙光福
函数调用关系工具-2011-孙光福
 
版本控制 使用Git & git hub
版本控制   使用Git & git hub版本控制   使用Git & git hub
版本控制 使用Git & git hub
 
Python 2-基本語法
Python 2-基本語法Python 2-基本語法
Python 2-基本語法
 
CKAN : 資料開放平台技術介紹 (CAKN : Technical Introduction to Open Data Portal)
CKAN : 資料開放平台技術介紹 (CAKN : Technical Introduction to Open Data Portal)CKAN : 資料開放平台技術介紹 (CAKN : Technical Introduction to Open Data Portal)
CKAN : 資料開放平台技術介紹 (CAKN : Technical Introduction to Open Data Portal)
 
LLVM introduction
LLVM introductionLLVM introduction
LLVM introduction
 

2016-04-07-清大-國際化開源專案技術實務與經驗分享