EDIT: Below is the answer for those who need a more exotic language. If you use one of them: de, es, fr, it, ja, ko, pt, sv, zh @ sergey-grinev provided a sufficient answer.
I came up with two solutions. Both rely on the properties file. You can create your own, based on examples found in com/sun/javafx/scene/control/skin/resources/ in jxfrt.jar with JRE.
All examples will use the Polish locale ( new Locale("pl", "PL") ), which is not built-in.
Solution 1
Create a JAR file with the following structure (change suffix accordingly)
com/sun/javafx/scene/control/skin/resources/controls_pl_PL.properties
and put it in
<path_to_JVM>/lib/ext
What is it.
I'm not sure what the license says about placing user files in com.sun.* , so here is another solution.
Decision 2
Create the properties file as described above, but you can name it and place it where you want. Say it will be
path/to/my/resources/polish.properties
Create two classes - ResourceBundle.Control and ResourceBundleControlProvider ( read more ), like this.
public class CustomLocaleFxResourceBundleControl extends ResourceBundle.Control { static final String FX_BASE_NAME = "com/sun/javafx/scene/control/skin/resources/controls"; private static final Locale MY_LOCALE = new Locale("pl", "PL"); @Override public String toBundleName(String baseName, Locale locale) { if (FX_BASE_NAME.equals(baseName) && MY_LOCALE.equals(locale)) return "path/to/my/resources/polish";
public class CustomLocaleFxResourceBundleControlProvider implements ResourceBundleControlProvider { private static final ResourceBundle.Control MY_RESOURCE_BUNDLE_CONTROL = new CustomLocaleFxResourceBundleControl(); public ResourceBundle.Control getControl(String baseName) { if (CustomLocaleFxResourceBundleControl.FX_BASE_NAME.equals(baseName)) return MY_RESOURCE_BUNDLE_CONTROL; return null; } }
Compile these classes and put them in a JAR file along with your resource and META-INF . META-INF folder should have the following structure
META-INF/services/java.util.spi.ResourceBundleControlProvider
java.util.spi.ResourceBundleControlProvider is a text file that is only a string in the ResourceBundleControlProvider class. In our case, it's just
CustomLocaleFxResourceBundleControlProvider
Complete jar in
<path_to_JVM>/lib/ext