Here you can find the source of getResourceBundleLocaleString(String sKey, Object[] sParam, String sResourceBundle)
Parameter | Description |
---|---|
sKey | The given resource bundle key |
sParam | The params for the localized message |
sResourceBundle | The resource bundle to load <p> |
public static String getResourceBundleLocaleString(String sKey, Object[] sParam, String sResourceBundle)
//package com.java2s; //License from project: Open Source License import java.text.MessageFormat; import java.util.ResourceBundle; public class Main { /**// w w w .jav a 2 s .c o m * Returns the locale specific string for the given * resource bundle key * <p> * @param sKey The given resource bundle key * @param sParam The params for the localized message * @param sResourceBundle The resource bundle to load * <p> * @return The required locale specific string if the * key was found in the resource bundle, else * it simply returns the key itself */ public static String getResourceBundleLocaleString(String sKey, Object[] sParam, String sResourceBundle) { ResourceBundle resourcebundleWS = ResourceBundle.getBundle(sResourceBundle); try { String sString = resourcebundleWS.getString(sKey); return MessageFormat.format(sString, sParam); } catch (Throwable e) { return sKey; } } /** * Returns the locale specific string for the given * resource bundle key and given resource bundle * <p> * @param sKey The given resource bundle key * @param sResourceBundle The resource bundle to load * <p> * @return The required locale specific string if the * key was found in the resource bundle, else * it simply returns the key itself */ public static String getResourceBundleLocaleString(String sKey, String sResourceBundle) { ResourceBundle resourcebundleWS = ResourceBundle.getBundle(sResourceBundle); try { String sString = resourcebundleWS.getString(sKey); return sString; } catch (Throwable e) { return sKey; } } }