Example usage for java.util ResourceBundle getBundle

List of usage examples for java.util ResourceBundle getBundle

Introduction

In this page you can find the example usage for java.util ResourceBundle getBundle.

Prototype

@CallerSensitive
public static ResourceBundle getBundle(String baseName, Module module) 

Source Link

Document

Gets a resource bundle using the specified base name and the default locale on behalf of the specified module.

Usage

From source file:org.musicrecital.util.DateUtil.java

/**
 * Return default datePattern (MM/dd/yyyy)
 *
 * @return a string representing the date pattern on the UI
 *//*www.  jav a2 s  . c  om*/
public static String getDatePattern() {
    Locale locale = LocaleContextHolder.getLocale();
    String defaultDatePattern;
    try {
        defaultDatePattern = ResourceBundle.getBundle(Constants.BUNDLE_KEY, locale).getString("date.format");
    } catch (MissingResourceException mse) {
        defaultDatePattern = "MM/dd/yyyy";
    }

    return defaultDatePattern;
}

From source file:net.pms.Messages.java

public static String getString(String key, String lang) {
    if (StringUtils.isEmpty(lang)) {
        return getString(key);
    }// w  w  w .ja v  a 2s  .  c om
    Locale l = new Locale(lang);
    ResourceBundle rb = ResourceBundle.getBundle(BUNDLE_NAME, l);
    if (rb == null) {
        rb = RESOURCE_BUNDLE;
    }
    return getString(key, rb);
}

From source file:com.inkubator.hrm.web.converter.PaySalaryJurnalTypeJurnalConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (data == HRMConstant.PAY_SALARY_JURNAL_TYPE_DEBET) {
        messages = resourceBundle.getString("paySalaryJurnal.debet");
    } else if (data == HRMConstant.PAY_SALARY_JURNAL_TYPE_KREDIT) {
        messages = resourceBundle.getString("paySalaryJurnal.kredit");
    }/*from w  ww . j ava 2  s . com*/
    return messages;
}

From source file:com.inkubator.hrm.web.converter.RomanovConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    Integer data = (Integer) value;
    String messages = String.valueOf(RomanovUtil.convertToRoman(data));

    return messages;
}

From source file:com.inkubator.hrm.web.converter.PaySalaryJurnalModelJurnalConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (data == HRMConstant.PAY_SALARY_JURNAL_MODEL_CASH) {
        messages = resourceBundle.getString("paySalaryJurnal.cash");
    } else if (data == HRMConstant.PAY_SALARY_JURNAL_MODEL_TRANSFER) {
        messages = resourceBundle.getString("paySalaryJurnal.transfer");
    }//from w  w w .  j a v a  2  s  .c  o  m
    return messages;
}

From source file:com.rcs.shoe.shop.fx.model.LanguageModel.java

public void setBundle(Language lang) {
    if (lang == null || lang.equals(this.bundle)) {
        return;// ww w. j av  a 2s  .c om
    }
    setLanguage(lang);
    bundle = ResourceBundle.getBundle("lang", new Locale(lang.getValue(), lang.toString()));
    setChanged();
    notifyObservers();
}

From source file:com.inkubator.hrm.web.converter.PaySalaryComponentFormulaConverter.java

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {
    ResourceBundle resourceBundle = ResourceBundle.getBundle("Messages",
            new Locale(FacesUtil.getSessionAttribute(HRMConstant.BAHASA_ACTIVE).toString()));

    String messages = StringUtils.EMPTY;
    Integer data = (Integer) value;
    if (Objects.equals(data, 1)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_tunjangan");
    } else if (Objects.equals(data, -1)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_potongan");
    } else if (Objects.equals(data, 0)) {
        messages = resourceBundle.getString("paySalaryComponent.paySalaryComponent_subsidi");
    }// w  w w .ja  v  a 2s.co m
    return messages;
}

From source file:fr.certu.chouette.plugin.report.ReportItem.java

/**
 * @param locale/*from  www .ja  v  a2  s .  c om*/
 * @return
 */
public String getLocalizedMessage(Locale locale) {
    String format = "";
    String message = "";
    try {
        ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName(), locale);
        format = bundle.getString(getMessageKey());
        message = MessageFormat.format(format, messageArgs.toArray());
    } catch (MissingResourceException e1) {
        try {
            ResourceBundle bundle = ResourceBundle.getBundle(this.getClass().getName());
            format = bundle.getString(getMessageKey());
            message = MessageFormat.format(format, messageArgs.toArray());
        } catch (MissingResourceException e2) {
            message = getMessageKey();
            if (messageArgs != null)
                message += " : " + Arrays.toString(messageArgs.toArray());
        }
    }

    return message;
}

From source file:fr.mael.microrss.web.ConfigController.java

@RequestMapping(value = "/", method = RequestMethod.GET)
@ResponseBody/* w  w w. j a v a 2  s. c  om*/
public Config get(Locale locale) throws Exception {
    ResourceBundle bundle = ResourceBundle.getBundle("fr.mael.microrss.i18n.messages", locale);
    Config config = new Config(userService.getUserConfig());
    config.setI18n(Tools.convertResourceBundleToMap(bundle));
    return config;
}

From source file:adalid.commons.bundles.Bundle.java

/**
 * @param newLocale the locale to set/*from  ww  w .  j a va  2  s .  co m*/
 */
public static void setLocale(Locale newLocale) {
    ResourceBundle prevResourceBundle = resourceBundle;
    if (newLocale == null) {
        locale = Locale.getDefault();
        resourceBundle = defaultResourceBundle;
    } else if (newLocale.equals(locale)) {
    } else {
        locale = newLocale;
        try {
            resourceBundle = ResourceBundle.getBundle(BASE_NAME, locale);
        } catch (MissingResourceException e) {
            resourceBundle = defaultResourceBundle;
        }
    }
    if (resourceBundle.equals(prevResourceBundle)) {
    } else {
        linguist = getLinguist(resourceBundle);
    }
}