2: 2019-02-15 (金) 08:19:37 yuji Attached file: python372jp.chm, Deleted an attach file: python372jp.chm at 2019-02-20 (水) 08:35:58 |
3: 2019-02-19 (火) 23:36:10 yuji Attached file: python372jp.chm, Deleted an attach file: python372jp.chm at 2019-02-21 (木) 13:46:13 |
||
---|---|---|---|
Line 18: | Line 18: | ||
ドキュメントを作成するのに必要なツールSphinx(Pythonで動作する)やTransifex(翻訳プロジェクト)などを,インストールする。 | ドキュメントを作成するのに必要なツールSphinx(Pythonで動作する)やTransifex(翻訳プロジェクト)などを,インストールする。 | ||
> pip install sphinx | > pip install sphinx | ||
+ | > pip install sphinx-intl | ||
> pip install blurb | > pip install blurb | ||
> pip install transifex-client | > pip install transifex-client | ||
Line 35: | Line 36: | ||
> cd cpython-doc-intl | > cd cpython-doc-intl | ||
> git checkout intl-3.6 | > git checkout intl-3.6 | ||
+ | |||
+ | ** Sphinxの設定ファイルを修正 [#e1844232] | ||
+ | Sphinxを使用して日本語ドキュメントが出力されるように,''conf.py''ファイルのGeneral configurationのどこかに,以下の追加・修正をする。 | ||
+ | language = 'ja' | ||
+ | locale_dirs = ['locale/'] | ||
+ | gettext_compact = False | ||
+ | : | ||
+ | : | ||
+ | today_fmt = '%m/%d/%Y' | ||
** 翻訳済みリソースをTransifexからダウンロードする [#sb5a1327] | ** 翻訳済みリソースをTransifexからダウンロードする [#sb5a1327] | ||
Line 55: | Line 65: | ||
Pythonドキュメントプロジェクト [[transifex>https://www.transifex.com/python-doc/]] での翻訳作業の成果を, [[Pythonドキュメント日本語訳プロジェクト>https://github.com/python-doc-ja/python-doc-ja]] に公開しているようだ。~ | Pythonドキュメントプロジェクト [[transifex>https://www.transifex.com/python-doc/]] での翻訳作業の成果を, [[Pythonドキュメント日本語訳プロジェクト>https://github.com/python-doc-ja/python-doc-ja]] に公開しているようだ。~ | ||
- | 翻訳作業を行っている [[transifex>https://www.transifex.com/python-doc/]] から,直接バージョン3.7.2の.poファイルをダウンロード(作業中で未完成だが)する場合は,~ | + | 翻訳するための設定ファイル.tx/configファイルを作成する。 |
- | > mkdir locale | + | |
> cd locale | > cd locale | ||
- | > tx init | + | > create-txconfig |
- | のようにして,ソースファイル名を入力するところでctrl-Cで止める。 | + | |
- | > tx config mapping-remote https://www.transifex.com/python-doc/python-newest/ | + | |
- | として,txの設定ファイル''.tx/config''を作成する。~ | + | |
- | そして,.tx/configファイルを, | + | Pythonドキュメントソースからメッセージカタログ(.pot)ファイルを作成する。~ |
- | awk '/file_filter/{sub("translations/python-newest.","",$3);print $1 " " $2 " " $3;print "source_file = pot/" $3;} !/file_filter/{print $0}' config | awk '/file_filter|source_file/{sub("/<lang>","",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("--","/",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter/{sub("= ","= <lang>/LC_MESSAGES/",$0);print $0;} !/file_filter/{print $0}' | awk '/source_file/{sub(/\.po/,".pot",$3);print $0;} !/source_file/{print $0}' | awk '{sub("type = PO","",$0);print $0;}' | awk '/host/{print $0;print "type = PO";} !/host/{print $0}' > config.1 | + | > sphinx-build -b gettext . locale/pot |
- | awk '/file_filter|source_file/{sub("email_", "email.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' config.1 | awk '/file_filter|source_file/{sub("http_", "http.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("logging_", "logging.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("os_", "os.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("tkinter_", "tkinter.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("unittest_", "unittest.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("urllib_", "urllib.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("xml_", "xml.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("xmlrpc_", "xmlrpc.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("glossary_", "glossary",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("dom_", "dom.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("etree_elementtree", "etree.elementtree",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("sax_", "sax.",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' > config.2 | + | |
- | awk '/file_filter|source_file/{sub("2_0", "2.0",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' config.2 | awk '/file_filter|source_file/{sub("2_1", "2.1",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_2", "2.2",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_3", "2.3",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_4", "2.4",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_5", "2.5",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_6", "2.6",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("2_7", "2.7",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_0", "3.0",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_1", "3.1",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_2", "3.2",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_3", "3.3",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_4", "3.4",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_5", "3.5",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_6", "3.6",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' | awk '/file_filter|source_file/{sub("3_7", "3.7",$3);print $1 " " $2 " " $3;} !/file_filter|source_file/{print $0}' > config.3 | + | |
- | copy config.3 config | + | |
- | del config.1 config.2 config.3 | + | |
- | とかして((もっと良い方法があると思うが,わからない。)), | + | |
- | [main] | + | |
- | host = https://www.transifex.com | + | |
- | type = PO | + | |
- | [python-newest.about] | + | 翻訳するための設定ファイル.tx/configファイルをpotファイル情報で更新する。 |
- | file_filter = <lang>/LC_MESSAGES/about.po | + | > sphinx-intl update-txconfig-resources --pot-dir pot --transifex-project-name="python-newest" |
- | source_file = pot/about.pot | + | > awk '/file_filter/{sub("locales/","");print $0} !/file_filter/{print $0}' .tx /config > .tx/config.2 |
- | source_lang = en | + | > cp .tx/config.2 .tx/config |
- | + | > rm .tx/config.2 | |
- | [python-newest.bugs] | + | |
- | file_filter = <lang>/LC_MESSAGES/bugs.po | + | |
- | source_file = pot/bugs.pot | + | |
- | source_lang = en | + | |
- | + | ||
- | [python-newest.c-api--abstract] | + | |
- | file_filter = <lang>/LC_MESSAGES/c-api/abstract.po | + | |
- | source_file = pot/c-api/abstract.pot | + | |
- | source_lang = en | + | |
- | : | + | |
- | : | + | |
- | のような構成に修正する。 | + | |
- | + | ||
- | 修正が終わったら, | + | |
> tx pull -l ja | > tx pull -l ja | ||
- | とすると,現在翻訳作業中の.poファイルがダウンロードできる。 | + | とすると,現在翻訳作業中の翻訳リソースの.poファイルがダウンロードできる。 |
*** Pythonドキュメント日本語訳プロジェクトのリソースを使う場合 [#n16ba263] | *** Pythonドキュメント日本語訳プロジェクトのリソースを使う場合 [#n16ba263] | ||
Line 108: | Line 92: | ||
* 日本語ドキュメント(HTML)を作成 [#w722d888] | * 日本語ドキュメント(HTML)を作成 [#w722d888] | ||
- | Sphinxを使用してHTMLの日本語ドキュメントが出力されるように,''conf.py''ファイルのGeneral configurationを,以下の追加・修正をする。 | + | ''conf.py''ファイルのOptions for HTML outputに,以下の修正をする。 |
- | language = 'ja' | + | html_last_updated_fmt = '%m/%d/%Y' |
- | locale_dirs = ['locale/'] | + | |
- | gettext_compact = False | + | 翻訳した.poファイル(実際には.moファイル)を使用して,ドキュメントファイル(HTMLファイル)をビルドしてみる。~ |
- | : | + | |
- | : | + | |
- | #today_fmt = '%B %d, %Y' <-- コメントアウト | + | |
- | 翻訳した.poファイルを使用して,ドキュメントファイル(HTMLファイル)をビルドしてみる。~ | + | |
> make clean html | > make clean html | ||
Line 142: | Line 122: | ||
この場合,LaTeX([[W32Tex>https://texwiki.texjp.org/?W32TeX]]を使ってる)やその他の周辺ツール,スタイルファイルなどが必要になる。 | この場合,LaTeX([[W32Tex>https://texwiki.texjp.org/?W32TeX]]を使ってる)やその他の周辺ツール,スタイルファイルなどが必要になる。 | ||
- | 日本語用のクラスファイルは,pTeXに付属するjarticle, jreport, jbookや,pLaTeX2eのjsarticle, jsbookがある。~ | + | 設定ファイル''conf.py''のOptions for LaTeX outputで,使用するエンジン''xelatex''をコメントアウトする。 |
- | LaTeXでは,article, report, bookは,それぞれ論文,報告書,書籍用というように使い分けするようだ。 | + | |
- | + | ||
- | ''conf.py''ファイルのOptions for LaTeX outputにある使用するエンジンを''xelatex''をコメントアウトする。 | + | |
#latex_engine = 'xelatex' | #latex_engine = 'xelatex' | ||
- | Sphinxのクラスでhowto, manualは,howtoが短い文書,manualが長い文書用に利用されるようだ。 | + | デフォルトの''platex''を使うようにする。 |
+ | |||
+ | Sphinxのクラスにhowtoとmanualがあって,howtoが短い文書,manualが長い文書に利用されるようだ。~ | ||
+ | 使用するドキュメントクラスは,デフォルト設定のhowtoに''jreport'',manualに''jsbook''が使われる。変更したい場合は, | ||
+ | latex_docclass = {"howto": "jsreport", "manual": "jsbook"} | ||
+ | のように設定する。 | ||
- | ''conf.py''ファイルの''latex_elements['preamble']''に,以下のように追加する。 | + | ''conf.py''ファイルのプリアンプル''latex_elements['preamble']''に,以下のように追加する。 |
latex_elements['preamble'] = r''' | latex_elements['preamble'] = r''' | ||
\authoraddress{ | \authoraddress{ | ||
Line 158: | Line 140: | ||
\let\endVerbatim=\endOriginalVerbatim | \let\endVerbatim=\endOriginalVerbatim | ||
\usepackage[utf8]{inputenc} | \usepackage[utf8]{inputenc} | ||
+ | \DeclareUnicodeCharacter{00DC}{\={U}} | ||
+ | \DeclareUnicodeCharacter{00FC}{\={u}} | ||
+ | \DeclareUnicodeCharacter{0130}{\={I}} | ||
+ | \DeclareUnicodeCharacter{0131}{\={i}} | ||
\DeclareUnicodeCharacter{017F}{\={s}} | \DeclareUnicodeCharacter{017F}{\={s}} | ||
- | \DeclareUnicodeCharacter{212A}{\={.}} | + | \DeclareUnicodeCharacter{0404}{\={e}} |
+ | \DeclareUnicodeCharacter{212A}{\={K}} | ||
: | : | ||
: | : | ||
+ | いくつかの.texファイル(library.tex,howto-logging.tex,using.tex)で,画像を読み込んでいるところでエラーが出るので,''conf.py''のOptions for LaTeX outputに,以下を追加する。 | ||
+ | latex_elements['passoptionstopackages'] = r''' | ||
+ | \usepackage[dvipdfmx]{graphicx} | ||
+ | ''' | ||
** texファイルを作成して,さらにpdfファイルを作成する [#ab6bf0be] | ** texファイルを作成して,さらにpdfファイルを作成する [#ab6bf0be] | ||
Line 168: | Line 159: | ||
この時,文書サイズをA4かletterか指定できる。~ | この時,文書サイズをA4かletterか指定できる。~ | ||
うまくいくと,build/latexディレクトリに.texファイルが作成されている。 | うまくいくと,build/latexディレクトリに.texファイルが作成されている。 | ||
- | |||
- | いくつかの.texファイル(library.tex,howto-logging.tex,using.tex)で画像を読み込んでいるがエラーが出るので, | ||
- | \usepackage[dvipdfmx]{graphicx} | ||
- | を | ||
- | \usepackage{sphinx} | ||
- | の前あたりに追加する。 | ||
texファイルからPDFファイルに変換してみる。 | texファイルからPDFファイルに変換してみる。 |