jaxp/src/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_de.java
changeset 16953 a44e04deb948
parent 12457 c348e06f0e82
child 20582 594878286b70
equal deleted inserted replaced
16416:bcebd3fdefc9 16953:a44e04deb948
  1446   /** I don't think this is used any more.
  1446   /** I don't think this is used any more.
  1447    * @deprecated  */
  1447    * @deprecated  */
  1448   public static final String QUERY_HEADER = "PATTERN ";
  1448   public static final String QUERY_HEADER = "PATTERN ";
  1449 
  1449 
  1450 
  1450 
  1451   /**
       
  1452    *   Return a named ResourceBundle for a particular locale.  This method mimics the behavior
       
  1453    *   of ResourceBundle.getBundle().
       
  1454    *
       
  1455    *   @param className the name of the class that implements the resource bundle.
       
  1456    *   @return the ResourceBundle
       
  1457    *   @throws MissingResourceException
       
  1458    */
       
  1459   public static final XSLTErrorResources loadResourceBundle(String className)
       
  1460           throws MissingResourceException
       
  1461   {
       
  1462 
       
  1463     Locale locale = Locale.getDefault();
       
  1464     String suffix = getResourceSuffix(locale);
       
  1465 
       
  1466     try
       
  1467     {
       
  1468 
       
  1469       // first try with the given locale
       
  1470       return (XSLTErrorResources) ResourceBundle.getBundle(className
       
  1471               + suffix, locale);
       
  1472     }
  1451     }
  1473     catch (MissingResourceException e)
       
  1474     {
       
  1475       try  // try to fall back to en_US if we can't load
       
  1476       {
       
  1477 
       
  1478         // Since we can't find the localized property file,
       
  1479         // fall back to en_US.
       
  1480         return (XSLTErrorResources) ResourceBundle.getBundle(className,
       
  1481                 new Locale("en", "US"));
       
  1482       }
       
  1483       catch (MissingResourceException e2)
       
  1484       {
       
  1485 
       
  1486         // Now we are really in trouble.
       
  1487         // very bad, definitely very bad...not going to get very far
       
  1488         throw new MissingResourceException(
       
  1489           "Could not load any resource bundles.", className, "");
       
  1490       }
       
  1491     }
       
  1492   }
       
  1493 
       
  1494   /**
       
  1495    * Return the resource file suffic for the indicated locale
       
  1496    * For most locales, this will be based the language code.  However
       
  1497    * for Chinese, we do distinguish between Taiwan and PRC
       
  1498    *
       
  1499    * @param locale the locale
       
  1500    * @return an String suffix which canbe appended to a resource name
       
  1501    */
       
  1502   private static final String getResourceSuffix(Locale locale)
       
  1503   {
       
  1504 
       
  1505     String suffix = "_" + locale.getLanguage();
       
  1506     String country = locale.getCountry();
       
  1507 
       
  1508     if (country.equals("TW"))
       
  1509       suffix += "_" + country;
       
  1510 
       
  1511     return suffix;
       
  1512   }
       
  1513 
       
  1514 
       
  1515 }