Localizing a JSF 1.2 Application with UTF-8 Resources

(WARNING: this is my first Java application coming from .NET, so don't bash me if I write too much garbage)

I am developing a simple JSF 1.2 web application that should support Russian, Chinese and other languages ​​outside of ISO 8859-1, which is automatically used in Properties.load().

Is there a way to use properties loaded from XML files using Properties.loadFromXml()inside JSF without writing too much code?

I know that there are alternative ways to do this (write your own bootloader, avoiding characters ...), but I would really like to find a simple solution, and I do not see it in all the forums I'm checking.

Thank you in advance for your help.

+3
source share
1 answer

I think the most widely used approach is to encode your files .propertiesusing unicode escape sequences. This can be easily done using the AnyEdit plugin for Eclipse.

The problem is what the ResourceBundleconstructor uses Properties(inputStream), not Properties(reader).

You can use your own component LoadBundleinstead f:loadBundleto overcome this, but you will have to:

  • expand original
  • define it as a custom component (facelets and / or jsp)
  • define a new implementation ResourceBundle
  • create an instance using new InputStreamReader(classloader.getResourceAsStream(..))
+3
source

Source: https://habr.com/ru/post/1743951/