Changeset 2536 in josm


Ignore:
Timestamp:
2009-11-28T18:05:37+01:00 (14 years ago)
Author:
Gubaer
Message:

fixed #3693: Preferences dialog take very long to show up
forgot to check in in r2535

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r2512 r2536  
    99import java.util.MissingResourceException;
    1010import java.util.Vector;
     11import java.util.logging.Logger;
    1112
    1213import org.openstreetmap.josm.gui.MainApplication;
     14import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1315import org.xnap.commons.i18n.I18nFactory;
    1416
     
    1921 */
    2022public class I18n {
     23    static private final Logger logger = Logger.getLogger(I18n.class.getName());
    2124
    2225    /* Base name for translation data. Used for detecting available translations */
     
    5962        if (i18n == null)
    6063            return n == 1 ? tr(text, objects) : tr(pluralText, objects);
    61         return filter(i18n.trn(text, pluralText, n, objects));
     64            return filter(i18n.trn(text, pluralText, n, objects));
    6265    }
    6366
     
    6568        if (i18n == null)
    6669            return n == 1 ? tr(text) : tr(pluralText);
    67         return filter(i18n.trn(text, pluralText, n));
     70            return filter(i18n.trn(text, pluralText, n));
    6871    }
    6972
     
    7174        if (i18n == null)
    7275            return n == 1 ? tr(text, objects) : tr(pluralText, objects);
    73         return i18n.trnc(ctx, text, pluralText, n, objects);
     76            return i18n.trnc(ctx, text, pluralText, n, objects);
    7477    }
    7578
     
    7780        if (i18n == null)
    7881            return n == 1 ? tr(text) : tr(pluralText);
    79         return i18n.trnc(ctx, text, pluralText, n);
     82            return i18n.trnc(ctx, text, pluralText, n);
    8083    }
    8184
     
    9295     * @return an array of locale objects.
    9396     */
    94     public static final Locale[] getAvailableTranslations() {
     97    public static final Locale[] getAvailableTranslations(ProgressMonitor monitor) {
     98        monitor.indeterminateSubTask(tr("Loading available locales..."));
    9599        Vector<Locale> v = new Vector<Locale>();
    96100        LinkedList<String>str = new LinkedList<String>();
    97101        Locale[] l = Locale.getAvailableLocales();
     102        monitor.subTask(tr("Checking locales..."));
     103        monitor.setTicksCount(l.length);
    98104        for (int i = 0; i < l.length; i++) {
     105            monitor.setCustomText(tr("Checking translation for locale ''{0}''", l[i].getDisplayName()));
    99106            String loc = l[i].toString();
    100107            String cn = TR_BASE + loc;
     
    105112            } catch (ClassNotFoundException e) {
    106113            }
     114            monitor.worked(1);
    107115        }
    108116        /* hmm, don't know why this is necessary */
    109117        try {
    110           if(!str.contains("nb"))
    111             v.add(new Locale("nb"));
     118            if(!str.contains("nb")) {
     119                v.add(new Locale("nb"));
     120            }
    112121        } catch (Exception e) {}
    113122        try {
    114           if(!str.contains("gl"))
    115             v.add(new Locale("gl"));
     123            if(!str.contains("gl")) {
     124                v.add(new Locale("gl"));
     125            }
    116126        } catch (Exception e) {}
    117127        l = new Locale[v.size()];
     
    145155            Locale l;
    146156            Locale d = Locale.getDefault();
    147             if (localeName.equals("he")) localeName = "iw_IL";
     157            if (localeName.equals("he")) {
     158                localeName = "iw_IL";
     159            }
    148160            int i = localeName.indexOf('_');
    149161            if (i > 0) {
     
    158170                if (!l.getLanguage().equals("en")) {
    159171                    System.out.println(tr("Unable to find translation for the locale {0}. Reverting to {1}.",
    160                     l.getDisplayName(), d.getDisplayName()));
     172                            l.getDisplayName(), d.getDisplayName()));
    161173                    Locale.setDefault(d);
    162174                } else {
Note: See TracChangeset for help on using the changeset viewer.