Examples of ResourceBundle


Examples of java.util.ResourceBundle

    }

    try
    {
      final ResourceBundleFactory resourceBundleFactory = runtime.getResourceBundleFactory();
      final ResourceBundle bundle = resourceBundleFactory.getResourceBundle(resourceId);
      if (bundle != null)
      {
        return bundle.getString(resourceKey);
      }
    }
    catch (Exception e)
    {
      // on errors return null.
View Full Code Here

Examples of java.util.ResourceBundle

     *
     * @return null if the data can't be found -- defaulting happens
     *         above here.
     */
    protected String getInternal(Class requestor, String field, int type) {
        ResourceBundle bundle = null;
        Package pckg = requestor.getPackage();

        String bString = (pckg == null ? ""
                : (requestor.getPackage().getName() + "."))
                + ResourceFileNamePrefix;

        try {
            bundle = ResourceBundle.getBundle(bString, loc);
        } catch (MissingResourceException e) {
            Debug.message(DEBUG, "Could not locate resource: "
                    + bString.replace('.', '/') + ".properties");
            return null;
        }

        String key = shortClassName(requestor) + "." + field;
        switch (type) {
        case TEXT:
            // Do nothing.
            break;
        case TITLE:
            key += ".title";
            break;
        case TOOLTIP:
            key += ".tooltip";
            break;
        case MNEMONIC:
            key += ".mnemonic";
            break;
        }

        try {

            return bundle.getString(key);

        } catch (MissingResourceException e) {

            Debug.message(DEBUG, "Could not locate string in resource: "
                    + (pckg == null ? "" : (requestor.getPackage().getName().replace('.', '/') + "."))
View Full Code Here

Examples of java.util.ResourceBundle

     * @return null if the data can't be found -- defaulting happens
     *         above here.
     */
    protected void setForBundleCreation(Class requestor, String field,
                                        int type, String defaultString) {
        ResourceBundle bundle = null;

        Package pckg = requestor.getPackage();

        String bString = (pckg == null ? ""
                : (requestor.getPackage().getName() + "."))
                + ResourceFileNamePrefix;
       
        String propertyFileNameKey = null;
        Properties propertyFileProperties = null;

        // OK, first see what the property file should be.
        StringBuffer sbuf = new StringBuffer(bString.replace('.', '/'));
        // Scope the desired resource bundle property file if the
        // default isn't wanted.
        if (!Debug.debugging(DEBUG_CREATE_DEFAULT)) {
            sbuf.append("_" + loc.toString());
        }
        sbuf.append(".properties");
        propertyFileNameKey = sbuf.toString().intern();

        // See if we already have a properties file with the key-value
        // pairs for this particular resource bundle.
        propertyFileProperties = (Properties) getCreateHash().get(propertyFileNameKey);

        // If not, create it.
        if (propertyFileProperties == null) {
            propertyFileProperties = new Properties();
            getCreateHash().put(propertyFileNameKey, propertyFileProperties);
        }

        try {
            bundle = ResourceBundle.getBundle(bString, loc);
        } catch (MissingResourceException e) {
        }

        String resourceKey = shortClassName(requestor) + "." + field;
        switch (type) {
        case TEXT:
            // Do nothing.
            break;
        case TITLE:
            resourceKey += ".title";
            break;
        case TOOLTIP:
            resourceKey += ".tooltip";
            break;
        case MNEMONIC:
            resourceKey += ".mnemonic";
            break;
        }

        try {
            if (bundle != null) {
                String resourceValue = bundle.getString(resourceKey);
                propertyFileProperties.put(resourceKey, resourceValue);
            } else {
                propertyFileProperties.put(resourceKey, defaultString);
            }
        } catch (MissingResourceException e) {
View Full Code Here

Examples of java.util.ResourceBundle

    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

Examples of java.util.ResourceBundle

   * @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

Examples of java.util.ResourceBundle

    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

Examples of java.util.ResourceBundle

    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

Examples of java.util.ResourceBundle

    }
    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

Examples of java.util.ResourceBundle

        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

Examples of java.util.ResourceBundle

    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
TOP
Copyright © 2018 www.massapi.com. 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.