Localization ServiceローカライゼーションサービスThere is a Turbine service that makes it easy to add localization support to your application. 国際化のサポートをアプリケーションへ追加するTurbineのサービスです。 Configuration設定# ------------------------------------------------------------------- # # S E R V I C E S # # ------------------------------------------------------------------- # Classes for Turbine Services should be defined here. # Format: services.[name].classname=[implementing class] # # To specify properties of a service use the following syntax: # service.[name].[property]=[value] # Turbineのサービスのためのクラス群はここに定義します。 # フォーマット: services.[name].classname=[implementing class] # # サービスのプロパティを設定するには、以下の書式を使用します: # service.[name].[property]=[value] services.GlobalCacheService.classname=org.apache.fulcrum.cache.TurbineGlobalCacheService . . . Usage使用方法
TurbineServices.getInstance().getService(LocalizationService.LOCALIZATION)
.getString("DISPLAYPROJECTS_TITLE");
Wow. That is a lot of typing. That could be easily shortened to this: Wow. これをタイプするのは大変ですね。これはこのように短くすることが出来ます:
Localization.getString("DISPLAYPROJECTS_TITLE");
The hard example above was given as an example of using Services. The easy example is the one that you really should be using. Another cool feature of the Localization class is that you can pass in a RunData object like this: 上記の理解困難な例は、サービスの利用例としてあげました。 こちらの簡単な例は、実際に使用されるものです。 Localizationクラスのもう一つのクールな特徴は、RunDataオブジェクトをこのように渡すことができることです: Localization.getString(data, "DISPLAYPROJECTS_TITLE"); This has the added effect of using the Accept-Language HTTP header to determine which language to display based on what setting the user has defined in the browser. Can you say Dynamic Localization? ;-) これはAccept-Language HTTPヘッダを使用し、どのような設定をユーザがブラウザに定義したかに基づいて、どの言語で表示を行うかを決定する効果を追加します。 あなたは動的な国際化を行い話すことができますか? ;-) For creating the file where you get the value of the String, please see the java.util.ListResourceBundle and java.util.ResourceBundle classes for more information. Jyve also contains example usage of this code because that was the first place where this code was originally developed. Stringの値を取得する元となるファイルを作成することの詳細に関しては、java.util.ListResourceBundleとjava.util.ResourceBundleを参照してください。 Jyveはこのコードの使用例も含んでいます。 なぜならば、ここがこのコードが開発された最初の場所であるからです。 |