Hi Chris,

> what issue is exactly addressed by this change? Isn't it early enough to 
> do it in FreeMind line 249?

I address the issue reported in [ freemind-Bugs-1967208 ] Localization 
of shortcuts in the menus doesn't work

http://sourceforge.net/tracker/?func=detail&atid=107118&aid=1967208&group_id=7118

In order to solve it Locale.setDefault should be called before any awt 
dependent class (e.g. FreeMind which is a JFrame) is initialized. (As a 
positive side-effect you do not have to supply names of buttons for the 
standard dialogs e.g. for the yes-no-cancel dialog appearing on closing 
of freemind and mnemonics for standard dialogs are also set 
automatically, and I have already changed ControllerAdapter in this sense).

I am afraid that the refactoring you propose is not really helpful. The 
actual problem is that FreeMind (which is a JFrame) contains a lot of 
application initialization code which generally should be done from the 
FreeMindStarter. I do not think that any refactorings should be done 
before the 0.9.0 is released. But if you feel very safe you still could 
do it yourself.

Dimitry

> Observe, that you doubled the code to read the preferences and that they 
> are read twice, now.
> And, if this is really necessary, then I would propose to pass the read 
> prefs to FreeMind.main such
> that it is not read again.
> 
> Regards, Chris
> 
> Update of /cvsroot/freemind/freemind/freemind/main
> In directory sc8-pr-cvs17.sourceforge.net:/tmp/cvs-serv32635
> 
> Modified Files:
>       Tag: fm_060405_integration
>       FreeMindStarter.java 
> Log Message:
> Call Locale.setDefault(Locale) before awt.Toolkit is initialised 
> for displaying of accelerator keys in selected language.
> 
> This solution is not perfect but just better than nothing.
> 
> Index: FreeMindStarter.java
> ===================================================================
> RCS file: 
> /cvsroot/freemind/freemind/freemind/main/Attic/FreeMindStarter.java,v
> retrieving revision 1.1.2.1
> retrieving revision 1.1.2.2
> diff -C2 -d -r1.1.2.1 -r1.1.2.2
> *** FreeMindStarter.java      7 Jul 2006 04:26:26 -0000       1.1.2.1
> --- FreeMindStarter.java      26 May 2008 20:50:25 -0000      1.1.2.2
> ***************
> *** 23,26 ****
> --- 23,33 ----
>   package freemind.main;
>   
> + import java.io.File;
> + import java.io.FileInputStream;
> + import java.io.InputStream;
> + import java.net.URL;
> + import java.util.Locale;
> + import java.util.Properties;
> + 
>   import javax.swing.JOptionPane;
>   
> ***************
> *** 51,55 ****
> --- 58,104 ----
>               // First check version of Java
>               FreeMindStarter.checkJavaVersion();
> +             setDefaultLocale();
>               FreeMind.main(args);
>       }
> + 
> +     /**
> +      */
> +     private static void setDefaultLocale() {
> +             String propsLoc = "freemind.properties";
> +             URL defaultPropsURL = ClassLoader.getSystemResource(propsLoc);
> +             Properties props = new Properties();
> +             try {
> +                     InputStream in = null;
> +                     in = defaultPropsURL.openStream();
> +                     props.load(in);
> +                     in.close();
> +                     String freemindDirectory = 
> System.getProperty("user.home") + File.separator +  
> props.getProperty("properties_folder");
> +                     File userPropertiesFolder = new File(freemindDirectory);
> +                     File autoPropertiesFile = new 
> File(userPropertiesFolder, props.getProperty("autoproperties"));
> +                     in = new FileInputStream(autoPropertiesFile);
> +                     Properties auto = new Properties(props);
> +                     auto.load(in);
> +                     in.close();
> +                     String lang = 
> auto.getProperty(FreeMindCommon.RESOURCE_LANGUAGE);
> +                     if(lang == null){
> +                             return;
> +                     }
> +                     Locale localeDef = null;
> +                     switch(lang.length()){
> +                     case 2:
> +                             localeDef = new Locale(lang);
> +                             break;
> +                     case 5:
> +                             localeDef =new Locale(lang.substring(0, 1), 
> lang.substring(3, 4));
> +                             break;
> +                     default:
> +                             return; 
> +                     }
> +                     Locale.setDefault(localeDef);
> +             } catch (Exception ex) {
> +                     ex.printStackTrace();
> +                     System.err
> +                                     .println("Panic! Error while loading 
> default properties.");
> +             }
> +             }
>   }
> 
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> Freemind-cvslog mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/freemind-cvslog
> 
> 
> ------------------------------------------------------------------------
> 
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Freemind-developer mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/freemind-developer


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Freemind-developer mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemind-developer

Reply via email to