ここでノブ。
コマンドラインベースのプログラムに国際化を実装しようとしています。以下は、Java 国際化トレイルで利用できるものです。
import java.util.*;
public class I18NSample {
static public void main(String[] args) {
String language;
String country;
if (args.length != 2) {
language = new String("en");
country = new String("US");
} else {
language = new String(args[0]);
country = new String(args[1]);
}
Locale currentLocale;
ResourceBundle messages;
currentLocale = new Locale(language, country);
messages = ResourceBundle.getBundle("MessagesBundle", currentLocale);
System.out.println(messages.getString("greetings"));
System.out.println(messages.getString("inquiry"));
System.out.println(messages.getString("farewell"));
}
}
これは明らかに機能しますが、いくつかのクラスがあります (現在パッケージには含まれていません)。これらのクラスを使用するには、これらすべてのクラスに同じバンドルをロードする必要がありますか?
私が最終的にやりたいのは、プログラムの最初に、ユーザーが使用したい言語を (利用可能な .properties ファイルのリストから) 選択できるようにすることです。特定のファイル。
これは可能ですか?
ありがとう