private static String getLocalizedOrCode(String bundleName,
                                             Locale locale,
                                             String code,
                                             String[] values) {
        ResourceBundle bundle = null;
        if (bundleName != null) {
            bundle = ResourceBundle.getBundle(bundleName, locale);
        }
        if (bundle == null) {
            return code;
        }
        String locMessage = bundle.getString(code);
        if (locMessage == null) {
            return code;
        }
        if (values == null) {
            return locMessage;
        }
        return MessageFormat.format(locMessage, (Object[]) values);
    }
private static String getLocalizedOrCode ( String bundleName , Locale locale , String code , String [ ] values ) { ResourceBundle bundle = null ; if ( bundleName != null ) { bundle = ResourceBundle . getBundle ( bundleName , locale ) ; } if ( bundle == null ) { return code ; } String locMessage = bundle . getString ( code ) ; if ( locMessage == null ) { return code ; } if ( values == null ) { return locMessage ; } return MessageFormat . format ( locMessage , ( Object [ ] ) values ) ; }
Gets the message from the resource bundle, formatting it if needed, and
on failure, just returns the code.

@param bundleName
The ResourceBundle where the message is defined.
@param locale
The preferred locale.
@param code
The message key.
@param values
The replacement values, assumed empty if null.
@return The detail messages, with {num}-indexed placeholders populated,
if needed.