1 year ago
#384793
Mike Witten
I can't get java to recognize my resource bundle?
I'm new to Java (and coding in general) and I am trying to understand how to work with localization, but I am running into a problem when just following along with tutorials.... My bundles aren't being found.
here is my main
package com.company;
import java.util.Locale;
import java.util.ResourceBundle;
public class Main {
public static void main(String[] args) {
Locale eng = new Locale("en" );
Locale fre = new Locale("fr");
Locale span = new Locale("es");
ResourceBundle englishBundle = ResourceBundle.getBundle("myBundle", eng);
ResourceBundle frenchBundle = ResourceBundle.getBundle("myBundle", fre);
ResourceBundle spanishBundle = ResourceBundle.getBundle("myBundle", span);
System.out.println(englishBundle.getString("hello"));
System.out.println(frenchBundle.getString("hello"));
System.out.println(spanishBundle.getString("hello"));
}
}
I created the bundle using intelliJ create Resource Bundle which gave me 4 files.
myBundle.properties
myBundle_en.properties
myBundle_es.properties
myBundle_fr.properties
Each file has a single translation hello
When I run the code I get the following exception: MissingResourceException: cant find bundle for base name myBundle
java
intellij-idea
localization
0 Answers
Your Answer