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