トップ «前の日記(2012-06-19) 最新 次の日記(2012-06-21)» 編集

Cocoa練習帳

iOS/iPhone/iPad/watchOS/tvOS/MacOSX/Android プログラミング, Objective-C, Cocoa, Swiftなど

2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|09|10|11|12|
2024|01|02|03|

2012-06-20 [iOS]多言語化(2)

ibtoolは仕様が代わったようで、以前のiPhone SDK向けの情報と違いがあるようだ。

まずは、基本的なibtoolを使用方法を試してみる。

前回の手作業で日本語版Storyboardのローカライズは、自動化というか、機械化というか、手順化できないという課題がある。ibtoolはそれを行う為のツールだ。

ベースとなる英語版Storybardから文字列情報を抜き出す。

$ ibtool --export-strings-file MainStoryboard.strings MainStoryboard.storyboard

生成したMainStoryboard.stringsを日本語環境にコピーして、文言の日本語に変更する。

$ cp MainStoryboard.strings ../ja.lproj/

これがオリジナル。

/* Class = "IBUITableViewController"; title = "Master"; ObjectID = "12"; */
"12.title" = "Master";
 
/* Class = "IBUIViewController"; title = "Detail"; ObjectID = "21"; */
"21.title" = "Detail";
 
/* Class = "IBUINavigationItem"; title = "Detail"; ObjectID = "26"; */
"26.title" = "Detail";
 
/* Class = "IBUILabel"; text = "Detail view content goes here"; ObjectID = "27"; */
"27.text" = "Detail view content goes here";
 
/* Class = "IBUINavigationItem"; title = "Master"; ObjectID = "36"; */
"36.title" = "Master";
 
/* Class = "IBUILabel"; text = "Title"; ObjectID = "phq-AM-6qj"; */
"phq-AM-6qj.text" = "Title";

これを翻訳する。


/* Class = "IBUITableViewController"; title = "Master"; ObjectID = "12"; */
"12.title" = "原盤";
 
/* Class = "IBUIViewController"; title = "Detail"; ObjectID = "21"; */
"21.title" = "詳細表示";
 
/* Class = "IBUINavigationItem"; title = "Detail"; ObjectID = "26"; */
"26.title" = "詳細表示";
 
/* Class = "IBUILabel"; text = "Detail view content goes here"; ObjectID = "27"; */
"27.text" = "ここに詳細を表示";
 
/* Class = "IBUINavigationItem"; title = "Master"; ObjectID = "36"; */
"36.title" = "原盤";
 
/* Class = "IBUILabel"; text = "Title"; ObjectID = "phq-AM-6qj"; */
"phq-AM-6qj.text" = "表題";

これから日本語版Storyboardを生成。

$ ibtool --import-strings-file MainStoryboard.strings --write MainStoryboard.storyboard ../en.lproj/MainStoryboard.storyboard

翻訳されている。

storyboard

勿論、実行しても。

run

トップ «前の日記(2012-06-19) 最新 次の日記(2012-06-21)» 編集