多言語対応の準備をしましょうかね その5
「4. Qtに含まれるlupdateコマンドを使って多言語対応したい文字列の情報を取得する」です。
lupdateコマンドを実行すると.proで指定されたソースファイル(SOURCES)を全部解析して、tr()マクロで書かれた文字列定数の翻訳のためのデータのテンプレート(.ts)を生成します。
実行するコマンドは以下の様な感じです。
lupdate -verbose brynhildr.pro
出来上がった.tsファイルは以下の様な感じです。
lupdateコマンドを実行すると.proで指定されたソースファイル(SOURCES)を全部解析して、tr()マクロで書かれた文字列定数の翻訳のためのデータのテンプレート(.ts)を生成します。
実行するコマンドは以下の様な感じです。
lupdate -verbose brynhildr.pro
出来上がった.tsファイルは以下の様な感じです。
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE TS> <TS version="2.1" language="ja_JP"> <context> <name>QObject</name> <message> <location filename="../main.cpp" line="39"/> <source>Setting up the main window ...</source> <translation type="unfinished"></translation> </message> </context> <context> <name>brynhildr::Brynhildr</name> <message> <location filename="../brynhildr.cpp" line="91"/> <source>Exit</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="92"/> <source>Exit Qt Brynhildr</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="96"/> <source>About</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="97"/> <source>Show Qt Brynhildr</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="101"/> <source>About &Qt</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="102"/> <source>Show Qt library's About box</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="109"/> <source>&File</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="115"/> <source>&Help</source> <translation type="unfinished"></translation> </message> <message> <location filename="../brynhildr.cpp" line="151"/> <source>connected : </source> <translation type="unfinished"></translation> </message> </context> </TS>sourceタグに囲まれた文字列がソースコードに埋め込まれたデフォルトの文字列です。翻訳が終わっていないので"unfinished"という文字列が見えますね。さて、次はやっと翻訳作業です。
« 今後の妄想をつぶやく | トップページ | 多言語対応の準備をしましょうかね その6 »
コメント