Ticket #1683: 0001-I18n-Don-t-abort-if-translation-resource-bundle-is.patch

File 0001-I18n-Don-t-abort-if-translation-resource-bundle-is.patch, 1.6 KB (added by mcdmx@…, 15 years ago)
  • src/org/openstreetmap/josm/gui/MainApplication.java

    From 7738dda49566de9b5db10fb253b7d0a5f34ed856 Mon Sep 17 00:00:00 2001
    From: Michel Marti <mcdmx@users.sf.net>
    Date: Wed, 29 Oct 2008 12:41:11 +0100
    Subject: [PATCH] I18n: Don't abort if translation resource bundle is missing.
    
    Instead of aborting with a MissingResourceException, we should fall back
    to a default resource bundle that returns the passed text.
    ---
     .../openstreetmap/josm/gui/MainApplication.java    |    8 +++++++-
     1 files changed, 7 insertions(+), 1 deletions(-)
    
    diff --git a/src/org/openstreetmap/josm/gui/MainApplication.java b/src/org/openstreetmap/josm/gui/MainApplication.java
    index d2e53c6..da88927 100644
    a b import java.util.LinkedList; 
    2020import java.util.List;
    2121import java.util.Locale;
    2222import java.util.Map;
     23import java.util.MissingResourceException;
    2324
    2425import javax.swing.JFrame;
    2526import javax.swing.JOptionPane;
    public class MainApplication extends Main { 
    178179            Locale.setDefault(new Locale(localeName));
    179180        }
    180181       
    181         i18n = I18nFactory.getI18n(MainApplication.class);
     182        try {
     183            i18n = I18nFactory.getI18n(MainApplication.class);
     184        } catch (MissingResourceException mre) {
     185            System.err.println("Notice: No translation available for your locale ("+Locale.getDefault()+").");
     186            i18n = I18nFactory.getI18n(MainApplication.class, Locale.getDefault(), I18nFactory.FALLBACK);
     187        }
    182188               
    183189                SplashScreen splash = new SplashScreen(Main.pref.getBoolean("draw.splashscreen", true));
    184190