Revision: 5621
          http://sourceforge.net/p/jump-pilot/code/5621
Author:   edso
Date:     2017-12-10 15:49:38 +0000 (Sun, 10 Dec 2017)
Log Message:
-----------
bugfix: KML extension couldn't find it's strings as OJ's I18N didn't use the 
proper resource bundle

Modified Paths:
--------------
    core/trunk/src/com/vividsolutions/jump/I18N.java

Modified: core/trunk/src/com/vividsolutions/jump/I18N.java
===================================================================
--- core/trunk/src/com/vividsolutions/jump/I18N.java    2017-12-10 15:47:33 UTC 
(rev 5620)
+++ core/trunk/src/com/vividsolutions/jump/I18N.java    2017-12-10 15:49:38 UTC 
(rev 5621)
@@ -193,9 +193,9 @@
    */
   @Deprecated
   public String getText(final String key) {
-      return getMessage(key);
+    return getMessage(this, key);
   }
-  
+
   /**
    * Convenience wrapper for {@link #getMessage(Object, String, Object...)}
    * 
@@ -227,19 +227,25 @@
    * categoryPrefixOrPath = new File("language/wfs/messages") then
    * resourcebundle is looked up as /language/wfs/messages[_locale].properties
    * 
-   * @param categoryPrefixOrPath
+   * @param categoryPrefixOrPathOrI18N
    *          The category.
    * @return The instance.
    */
-  private static I18N getInstance(final Object categoryPrefixOrPath) {
-    I18N instance = instances.get(categoryPrefixOrPath);
+  private static I18N getInstance(final Object categoryPrefixOrPathOrI18N) {
+    // needed for legacy methods like this.getText(String)
+    if (categoryPrefixOrPathOrI18N instanceof I18N)
+      return (I18N) categoryPrefixOrPathOrI18N;
+    
+    I18N instance = instances.get(categoryPrefixOrPathOrI18N);
     if (instance == null) {
-      if (categoryPrefixOrPath instanceof File)
-        instance = new I18N((File) categoryPrefixOrPath);
-      else
-        instance = new I18N(categoryPrefixOrPath.toString());
-      instances.put(categoryPrefixOrPath, instance);
+      if (categoryPrefixOrPathOrI18N instanceof File) {
+        instance = new I18N((File) categoryPrefixOrPathOrI18N);
+      } else {
+        instance = new I18N(categoryPrefixOrPathOrI18N.toString());
+      }
+      instances.put(categoryPrefixOrPathOrI18N, instance);
     }
+
     return instance;
   }
 
@@ -389,7 +395,10 @@
    * 
    * Examples:
    * 
-   * categoryPrefixOrPath = new String("org.openjump.myplugin") then
+   * categoryPrefixOrPathOrI18N instanceof I18N
+   * legacy option, mainly for the instance method this.getText(String)
+   * 
+   * categoryPrefixOrPathOrI18N = new String("org.openjump.myplugin") then
    * resourcebundle is looked up as
    * /org/openjump/myplugin/language/jump[_locale].properties
    * 
@@ -396,8 +405,8 @@
    * categoryPrefixOrPath = new File("language/wfs/messages") then
    * resourcebundle is looked up as /language/wfs/messages[_locale].properties
    * 
-   * @param categoryPrefixOrPath
-   *          The category.
+   * @param categoryPrefixOrPathOrI18n
+   *          The categoryPrefix or path object or i18n object.
    * @param label
    *          Label with argument insertion : {0}
    * @param objects values of parameters contained in the key
@@ -404,12 +413,12 @@
    * 
    * @return i18n label
    */
-  private static String getMessage(final Object categoryPrefixOrPath,
+  private static String getMessage(final Object categoryPrefixOrPathOrI18n,
       final String label, final Object... objects) {
-    I18N i18n = categoryPrefixOrPath != null ? 
getInstance(categoryPrefixOrPath)
+    I18N i18n = categoryPrefixOrPathOrI18n != null ? 
getInstance(categoryPrefixOrPathOrI18n)
         : getInstance();
-    if (label.contains("ShortenLinePlugIn"))
-        System.out.println(label);
+//    if (label.contains("ShortenLinePlugIn"))
+//        System.out.println(label);
     try {
       // IMPORTANT: trailing spaces break the Malayalam translation, 
       //            so we trim here, just to make sure


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to