[jsword-svn] r1879 - trunk/common/src/main/java/org/crosswire/common/util

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Wed Jun 18 17:30:25 MST 2008


Author: dmsmith
Date: 2008-06-18 17:30:25 -0700 (Wed, 18 Jun 2008)
New Revision: 1879

Modified:
   trunk/common/src/main/java/org/crosswire/common/util/Translations.java
Log:
Fixed a first run locale problem.

Modified: trunk/common/src/main/java/org/crosswire/common/util/Translations.java
===================================================================
--- trunk/common/src/main/java/org/crosswire/common/util/Translations.java	2008-06-18 21:41:42 UTC (rev 1878)
+++ trunk/common/src/main/java/org/crosswire/common/util/Translations.java	2008-06-19 00:30:25 UTC (rev 1879)
@@ -47,8 +47,33 @@
     {
         try
         {
+            loadSupportedTranslations();
+            Locale defaultLocale = Locale.getDefault();
             Properties props = ResourceUtil.getProperties(getClass());
-            translation = props.getProperty(TRANSLATION_KEY, DEFAULT_TRANSLATION);
+            translation = props.getProperty(TRANSLATION_KEY);
+            if (translation == null)
+            {
+                for (int i = 0; i < translations.length; i++)
+                {
+                    Locale supportedLocale = new Locale(translations[i]);
+                    if (supportedLocale.getLanguage().equals(defaultLocale.getLanguage()) &&
+                                    supportedLocale.getCountry().equals(defaultLocale.getCountry()))
+                    {
+                        translation = translations[i];
+                        return;
+                    }
+                }
+                for (int i = 0; i < translations.length; i++)
+                {
+                    Locale supportedLocale = new Locale(translations[i]);
+                    if (supportedLocale.getLanguage().equals(defaultLocale.getLanguage()))
+                    {
+                        translation = translations[i];
+                        return;
+                    }
+                }
+                translation = DEFAULT_TRANSLATION;
+            }
         }
         catch (IOException e)
         {
@@ -240,7 +265,7 @@
     /**
      * The translation that BibleDesktop should use.
      */
-    private String translation = DEFAULT_TRANSLATION;
+    private String translation;
 
     /**
      * List of available translations.




More information about the jsword-svn mailing list