Flexで多言語アプリを作成する予定です。私のアプローチは次のようなものです。アプリケーション内のすべてのフレーズを含むXMLを作成するには...
<mx:Script>
<![CDATA[
public var selectedLanguage : String = "spanish";
public var language : xml =
<xml>
<message id="<<hashcode of the string in english>>" english="hello world" spanish="hola mundo" french="bonjour tout le monde"/>
<message id="<<hashcode of the string in english>>" english="good bye every body" spanish="adios a todos" french="tout le monde au revoir"/>
</xml>;
//Then a function to make the translation:
public function translate(msg:String):String{
//Maybe not a hashCodeFunction but some function to return an unique code for every string
var hashcode : int = hashCodeFunction(msg);
var translation : String = language.message.(@id==hashcode)[selectedLanguage];
if(translation==null) return msg;
return translation;
}
]]>
</mx:Script>
<mx:Button label="translate('hello world')"/>
ええと、xmlは別の方法で構造化することもできますが、私が欲しいのは「translate('some text')」のようなすべてのラベルを作成することです。 「translate('sometext')」のようなソースコード内のすべての文字列を検索し、「some text」を抽出する「プリプロセッサ」を作成し、ハッシュコードを計算してxmlに追加し、xmlの準備ができたらすべてアプリケーションは多言語になります。
誰かが共有する別のアプローチを持っているかどうか知りたいです。