Note that there are some explanatory texts on larger screens.

plurals
  1. POJava loads wrong resource
    primarykey
    data
    text
    <p>I have this 2 properties files in my resources folder: <strong>messages_hr_HR.properties</strong> and <strong>messages.properties</strong></p> <p>I don't use javas's Locale class I use mine custom Locale class:</p> <pre><code>public class Locale { private String bundleName; private String localeName; private String iconPath; public Locale(String bundleName, String localeName, String iconPath) { super(); this.bundleName = bundleName; this.localeName = localeName; this.iconPath = iconPath; } public String getBundleName() { return bundleName; } public void setBundleName(String bundleName) { this.bundleName = bundleName; } public String getLocaleName() { return localeName; } public void setLocaleName(String localeName) { this.localeName = localeName; } public String getIconPath() { return iconPath; } public void setIconPath(String iconPath) { this.iconPath = iconPath; } } </code></pre> <p>I have Messages class with static method to return the value of the key:</p> <pre><code>public class Messages { private Messages() { // do not instantiate } private static List&lt;Locale&gt; availableLocales; private static Locale defaultLocale = new Locale("messages.messages", "EN", "/images/icons/locale/en.png"); static { availableLocales = new ArrayList&lt;Locale&gt;(); availableLocales.add(defaultLocale); availableLocales.add(new Locale("messages.messages_hr_HR", "HR", "/images/icons/locale/hr.png")); } private static Locale LOCALE = defaultLocale; private static ResourceBundle RESOURCE_BUNDLE = loadBundle(); private static ResourceBundle loadBundle() { return ResourceBundle.getBundle(LOCALE.getBundleName()); } public static String getString(String key) { try { ResourceBundle bundle = RESOURCE_BUNDLE == null ? loadBundle() : RESOURCE_BUNDLE; return bundle.getString(key); } catch (MissingResourceException e) { return "!" + key + "!"; } } public static void setLocale(Locale locale) { LOCALE = locale; RESOURCE_BUNDLE = loadBundle(); } public static Locale getLocale() { return LOCALE; } public static List&lt;Locale&gt; getAvailableLocales() { return availableLocales; } } </code></pre> <p>Then in my GUI I have radiobutton menu with available languages and when user clicks on some I just call <code>Messages.setLocale(clickedLanguageLocale);</code></p> <p>So you can see that I am responsible of loading specific file, not java.</p> <p>Problem is that on some computers it acts strange. Some text is on english (messages.properties) and some on croatian (messages_hr_HR). First thing that got on my mind was some OS default locale but it does not make any sense since I use mine classes.</p> <p>Any ideas for this behavior?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload