0
votes

I'm trying to internationalize my application and been searching a lot of tutorials on that. I always get stuck at this point, for no matter what configuration I do, none of them works.

Earlier I made a post onto a parsing exception. After solving this parser exception, now the application does not find bundles.

I arranged and registrated the Core bundle through faces-config.xml, as well as supported locales.

Even though I've searched through existing solutions but none of them seem to apply to my case.

So, where's the thing? Does it have to be at root folder? Is it a misconfig? A typo in my faces-config (don't think so, I redid it many times).

The config is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
    <application>
<!--        <message-bundle>messages_en_US</message-bundle> -->
<!--        <message-bundle>messages_es</message-bundle> -->
<!--        <message-bundle>messages_pt_BR</message-bundle> -->
        <locale-config>
            <default-locale>en_US</default-locale>
            <supported-locale>pt_BR</supported-locale>
            <supported-locale>es</supported-locale>
        </locale-config>

        <resource-bundle>
            <base-name>com.tfduque.fieldassist.interface</base-name>
            <var>msg</var>

        </resource-bundle>
    </application>

</faces-config>

Folder/package organization:

Folder Organization

Stack trace (FULL: https://pastebin.com/69iJrvuX):

Type Exception Report

Message Can't find bundle for base name com.tfduque.fieldassist.interface_es, locale pt_BR

Description The server encountered an unexpected condition that prevented it from fulfilling the request.

Exception

javax.servlet.ServletException: Can't find bundle for base name com.tfduque.fieldassist.interface_es, locale pt_BR

    javax.faces.webapp.FacesServlet.service(FacesServlet.java:659)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
1
"Even though I've searched through existing solutions but none of them seem to apply to my case." Which ones? How to Ask states to keep track of them and mention them in your Q. Otherwise you stand a chance this Q getting closed as a duplicate of one of the existing Q/A in stackoverflowKukeltje
Oh and this is really strange: com.tfduque.fieldassist.interface_es, locale pt_BR. interface_se should that not be 'interface' This effectively says it is looking for a file interface_es_pt_BR.properties which is indeed not there so the error is correct!Kukeltje

1 Answers

0
votes

Solved it by removing the full path to the file - just the name of the file seems to be enough:

<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://xmlns.jcp.org/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-facesconfig_2_2.xsd"
    version="2.2">
    <application>
<!--        <message-bundle>messages_en_US</message-bundle> -->
<!--        <message-bundle>messages_es</message-bundle> -->
<!--        <message-bundle>messages_pt_BR</message-bundle> -->
        <locale-config>
            <default-locale>en_US</default-locale>
            <supported-locale>pt_BR</supported-locale>
            <supported-locale>es</supported-locale>
        </locale-config>
<!--- Change the path ("com.tfduque.fieldassist.interface") to the filename ("interface") here -->    
        <resource-bundle>
            <base-name>interface</base-name>
            <var>msg</var>
        </resource-bundle>
    </application>

</faces-config>