Here we go..
This is the directory layout I have:
I will only include the related files, start with faces-config.xml
So when I navigate to chrome://settings/languages and put Turkish in the first place in the list seen there in the settings of Chrome and open the page, I will see the values from msg_tr.properties file. If English is on top, then English.. Great!!!
This is the directory layout I have:
I will only include the related files, start with faces-config.xml
<?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 wide configurations --> <application> <!-- Resolving resource bundles --> <resource-bundle> <base-name>biz.tugay.jsfone.msg</base-name> <var>msgs</var> </resource-bundle> <!-- Localisation configuration --> <locale-config> <default-locale>en</default-locale> <supported-locale>tr</supported-locale> </locale-config> </application> </faces-config>and lets show msg.properties and msg_tr.properties
title=A Sample JSF Application example helloWorld=Hello world!
title=JSF Uygulama \u00D6rne\u011Fi helloWorld=Merhaba D\u00FCnya!
And finally index.xhtml
<!DOCTYPE html> <html xmlns:f="http://xmlns.jcp.org/jsf/core" xmlns:h="http://xmlns.jcp.org/jsf/html"> <h:head> <title><h:outputText value="#{msgs.title}"/></title> <h:outputStylesheet name="css/default.css"/> </h:head> <f:view locale="#{request.locale}"/> <h:body> <div> <h:outputText value="#{msgs.helloWorld}"/> </div> </h:body> </html>