I'm using Deltaspike Core for retrieving and showing messages in different languages. I'm using the default MessageContext implementation but with a custom MessageResolver. It worked fine until I tried to use a properties' file codified as UTF-8.
THe UTF-8 file is locale_source.properties with a message:
messageKey=Localización no disponible.
And my code looks like this:
public class MessageBuilder {
@Inject
private MessageContext messageContext;
@PostConstruct
public void init() {
messageContext.messageSource(LOCALE_SOURCE);
}
@Override
public Message create(String key) {
Message m = messageContext
.clone()
.localeResolver(new MyOwnLocaleResolver())
.message()
.template("{" + key + "}");
...
System.out.println(messageBuilder.create(messageKey).toString());
It retrieves the message but with a codification error:
Localización no disponible.
As you see it changes the ó for ó. Is there something to specified the codification of the properties file? What else can I do to solve this issue?
Thanks.
I saw this that answer my question: How to use UTF-8 in resource properties with ResourceBundle
So the solution is basically keep the properties files in Latin1 and use unicode codes \uXXXX to represent those symbols that are not covered by that encoding.