[izpack-devel] Localizing InstallationGroupPanel

Loic lbndev at yahoo.fr
Wed Oct 11 11:52:01 CEST 2006


Hi,
 
Looks like the InstallationGroupPanel included in IzPack 3.9 is not localizable beyond the groups descriptions.
May I suggest the patch below to allow for some more localization (table colums headers, group names) ?
 
Thanks,
 
Loïc
 
--- InstallationGroupPanel-orig.java    2006-10-02 15:23:20.879057552 +0200
+++ InstallationGroupPanel-modif.java    2006-10-02 15:43:44.785995416 +0200
@@ -325,7 +325,8 @@
                 if (data == null)
                 {
                     String description = getGroupDescription(group);
-                    data = new GroupData(group, description);
+            String gname = getLocalizedGroupName(group);
+                    data = new GroupData(gname, description);
                     installGroups.put(group, data);
                 }
             }
@@ -399,9 +400,51 @@
         return description;
     }

+    /**
+     * Look for a key = InstallationGroupPanel.group.[group] entry:
+     * first using idata.langpack.getString(key+".html")
+     * next using idata.langpack.getString(key)
+     * next using idata.getVariable(key)
+     * lastly, defaulting to group 
+     * @param group - the installation group name
+     * @return the localized group name
+     */
+    protected String getLocalizedGroupName(String group)
+    {
+        String gname = null;
+        String key = "InstallationGroupPanel.group." + group;
+        if( idata.langpack != null )
+        {
+            String htmlKey = key+".html";
+            String html = idata.langpack.getString(htmlKey);
+            // This will equal the key if there is no entry
+            if( htmlKey.equalsIgnoreCase(html) )
+                gname = idata.langpack.getString(key);
+            else
+                gname = html;
+        }
+        if (gname == null)
+            gname = idata.getVariable(key);
+        if (gname == null)
+            gname = group;
+        try
+        {
+            gname = URLDecoder.decode(description, "UTF-8");
+        }
+        catch (UnsupportedEncodingException e)
+        {
+            emitWarning("Failed to convert localized group name", e.getMessage());
+        }
+
+        return gname;
+    }
+
     protected TableModel getModel(HashMap groupData)
     {
-        String[] columns = { "Selected", "InstallType", "Size"};
+        String[] columns = { idata.langpack.getString("InstallationGroupPanel.header.selection"),
+                 idata.langpack.getString("InstallationGroupPanel.header.description"),
+                 idata.langpack.getString("InstallationGroupPanel.header.size"};
+
          DefaultTableModel model = new DefaultTableModel (columns, 0)
          {
             public boolean isCellEditable (int row, int column)


	

	
		
___________________________________________________________________________ 
Découvrez une nouvelle façon d'obtenir des réponses à toutes vos questions ! 
Demandez à ceux qui savent sur Yahoo! Questions/Réponses
http://fr.answers.yahoo.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.berlios.de/pipermail/izpack-devel/attachments/20061011/b1cac0f0/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: InstallationGroupPanel.diff
Url: https://lists.berlios.de/pipermail/izpack-devel/attachments/20061011/b1cac0f0/attachment.ksh 


More information about the izpack-devel mailing list