Aloha guy's,
can you explain the file for what this can be good?? in project explorer -> Gradle: org.controlsfx:controlsfx:8.40.12 -> Resource Bundel 'controlsfx' -> here the different file in different language. Can i with this translate my Programm content englisch,Germany,Polish and can i make it editable
2.if the first one was a stupid idee how i can translate it? my idee is make translate properties lake this english.properties, germany.properties, polish.properties save in resources with loade with this
stateManager.setPersistenceMode(StateManager.PersistenceMode.USER);
try { input = new FileInputStream( stateManager.getProperty("Languge").orElse("").toString().trim()+".properties");// load a properties file prop.load(input);
// get the property value and print it out System.out.println(prop.getProperty("database")); System.out.println(prop.getProperty("dbuser")); System.out.println(prop.getProperty("dbpassword")); } catch (IOException ex) { ex.printStackTrace(); } finally { if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } }
If you create a Desktop project with the Gluon plugin for your IDE, using for instance the Multi View Project template, you will notice that each view has a properties file.
This default properties file contains key-values in English. But you can easily create a copy of that file, rename it with a different locale, and using the same keys, provide values in that locale.
For instance, for
primary.properties
you can create
primary_es.properties
in the same package, with:Once you have several locales for a given properties file, your IDE will show all at once:
And this is it, you don't need to change anything in your code. The default locale will be used to select the correct properties file.
Obviously, you can select a different locale in runtime. For that you will have to use a different resource bundle: