J
jacekfoo
Could you tell me where .properties file should be put in my program?
It is put in the same folder as class calling getResourceBoundle and it
still can't find these files.
Or maybe I misunderstood Java tutorial?
I want to use simple class called DefaultBooleanField that is supposed
to return true and false in many languages. In the same folder that
this class resides I have put BooleanField.properties, and
BooleanField_pl.properties.
Function that is supposed to take user readable values looks like that:
//StaticContent is some static class with some shared data.
@Override
public String takeUserText() {
if(contents)
return ResourceBundle.getBundle("BooleanField",
StaticContent.getLocale())
.getString("true");
return ResourceBundle.getBundle("BooleanField",
StaticContent.getLocale())
.getString("false");
}
And Main functions of test program looks like that:
public static void main(String[] args) {
StaticContent.setLocale(new Locale("pl", "PL"));
System.out.println(new DefaultBooleanField(true).takeUserText());
System.out.println(new DefaultBooleanField(false).takeUserText());
}
Thanks for any help.
It is put in the same folder as class calling getResourceBoundle and it
still can't find these files.
Or maybe I misunderstood Java tutorial?
I want to use simple class called DefaultBooleanField that is supposed
to return true and false in many languages. In the same folder that
this class resides I have put BooleanField.properties, and
BooleanField_pl.properties.
Function that is supposed to take user readable values looks like that:
//StaticContent is some static class with some shared data.
@Override
public String takeUserText() {
if(contents)
return ResourceBundle.getBundle("BooleanField",
StaticContent.getLocale())
.getString("true");
return ResourceBundle.getBundle("BooleanField",
StaticContent.getLocale())
.getString("false");
}
And Main functions of test program looks like that:
public static void main(String[] args) {
StaticContent.setLocale(new Locale("pl", "PL"));
System.out.println(new DefaultBooleanField(true).takeUserText());
System.out.println(new DefaultBooleanField(false).takeUserText());
}
Thanks for any help.