I understand with JSF, work with locales.

Created 3 properties-files: messages.properties, messages_en_US.properties, messages_ru_RU.properties.

UTF-8 encoding.

Pointed in faces-config.xml:

<application> <resource-bundle> <base-name>nsl.messages</base-name> <var>msg</var> </resource-bundle> <locale-config> <default-locale>ru</default-locale> <supported-locale>ru</supported-locale> <supported-locale>en</supported-locale> </locale-config> </application> 

The page in the browser displays:

enter image description here

Changing the encoding through the browser settings does not give any result, the text does not change at all. I tried in IDE to experiment with different encodings of properties - there is no result either.

I use Intellij idea, launched on glassfish 4, tomcat, jetty.

Maybe someone had the same story? What setting I did not take into account?

    4 answers 4

    If the code is in Intellij Idea, then change the listing encoding.

      The reason turned out to be Intellij Idea 14.1.3. Everything works great in Eclipse and Idea version 13.

        1. We need to see what encoding the page itself uses.
        2. And what is written in the properties file? It would be nice to make a debug print to find out exactly what is being read from the resource.
        • 1. The index.xhtml spelled <? Xml version = "1.0" encoding = "UTF-8"?>. The browser is UTF-8. <br/> 2. In properties: title=ЭлСктронная Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΠ° welcome_title=Π”ΠΎΠ±Ρ€ΠΎ ΠΏΠΎΠΆΠ°Π»ΠΎΠ²Π°Ρ‚ΡŒ Π² ΡΠ»Π΅ΠΊΡ‚Ρ€ΠΎΠ½Π½ΡƒΡŽ Π±ΠΈΠ±Π»ΠΈΠΎΡ‚Π΅ΠΊΡƒ enter_name=Π’Π²Π΅Π΄ΠΈΡ‚Π΅ вашС имя name=Имя: - Sergio
        • Is that the way it is written? Or is it still converted to unicode codes? - AntonSaburov
        • Initially it is written in .properties: \ u0418 \ u043C \ u044F, etc. In Idea there is a transparent native-to-ascii conversion setting, I turned it on, everything is therefore displayed in Russian. - Sergio

        You can read more about Transparent native-to-ascii conversion here.