Changeset 112 in josm


Ignore:
Timestamp:
Jul 17, 2006 12:18:11 AM (7 years ago)
Author:
imi
Message:

fixed exception for missing locale

File:
1 edited

Legend:

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

    r111 r112  
    11package org.openstreetmap.josm.tools; 
     2 
     3import java.text.MessageFormat; 
     4import java.util.Locale; 
     5import java.util.MissingResourceException; 
    26 
    37import org.openstreetmap.josm.Main; 
     
    1014 */ 
    1115public class I18n { 
    12         private static org.xnap.commons.i18n.I18n i18n = I18nFactory.getI18n(Main.class); 
     16        private static org.xnap.commons.i18n.I18n i18n; 
     17         
     18        static { 
     19                try { 
     20                i18n = I18nFactory.getI18n(Main.class); 
     21        } catch (MissingResourceException e) { 
     22                System.out.println("Locale '"+Locale.getDefault().getLanguage()+"' not found. Using default."); 
     23        } 
     24        } 
    1325         
    1426        public static String tr(String text, Object... objects) { 
     27                if (i18n == null) 
     28                        return MessageFormat.format(text, objects); 
    1529                return i18n.tr(text, objects); 
    1630        } 
    1731 
    1832        public static String tr(String text) { 
     33                if (i18n == null) 
     34                        return text; 
    1935                return i18n.tr(text); 
    2036        } 
    2137 
    2238        public static String trn(String text, String pluralText, long n, Object... objects) { 
     39                if (i18n == null) 
     40                        return n == 1 ? tr(text, objects) : tr(pluralText, objects); 
    2341                return i18n.trn(text, pluralText, n, objects); 
    2442        } 
    2543 
    2644        public static String trn(String text, String pluralText, long n) { 
     45                if (i18n == null) 
     46                        return n == 1 ? tr(text) : tr(pluralText); 
    2747                return i18n.trn(text, pluralText, n); 
    2848        } 
Note: See TracChangeset for help on using the changeset viewer.