package
read.properties.file;
import java.util.Locale;
import
java.util.ResourceBundle;
public class
ResourcesBundleExample {
public static void main(String[] args) {
ResourceBundle bundle = ResourceBundle.getBundle("config");
// read config_tr_TR.properties
Locale.setDefault(new Locale("tr", "TR"));
bundle = ResourceBundle.getBundle("config");
System.out.println("Current
Locale: " + Locale.getDefault());
System.out.println("my name is:
"
+ bundle.getString("who_are_you"));
// read config_en_US.properties
Locale.setDefault(new Locale("en", "US"));
bundle = ResourceBundle.getBundle("config");
System.out.println("Current
Locale: " + Locale.getDefault());
System.out.println("my name is:
"
+ bundle.getString("who_are_you"));
}
}
|
config_tr_TR.properties
config_en_US.properties
|
outputs:
Current Locale: tr_TR
my name is: eda_TR
Current Locale: en_US
my name is: eda_EN
No comments:
Post a Comment