Pregunta

java.util.MissingResourceException: Can't find bundle for base name xxx.i18n.base, locale en_US

I am currently implementing i18n, using Facelets. I have three .properties files:

  • xxx.i18n.base.properties
  • xxx.i18n.base_en_US.properties
  • xxx.i18n.base_nl_NL.properties

faces-config.xml

<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="2.0"
    xmlns="http://java.sun.com/xml/ns/javaee" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd">

    <application>
        <locale-config>
            <default-locale>nl_NL</default-locale>
            <supported-locale>en_US</supported-locale>
        </locale-config>
        <resource-bundle>
            <base-name>xxx.i18n.base</base-name>
            <var>base</var>
        </resource-bundle>
    </application>
</faces-config>

As the error stated, I have trouble locating the en_US file, but when I set my locale for nl_NL, it can not be found either. Finally, putting the locale to something like de_DE will give me this result for de_DE, even though this locale is not defined as supported.

I'm using the following syntax to retreive values from the .properties files

#{base['msg']}

Does anyone have any idea as to why my application can not seem to find these locale files?

¿Fue útil?

Solución 2

Seems that I had located my properties files in the wrong folder: java/xxx/i18n instead of resources/xxx/i18n

After replacing the properties files my problem was solved. Everyone thanks for your help though!

Otros consejos

If you default locale is "nl_NL", so please change your faces-config.xml likes this.

    <application>
      <locale-config>
        <default-locale>nl_NL</default-locale>
        <supported-locale>en_US</supported-locale>
      </locale-config>
      <resource-bundle>
        <base-name>xxx.i18n.base_nl_NL</base-name>
        <var>msg</var>
      </resource-bundle>
   </application>

And also make sure the path of properties files is correct or not.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top