Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add zh translation #29

Merged
merged 19 commits into from
Dec 25, 2015
Merged

Add zh translation #29

merged 19 commits into from
Dec 25, 2015

Conversation

ccwang002
Copy link
Member

To resolve #18

Set up Transifex client

Refer to Transifex client doc, add the file ~/.transifexrc.

Upload the raw messages to Transifex

  1. Run python manage.py makemessages -l zh to update the po files (will do fuzzy match).
  2. At src/, run tx push -s update source file.

Update the translation from Transifex

  1. At src/, run tx pull -l zh-Hant to download translated po files from Transifex
  2. Run python manage.py compilemessages -l zh to compile mo files

Use the translation

Use http://localhost:8000/i18n/ to change the locale in use.
To disable it, revert 55fd904.

(這個應該要改成用 URL 來做的,但我太懶了)

@codecov-io
Copy link

Current coverage is 89.13%

Merging #29 into master will not affect coverage as of 3413b2e

@@            master     #29   diff @@
======================================
  Files           25      25       
  Stmts          497     497       
  Branches         0       0       
  Methods          0       0       
======================================
  Hit            443     443       
  Partial          0       0       
  Missed          54      54       

Review entire Coverage Diff as of 3413b2e

Powered by Codecov. Updated on successful CI builds.

zh-hant becomes zh due to some Django internal process.
@uranusjr
Copy link
Member

問一下,Transifex 是會自動 pull 新的字串嗎?

@ccwang002
Copy link
Member Author

不會,要手動 push / pull

@uranusjr
Copy link
Member

從 Transifex pull 回 repo 是應該要有個人負責手動沒錯,但從 repo push 到 Transifex 感覺可以接到 Travis CI 上。不過我好像沒在文件裡找到指令,有 pointer 嗎?

@ccwang002
Copy link
Member Author

tx push -s 就可以,但需要 .transifexrc (好像沒有 API token 所以一定要存帳密的樣子)

@ccwang002
Copy link
Member Author

Travis Transifex integration source code: https://github.com/travis-ci/dpl/blob/master/lib/dpl/provider/transifex.rb

這邊有範例:

所以應該是做得到?

@uranusjr
Copy link
Member

剛試了一下好像要權限才能 push

Exception: Only maintainers are allowed to update the source file.

可能要再設定一下(或者以後就交給你負責了這樣我也 OK!)

@ccwang002
Copy link
Member Author

不不,果斷開啊

@uranusjr
Copy link
Member

綜合上面 Travis,開個 pycontw 當 bot 帳號來 push 好了?

@ccwang002
Copy link
Member Author

email ?

@uranusjr
Copy link
Member

我創好了,email 先設 web [at] pycon.tw,@daikeren 麻煩幫認證一下了。

@uranusjr
Copy link
Member

OK 我搞定了 Travis,不過現在的 .gitignore 有包含 .mo,所以在 deploy 時需要 compilemessages。我有在 fabfile 多加了這個,但需要先確認 staging 和 production 機器上有 gettext 才能 merge 這個,不然 deploy 會失敗。

話說其實我不是很確定 ignore .mo 是不是好主意。如果 ignore 它們,所有開發的人都需要記得偶爾在本機跑一下 compilemessages 才能把翻譯的結果實際套用到本機的網頁上。這可能會造成一些很奇怪的誤會,開發起來也不太順。Django 本身其實前陣子才討論過這個,但最終結果是保留 .mo 檔。或許需要考慮一下。

@uranusjr uranusjr mentioned this pull request Dec 24, 2015
@daikeren
Copy link
Contributor

把 .mo 檔塞進去 repo 不小心也會被某人蓋掉,所以我還是會在實際 deploy 的機器上面跑 compilemessages。不過還是會把 .mo 檔加進去 .gitignore 吧,這樣子不需要管翻譯的人可以不需要在 local 跑 compilemessages,開發會比較方便一點。

Since developer may not want to run compilemessages in develop time, let's put .mo in repo!
@uranusjr
Copy link
Member

剛剛想到可以在 Travis 上多加一個 after_success hook 讓它在 master 上自動跑 compilemessages commit 回來,這樣就不用記得要自己跑了。當然 deploy 機器上還是再跑一下比較好。

@daikeren
Copy link
Contributor

這部分流程(文件 XD)就讓 @ccwang002 決定(寫下來)吧!

@ccwang002
Copy link
Member Author

現在的流程應該很自動化了,我整理一下:

  • 不理翻譯的開發流程與之前一模一樣
  • 平常 master branch 有更新,Travis CI 就會自動更新 Transifex 上面的字串
  • locale 用 /i18n/ 這個網址去改 cookie 裡的語言設定(未來應該要改)
  • Transifex 就我或 TP 定時把字串抓下來,更新 po 和 mo 檔,commit 回 master branch 裡

Transifex 就歡迎大家自己翻,翻完如果沒出現在自己的環境,就 ping 我或 TP

@ccwang002
Copy link
Member Author

那我 merge 了,雖然還沒有實作 lang URL。

ccwang002 added a commit that referenced this pull request Dec 25, 2015
@ccwang002 ccwang002 merged commit 7edaddf into master Dec 25, 2015
@ccwang002 ccwang002 deleted the transifex branch December 25, 2015 03:36
@daikeren
Copy link
Contributor

@ccwang002 你 merge 太快了 ... 好歹讓我再確認一下吧 orz

@ccwang002
Copy link
Member Author

krdai.info 沒有設定 transifex-client 現在 deploy 會出錯

應該是這部份啦

@daikeren
Copy link
Contributor

是說這種會跟 deploy 環境有關的以後可能讓我 merge 吧

@flywindy
Copy link
Contributor

是說,以後大家就乖乖 pull request,讓 @daikeren 負責 merge master 吧?

@ccwang002
Copy link
Member Author

QQ... 好的…

@uranusjr
Copy link
Member

說到切換語系,我覺得這可能直接做在每一頁裡比較好,例如像 Pinkoi 是做在 footer 最右下角我覺得不錯。不太確定我們現在的版有沒有 footer,沒有的話做在 navbar 也是個選擇。麻煩 @flywindy 和設計師討論的時候記得考慮到這個東西~

@ccwang002
Copy link
Member Author

我目前是隨便做個能動的,因為加到 navbar 會炸 layout

@ccwang002 ccwang002 mentioned this pull request Dec 25, 2015
@ccwang002
Copy link
Member Author

https://github.com/pycontw/pycontw2016/blob/master/fabfile.py#L95

不應該讓 Travis CS 自動把 translation 結果上傳上去,不然上面的記錄會被蓋掉。只要 tx push -s 就好

uranusjr added a commit that referenced this pull request Dec 25, 2015
@ccwang002
Copy link
Member Author

Yay. Merry Christmas!
Transifex zh 100% progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

多國語系
5 participants