v4.2
 Softimage ディクショナリに指定されている文字列を検索し、それに相当する他言語の文字列を戻します。
Softimage には翻訳辞書(英語から他の言語に翻訳するストリングテーブル)の概念があります。各翻訳辞書は、factory/Application/Dictionary/en に保存される.dict ファイルです。これらの辞書を他の言語に翻訳すると、その言語用のディレクトリに同名のファイルが作成されます。たとえば、日本語の翻訳は jp ディレクトリに保存されます。
英語版のファイルに文字列を指定することにより、各文字列が数値 ID で参照できるようになります。
文字列にはその言語固有のデータを含めなければならない場合があります。たとえば、「File c:¥temp¥myfile.txt not found」というメッセージのファイル名やディレクトリ名を翻訳することはできません。このような場合は、プレースホルダ(String1、String2、String3 引数で最大 3 つの文字列を代入できます)として%トークンを使用できます。
%sトークンの数は、オプション文字列の数と一致している必要があります(最大3個)。書式が%D であるトークンはサポートしていません。%d トークンが存在するとクラッシュする場合があります。
たとえば、"File c:¥temp¥myfile.txt not found"の代わりに"File %s not found"の書式で記述し、Translation メソッドを呼び出すると、引数 String1 を使用してファイル名が指定されます。 
| String XSIUtils.Translate( Object in_ToTranslate, String in_Dictionary, String in_string1, String in_string2, String in_string3 ); | 
| oString = XSIUtils.Translate( Key, Dictionary, [String1], [String2], [String3] ); | 
| パラメータ | タイプ | 説明 | 
|---|---|---|
| Keys | Stringまたは Integer | 文字列が渡されると、英語辞書内の一致する文字列が検索されます。文字列が見つかった場合は、その文字列に対応する文字列が現在の辞書から取得され、戻されます。文字列が見つからない場合は入力した文字列が戻されます。現在の辞書が英語辞書の場合は常に入力した文字列が戻されます。 また、辞書の文字列ID を入力することも可能です。この場合は、直接現在の言語の辞書から文字列を検索します。その ID を持つ文字列が見つからない場合は空の文字列が戻されます。 | 
| Dictionary | String | 検索するディレクトリの名前。ファイル名から.dict拡張子を取り除いた名前が辞書名です。 | 
| String1 | String | 1 番目の%s を辞書内の文字列に対応させるためのオプションの引数。 | 
| String2 | String | 2 番目の%s を辞書内の文字列に対応させるためのオプションの引数。 | 
| String3 | String | 3 番目の%s を辞書内の文字列に対応させるためのオプションの引数。 | 
| // Demonstration of XSIUtils.Translate
currentLang = GetValue("Preferences.General.language") ;
Application.LogMessage( "The current language is " + currentLang ) ;
// You can't translate any arbitrary string, only
// ones that are already in the dictionary.
pixelRatio = XSIUtils.Translate( "Pixel Ratio", "XSIXSI" ) ;
Application.LogMessage( "Pixel Ratio translated is " + pixelRatio ) ;
// Load a Softimage warning message, in English
// it says "Do you want to remove it?"
errorMsg = XSIUtils.Translate( 333, "XSIMSGCAT" ) ;
XSIUIToolkit.MsgBox( errorMsg ) ;
// This is an error message that contains additional
// context information
// Dictionary contains: "31$Path %s has been changed to %s"
// Resulting string is:
// WARNING : 31$Path C:\out.txt has been changed to C:\temp\out.txt
warningMsg = XSIUtils.Translate(32, "XSIMSGCAT", "C:\\out.txt", "C:\\temp\\out.txt" );
Application.LogMessage( warningMsg, siWarning ) ; |