c-bata / webframework-in-python

"How to write WSGI WEB Framework" talked at PyConJP 2016
https://c-bata.github.io/webframework-in-python/
25 stars 3 forks source link

Translate into English using Google Translate API #13

Closed c-bata closed 1 year ago

c-bata commented 6 years ago

Creating po files

See: https://www.sphinx-doc.org/ja/1.7/intl.html

$ pip install sphinx-intl
$ vim source/conf.py
# add following settings
# locale_dirs = ['locale/']
# gettext_compact = False
$ make gettext
$ ls build/locale/
index.pot      kobin.pot      middleware.pot request.pot    response.pot   routing.pot    server.pot     sphinx.pot     template.pot   wsgi.pot
$ sphinx-intl update -p build/locale -l ja
Create: source/locale/ja/LC_MESSAGES/kobin.po
Create: source/locale/ja/LC_MESSAGES/template.po
Create: source/locale/ja/LC_MESSAGES/middleware.po
Create: source/locale/ja/LC_MESSAGES/sphinx.po
Create: source/locale/ja/LC_MESSAGES/request.po
Create: source/locale/ja/LC_MESSAGES/routing.po
Create: source/locale/ja/LC_MESSAGES/wsgi.po
Create: source/locale/ja/LC_MESSAGES/response.po
Create: source/locale/ja/LC_MESSAGES/index.po
Create: source/locale/ja/LC_MESSAGES/server.po

Translating po files into English.

Use a following snippet. https://gist.github.com/c-bata/27edee8a02815e1858ad94e77e78ed13

c-bata commented 6 years ago

Cost: 30 yen.

$ python translate_po.py --lang en ja/LC_MESSAGES/index.po 1>index_en.po
Cost: 3.6904620000000006 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/kobin.po 1>kobin_en.po
Cost: 0.024617999999999998 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/middleware.po 1>middleware_en.po
Cost: 1.60017 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/request.po 1>request_en.po
Cost: 4.728894 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/response.po 1>response_en.po
Cost: 3.8784539999999996 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/routing.po 1>routing_en.po
Cost: 5.8188 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/server.po 1>server_en.po
Cost: 1.087668 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/template.po 1>template_en.po
Cost: 1.4009880000000001 yen
$ python translate_po.py --lang en ja/LC_MESSAGES/wsgi.po 1>wsgi_en.po
Cost: 7.00494 yen

Cache size

$ du -h po-translation-cache.json
132K    po-translation-cache.json
c-bata commented 6 years ago
$ make -e SPHINXOPTS="-D language='ja'" html
$ open build/html/index.html
2018-10-28 21 33 54

It seems that there are quotes we need to remove.

c-bata commented 6 years ago
$ ./translate.sh
Cost: 0.0 yen
Cost: 0.020142000000000004 yen
Cost: 1.562124 yen
Cost: 4.641611999999999 yen
Cost: 3.809076 yen
Cost: 5.686758 yen
Cost: 1.05186 yen
Cost: 0.30213 yen
Cost: 1.3428 yen
Cost: 6.89304 yen
2018-10-28 21 50 59 2018-10-28 23 20 03 2018-10-28 23 20 18