1 Reply Latest reply: Jan 19, 2010 2:58 AM by 843810 RSS

    How to use the ICU4J UResourceBundle class

    843810

      Hi,

      I am unable to make out the right way of using the ICU4J UResourceBundle class for loading binary resource bundle files created using the genrb utility.



      I have two text files with the following content:
      root.res:
      root { definition1 { "hi" }
      
      definition2 { "hello" }}
      es_ES.res:

      es_ES { definition1 { "G_hi" }
      
      definition2 { "G_hello" }} 
      I have created a package containing two resource bundles using the genrb utility as follows [from the path D:/CA/ICU/bundles].
      D:/CA/ICU/icu/bin/genrb -d myapp root.txt es_ES.txt 
      This has created 2 .res files - root.res and es_ES.res - in the path D:\CA\ICU\bundles\myapp.



      I am then trying to load the resource bundle using the below line.

      UResourceBundle rb = UResourceBundle.getBundleInstance("D:\\CA\\ICU\\bundles\\myapp", new Locale("es", "ES")); 
      But i am getting the below error on running the code.


      java.util.MissingResourceException: Could not find the bundle D:\CA\ICU\bundles\myapp_es_ES
      at com.ibm.icu.impl.ResourceBundleWrapper.getBundleInstance(ResourceBundleWrapper.java:107)
      at com.ibm.icu.util.UResourceBundle.instantiateBundle(UResourceBundle.java:544)
      at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:137)
      at com.ibm.icu.util.UResourceBundle.getBundleInstance(UResourceBundle.java:197)
      at com.infy.i18n.URBTest.main(URBTest.java:25)



      I tried to use various options but it did not help. I will be very grateful if someone can help me out in how exactly i will be able to load the es_ES.res and root.res files and how i invoke the strings for definition1 and definition2 once i get a reference to the UResourceBundle object.

      Thanks in advance.