Package java.util

Examples of java.util.ResourceBundle$CacheKey


    private static ResourceBundle b;

    /** Get bundle from .properties files in the package path */
    private static ResourceBundle getBundle() {
        ResourceBundle bundle = null;

        try {
            bundle = ResourceBundle.getBundle("org.libtiff.jai.codec.xtiff", Locale.US);
            return bundle;
        } catch (Exception e) {
View Full Code Here


   * @param arg2 Can be null
   * @return The localized text depending on the browser language
   */
  private String getText(HttpServletRequest request, String key, String defaultVal, String arg1, String arg2) {
      Locale locale = getLocale(request);
      ResourceBundle bundle =
           ResourceBundle.getBundle("ajaxServlet", locale);
      String bundleValue = bundle.getString(key);
      if (bundleValue == null) {
        if (arg1 != null)
          defaultVal = ReplaceVariable.replaceAll(defaultVal, "{0}", arg1);
        if (arg2 != null)
          defaultVal = ReplaceVariable.replaceAll(defaultVal, "{1}", arg2);
View Full Code Here

    public String getText( String key,
                           Locale locale )
    {
        try
        {
            ResourceBundle bundle = ResourceBundle.getBundle( Constants.SYSTEM_BUNDLE_NAME );
            return bundle.getString( key );
        }
        catch ( MissingResourceException m )
        {
            return "???" + key + "???";
        }
View Full Code Here

    while (st.hasMoreTokens()) {
      String code = st.nextToken();
      // get the locales and associated resources one by one
      Locale l = new Locale(code);
      CustomizedLocale.set(l);
      ResourceBundle r = ResourceFinder.get(Installer.class);
      // put default locale first, all other after, in order
      if ((defaultLocale.getVariant().equals("") && defaultLocale.getCountry().equals("") && defaultLocale.getLanguage().equals(l.getLanguage()))
      || (defaultLocale.getVariant().equals("") && (!defaultLocale.getCountry().equals("")) && defaultLocale.getLanguage().equals(l.getLanguage()) && defaultLocale.getCountry().equals(l.getCountry()))
      || defaultLocale.equals(l)) {
        locList.add(0,l);
        resList.add(0,r);
      } else {
        locList.add(l);
        resList.add(r);
      }
      numLocales++;
    }
    // reset to default locale, just in case
    CustomizedLocale.set(defaultLocale);

    ButtonGroup bg = new ButtonGroup();
    Box vbox = Box.createVerticalBox();
    vbox.add(Box.createVerticalGlue());
    // Add UI elements in localisation order
    for (int i=0; i<numLocales; ++i) {
      final ResourceBundle res = (ResourceBundle)resList.get(i);
      final int counter = i;
      // first one is true as this is the default locale
      ActionRadioButton arb = new ActionRadioButton(res.getString("chooseThisLanguage"),i==0) {
        public void stateChanged(ChangeEvent e) {
          if (isSelected()) {
            Installer.resources = res;
            Locale l = (Locale)locList.get(counter);
            CustomizedLocale.set(l);
View Full Code Here

    }
    StringBuffer sb = new StringBuffer(c.getName());
    sb.insert(sb.lastIndexOf("."),".help");
    sb.append("Help");
    try {
      ResourceBundle rb = ResourceBundle.getBundle(sb.toString(),CustomizedLocale.get());
      return rb;
    } catch (Exception e) {
      System.err.println("Can't load help resource : "+ sb.toString());
      System.exit(0);
    }
View Full Code Here

        List<ResourceBundle> bundleList = bundles == null ? null : bundles.get();
        if (bundleList == null) {
            bundleList = List.nil();
            for (String bundleName : bundleNames) {
                try {
                    ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
                    bundleList = bundleList.prepend(rb);
                } catch (MissingResourceException e) {
                    throw new InternalError("Cannot find javac resource bundle for locale " + locale);
                }
            }
View Full Code Here

    private static String getLocalizedString(List<ResourceBundle> bundles,
                                             String key,
                                             Object... args) {
       String msg = null;
        for (List<ResourceBundle> l = bundles; l.nonEmpty() && msg == null; l = l.tail) {
            ResourceBundle rb = l.head;
            try {
                msg = rb.getString(key);
            }
            catch (MissingResourceException e) {
                // ignore, try other bundles in list
            }
        }
View Full Code Here

     *
     * @param logger the Logger
     * @param message the message to be localized
     */
    private static String localize(Logger logger, String message) {
        ResourceBundle bundle = logger.getResourceBundle();
        return bundle != null ? bundle.getString(message) : message;
    }
View Full Code Here

                     "subbed in 1 only",
                     msg.toString());
    }

    public void testMessageWithExplicitBundle() throws Exception {
        ResourceBundle bundle = BundleUtils.getBundle(getClass());
        Message msg = new Message("SUB2_EXC", bundle, new Object[] {3, 4});
        assertSame("unexpected resource bundle", bundle, msg.bundle);
        assertEquals("unexpected message string",
                     "subbed in 4 & 3",
                     msg.toString());
View Full Code Here

                     "org.objectweb.celtix.common.i18n.Messages",
                     BundleUtils.getBundleName(getClass()));
    }

    public void testGetBundle() throws Exception {
        ResourceBundle bundle = BundleUtils.getBundle(getClass());
        assertNotNull("expected resource bundle", bundle);
        assertEquals("unexpected resource",
                     "localized message",
                     bundle.getString("I18N_MSG"));
                    
    }
View Full Code Here

TOP

Related Classes of java.util.ResourceBundle$CacheKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.