[Schmitzm-commits] r2420 - trunk/schmitzm-core/src/main/java/de/schmitzm/swing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 15 17:40:50 CET 2016


Author: mojays
Date: 2016-02-15 17:40:50 +0100 (Mon, 15 Feb 2016)
New Revision: 2420

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ResourceProviderManagerFrame.java
Log:
ResourceProviderManagerFrame: hide "empty" language information

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ResourceProviderManagerFrame.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ResourceProviderManagerFrame.java	2016-02-15 16:02:44 UTC (rev 2419)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ResourceProviderManagerFrame.java	2016-02-15 16:40:50 UTC (rev 2420)
@@ -54,6 +54,8 @@
 import javax.swing.JTable;
 import javax.swing.table.AbstractTableModel;
 
+import org.apache.commons.lang.StringUtils;
+
 import de.schmitzm.lang.LocaleComparator;
 import de.schmitzm.lang.ResourceProvider;
 import de.schmitzm.swing.input.InputOption;
@@ -451,9 +453,22 @@
     private String getLanguageString(Set<Locale> locales) {
       String langStr = "";
       for (Locale l : locales) {
+        String langDesc = l.getDisplayLanguage();
+        String langAbbr = l.toString();
+        // Skip language if description and abbreviation are both empty
+        if ( StringUtils.isBlank(langAbbr) && StringUtils.isBlank(langDesc) )
+          continue;
+        // If description is empty, show only abbreviation
+        if ( StringUtils.isBlank(langDesc) ) {
+          langDesc = langAbbr;
+          langAbbr = "";
+        }
+        // Concat languages
         if ( !langStr.equals("") )
           langStr += ", ";
-        langStr += l.getDisplayLanguage() + " (" + l.toString() + ")";
+        langStr += langDesc;
+        if ( !StringUtils.isBlank(langAbbr) )
+          langStr += " (" + langAbbr + ")";
       }
       return langStr;
     }



More information about the Schmitzm-commits mailing list