class GlobalMessageUtil {

  protected static String getLocaleString( Locale locale ) {
    final StringBuilder localeString = new StringBuilder();
    if ( locale != null && !StringUtils.isBlank( locale.getLanguage() ) ) {
      if ( !StringUtils.isBlank( locale.getCountry() ) ) {
        // force language to be lower case and country to be upper case
        localeString.append( locale.getLanguage().toLowerCase() ).append( '_' ).append(
          locale.getCountry().toUpperCase() );
      } else {
        // force language to be lower case
        localeString.append( locale.getLanguage().toLowerCase() );
      }
    }
    return localeString.toString();
  }

}