Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: JRuby 1.1.3
-
Fix Version/s: JRuby 1.6.4
-
Component/s: Java Integration
-
Labels:None
-
Environment:Windows XP
-
Number of attachments :
Description
# 1. JRuby source code
# jruby02.rb
require 'java'
include_class 'java.lang.String' do |package,name|
"J#{name}"
end
ResourceBundle = java.util.ResourceBundle
Locale = java.util.Locale
lang = JString.new 'pt'
country = JString.new 'BR'
cLocale = Locale.new lang, country
msg = ResourceBundle.get_bundle 'MessagesBundle', cLocale
puts msg.get_string 'greetings'
puts msg.get_string 'welcome'
# 2. The MessagesBundle_pt_BR.properties is # in the same folder as the jruby02.rb program # MessagesBundle_pt_BR.properties greetings = Ol\u00a0 welcome = Benvindo ao Brazil
# 3. Executed the program # jruby jruby02.rb # and the output is Ol┬á Benvindo ao Brazil # whereas the outputs should have been: Olá Benvindo ao Brazil
# The equivalent Java program works properly
import java.util.*;
public class InternationalizationEx
{
public static void main(String[] args)
{
String lang, country;
Locale cLocale;
ResourceBundle msg;
lang = new String("pt");
country = new String("BR");
cLocale = new Locale(lang, country);
msg = ResourceBundle.getBundle("MessagesBundle", cLocale);
System.out.println(msg.getString("greetings"));
System.out.println(msg.getString("welcome"));
}
}
Some encoding problem in JRuby?
If the message bundle resource file is in UTF-8 encoding then things display ok. The example uses \uxxxxx unicode format which does not work. We will have to figure out exactly what is happening, but it will not happen for 1.1.4. Bumping to 1.1.5.