私はのアプリケーションで国際化をサポートしたいと考えています。japanese.Myプロパティファイル名はApplicationです。Application_ja.propertiesファイルで動作しますが、 Application_ja_JP.propertiesファイルでは機能しません。私はtomcatサーバー上でアプリケーションを実行しています。 私を助けてください。ストラット内での国際化
0
A
答えて
0
私は2つの言語をサポートするアプリケーションを作成しました。私はあなたが私に説明しようとするいくつかのコードを貼り付けていない場合。私はロケールを処理するためのStruts Actionクラスを作成まず
、このクラスのメソッドがあります。
public ActionForward en(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, Locale.ENGLISH);
return mapping.findForward(SUCCESS);
}
public ActionForward lt(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
request.getSession().setAttribute(
Globals.LOCALE_KEY, new Locale("lt"));
return mapping.findForward(SUCCESS);
}
英語のための一つの方法とリトアニア語のための1つの方法。 (application.propertiesとapplication_lt.properties)
<message-resources parameter="lt/klc/resources/application_lt"/>
<message-resources parameter="lt/klc/resources/application"/>
私がしたい:私は私のリソースを宣言し
<action input="/views/index.jsp"
parameter="method"
path="/locale"
scope="request"
type="lt.klc.action.LanguageSelectAction"
validate="false">
<forward name="success" path="/views/index.jsp"/>
</action>
:
私は私のstruts-config.xmlファイルで、このアクションクラスを宣言しましたチャージの言語私は電話したい方法を提供することで、このクラスを簡単に呼び出します:<html:link action="locale.xhtml?method=en">English</html:link>
<html:link action="locale.xhtml?method=lt">Lietuviškai</html:link>
Hこれは役に立ちます。
0
Suppose you have two properties files-
struts_en_UK.properties
common.color = colour
struts_en_US.properties
common.color = color
The following code will fetch the resource from properties file as follows-
Locale locale = new Locale("en", "UK");
ResourceBundle bundle = ResourceBundle.getBundle("struts",locale);
System.out.println(bundle.getString("common.color"));
Locale usLocale = new Locale("en", "US");
ResourceBundle usBundle = ResourceBundle.getBundle("struts",usLocale);
System.out.println("Us Locale : "+usBundle.getString("common.color"));
関連する問題
- 1. JavaScript内の国際化
- 2. Spring - プレースホルダ内の国際化メッセージ
- 3. Struts2 +国際化
- 4. ルビー - 国際化
- 5. モノ国際化
- 6. YAML国際化
- 7. カスタムモデルエラーの国際化
- 8. AngularJSの国際化
- 9. SSRSの国際化
- 10. Railsの国際化
- 11. Javaの国際化
- 12. Yii2での国際化(データベース)
- 13. Qtでの国際化4.8
- 14. 国際化検証
- 15. Struts2 +国際化+ Java
- 16. Android WebView国際化
- 17. JDeveloperと国際化
- 18. cakePHP 3.3国際化
- 19. Springのプレースホルダの国際化
- 20. VB 6アプリケーションの国際化
- 21. asp.net Webフォームの国際化
- 22. Struts2ラジオボタンの国際化
- 23. 国際化の問題
- 24. symfonyのi18n(国際化)
- 25. 成果の国際化
- 26. iPhoneアプリケーションの国際化
- 27. Springプロジェクトの国際化
- 28. Javascriptライブラリの国際化(i18n)
- 29. ボタン画像の国際化
- 30. Djangoアプリケーションのレイアウト:国際化
回答が必要な場合は、質問に答えられていない限り、前の質問に同意してください。 –
リソースから読み取る方法にコードフラグメントを貼り付けるように気をつけますか?また、Localeオブジェクトを作成して渡す方法は?現時点では、あなたは "どこかでコードエラーがあります"以外の質問に答えることは実際には不可能です。私はあなたがそのような答えを読むことを望んでいるとは思わない... –