[izpack-devel] Patch 5/6 patch against the current trunk

Ari Voutilainen ari.voutilainen at iki.fi
Wed Jan 10 21:44:07 CET 2007


Hi all,

I think taking language from OS is the best guess to offer 
readable texts to user. But this should be offered via language 
selection dialog. So situation is this:

langFromOS=yes && lang pack found => You have to make your 
installation with that language.

What about if I go to Germany and let's assume I can understand 
only Finnish. My friend have German as regional settings and 
langFromOS is yes and lang pack is found so installer gives me 
German and I would say something... well, at least I wouldn't 
thank developers. This is only one example where this feature 
isn't very good. We cannot be 100 % sure the _user_ wants to use 
that language which is set in a operating system.

If someone wants to offer only one language in the installation I 
think he/she should edit install XML file so that there will be 
only one language and that is used regardless of the regional 
settings. If there is multiple languages let's have a selection 
dialog with the language which is in the system (or english if 
not matched). So I vote for the original behaviour.

Regards,
Ari

Markus Schlegel wrote:
> Hi Julien
> 
> I've also made a patch against the current trunk for the
> "langFromOS"-Feature.
> 
> I can not understand why this feature is a problem for the izpack team,
> since it does not change current behavior. I can understand when the
> commandline switch (in my original post) was a problem for you. But I
> changed the implementation to use gui-modifiers. Also I have added the
> Documentation for it.
> 
> Please concern, that the Language Selection Dialog is the only part of
> your installer (except for the uninstaller) that can not be replaced by
> an other component and that cannot be omitted (if you want to support
> multiple installer languages).
> 
> Mabe there is someone on the users-list that would vote for this
> feature?
> 
> 
> Regards
> Markus
> 
> 
> 
> -----Original Message-----
> From: izpack-devel-bounces at lists.berlios.de
> [mailto:izpack-devel-bounces at lists.berlios.de] On Behalf Of Julien Ponge
> Sent: Tuesday, January 09, 2007 8:40 AM
> To: izpack-devel at lists.berlios.de
> Subject: Re: [izpack-devel] Next release will be 3.10.0
> 
> Hi Markus,
> 
> ...
> 
> About 5/6: I will have a look again to make my mind, but I am mildly in
> favour of this patch since there is no consensus about it.
> 
> ...
> 
> 
> ------------------------------------------------------------------------
> 
> Index: C:/deron/tools_/IzPack_TRUNK/src/lib/com/izforge/izpack/installer/GUIInstaller.java
> ===================================================================
> --- C:/deron/tools_/IzPack_TRUNK/src/lib/com/izforge/izpack/installer/GUIInstaller.java	(revision 1698)
> +++ C:/deron/tools_/IzPack_TRUNK/src/lib/com/izforge/izpack/installer/GUIInstaller.java	(working copy)
> @@ -1,5 +1,5 @@
>  /*
> - * $Id:$
> + * $Id$
>   * IzPack - Copyright 2001-2006 Julien Ponge, All Rights Reserved.
>   * 
>   * http://www.izforge.com/izpack/
> @@ -205,35 +205,57 @@
>          List availableLangPacks = getAvailableLangPacks();
>          int npacks = availableLangPacks.size();
>          if (npacks == 0) throw new Exception("no language pack available");
> -        String selectedPack;
> +        String selectedPack = null;
> + 
> +        //if modifier langFromOS is set to "yes", we may not display a dialog and take instead the language from the OS
> +        //The Langugedialog is displayed anyway, if the installer does not contain the language that the system runs with.
> +        if (useLanguageFromOS()){
> +            Locale l = Locale.getDefault();
> +            String osCode = l.getISO3Language().toLowerCase();
> +            if (availableLangPacks.contains(osCode)){
> +                selectedPack = osCode;
> +            }else{
> +                //now let's try the countrycode for backward compatibility. Think we should take langcode instead...
> +                osCode = l.getISO3Country().toLowerCase();
> +                if (availableLangPacks.contains(osCode)){
> +                    selectedPack = osCode;
> +                }else{
> +                    //noop, let the user choose the language...
> +                }
> +            }
> +        }
> +        
> +        if (selectedPack==null){
> +            // Dummy Frame
> +            JFrame frame = new JFrame();
> +            frame.setIconImage(new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png"))
> +            .getImage());
>  
> -        // Dummy Frame
> -        JFrame frame = new JFrame();
> -        frame.setIconImage(new ImageIcon(this.getClass().getResource("/img/JFrameIcon.png"))
> -                .getImage());
> +            Dimension frameSize = frame.getSize();
> +            Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
> +            frame.setLocation((screenSize.width - frameSize.width) / 2,
> +                    (screenSize.height - frameSize.height) / 2 - 10);
>  
> -        Dimension frameSize = frame.getSize();
> -        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
> -        frame.setLocation((screenSize.width - frameSize.width) / 2,
> -                (screenSize.height - frameSize.height) / 2 - 10);
> +            // We get the langpack name
> +            if (npacks != 1)
> +            {
> +                LanguageDialog picker = new LanguageDialog(frame, availableLangPacks.toArray());
> +                picker.setSelection(Locale.getDefault().getISO3Country().toLowerCase());
> +                picker.setModal(true);
> +                picker.toFront();
> +                //frame.setVisible(true);
> +                frame.setVisible(false);
> +                picker.setVisible(true);
>  
> -        // We get the langpack name
> -        if (npacks != 1)
> -        {
> -            LanguageDialog picker = new LanguageDialog(frame, availableLangPacks.toArray());
> -            picker.setSelection(Locale.getDefault().getISO3Country().toLowerCase());
> -            picker.setModal(true);
> -            picker.toFront();
> -            //frame.setVisible(true);
> -            frame.setVisible(false);
> -            picker.setVisible(true);
> -
> -            selectedPack = (String) picker.getSelection();
> -            if (selectedPack == null) throw new Exception("installation canceled");
> +                selectedPack = (String) picker.getSelection();
> +                if (selectedPack == null) throw new Exception("installation canceled");
> +            }
> +            else
> +            {
> +                selectedPack = (String) availableLangPacks.get(0);
> +            }
>          }
> -        else
> -            selectedPack = (String) availableLangPacks.get(0);
> -
> +        
>          // We add an xml data information
>          this.installdata.xmlData.setAttribute("langpack", selectedPack);
>  
> @@ -440,6 +462,20 @@
>          return (true);
>      }
>  
> +    /** 
> +     * Returns whether the Language Selection Dialog should be displayed even if the Installer contains a language matching the System's language.
> +     *
> +     * @return true if the gui-modifier "langFromOS" was set to "yes", false otherwise
> +     */
> +     protected boolean useLanguageFromOS()
> +     {
> +         if (installdata.guiPrefs.modifier.containsKey("langFromOS") 
> +                && "yes".equalsIgnoreCase((String) installdata.guiPrefs.modifier.get("langFromOS")))
> +             return (true);
> +         else
> +             return (false);
> +     }
> +
>      /**
>       * Returns the type in which the language should be displayed in the language selction dialog.
>       * Possible are "iso3", "native" and "usingDefault".
> 
> 
> ------------------------------------------------------------------------
> 
> Index: C:/deron/tools_/IzPack_TRUNK/src/doc-ng/XHTML/node5.html
> ===================================================================
> --- C:/deron/tools_/IzPack_TRUNK/src/doc-ng/XHTML/node5.html	(revision 1698)
> +++ C:/deron/tools_/IzPack_TRUNK/src/doc-ng/XHTML/node5.html	(working copy)
> @@ -273,6 +273,16 @@
>          language will be used if possible, else the notation of the default locale. Using "default"
>          will be presented the language in the notation of the default locale of the VM.
>        </li>
> +
> +      <li>
> +        <tt>langFromOS</tt>:<br />
> +        possible are "yes" or "no". Default (when ommitted) is "no". If it is set to "yes", 
> +        the installer first checks if the system runs with a language supported by the installer 
> +        and ommits the Lanugage Selection Dialog if so. If the System runs with a Language not 
> +        supported by the installer, the Language Selection Dialog is displayed neverthless. <br />
> +        Example: If you have an Installer supporting German and English with "langFromOS=yes", 
> +        the dialog will show up on french systems but not on german or english ones.
> +      </li>
>      </ul>
>  
>      <h2><a id="modifyingPanels" name="modifyingPanels">Modifying IzPack Panels</a></h2>
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> izpack-devel mailing list
> izpack-devel at lists.berlios.de
> https://lists.berlios.de/mailman/listinfo/izpack-devel




More information about the izpack-devel mailing list