api/src/main/java/org/ocpsoft/rewrite/transposition/LocaleTransposition.java
private String translate(String lang, String value)
   {
      String translatation = null;
      if (value != null)
      {
         if (!bundleMap.containsKey(lang))
         {
            Locale locale = new Locale(lang);
            try
            {
               ResourceBundle loadedBundle = ResourceBundle.getBundle(bundleName, locale,
                        ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_DEFAULT));

               bundleMap.put(lang, loadedBundle);
            }
            catch (MissingResourceException e)
            {
               return null;
            }
         }

         try
         {
            // can we received more than one path section? e.g./search/service/
            translatation = bundleMap.get(lang).getString(value);
         }
         catch (MissingResourceException mrEx)
         {
            // ignore
         }
      }
      return translatation;
   }
private String translate(String lang, String value)
   {
      String translatation = null;
      if (value != null)
      {
         if (!bundleMap.containsKey(lang))
         {
            Locale locale = new Locale(lang);
            try
            {
               ResourceBundle loadedBundle = ResourceBundle.getBundle(bundleName, locale,
                        ResourceBundle.Control.getNoFallbackControl(ResourceBundle.Control.FORMAT_DEFAULT));

               bundleMap.put(lang, loadedBundle);
            }
            catch (MissingResourceException e)
            {
               return null;
            }
         }

         try
         {
            // can we received more than one path section? e.g./search/service/
            translatation = bundleMap.get(lang).getString(value);
         }
         catch (MissingResourceException mrEx)
         {
            // ignore
         }
      }
      return translatation;
   }
private String translate ( String lang , String value ) { String translatation = null ; if ( value != null ) { if ( ! bundleMap . containsKey ( lang ) ) { Locale locale = new Locale ( lang ) ; try { ResourceBundle loadedBundle = ResourceBundle . getBundle ( bundleName , locale , ResourceBundle . Control . getNoFallbackControl ( ResourceBundle . Control . FORMAT_DEFAULT ) ) ; bundleMap . put ( lang , loadedBundle ) ; } catch ( MissingResourceException e ) { return null ; } } try { // can we received more than one path section? e.g./search/service/ translatation = bundleMap . get ( lang ) . getString ( value ) ; } catch ( MissingResourceException mrEx ) { // ignore } } return translatation ; }
Translate a value into the matching one from a resource bundle in specified language.

@param lang
@param value
@return translated value or null if no bundle can be found for the specified language or no entries in the bundle
match the given value.
Translate a value into the matching one from a resource bundle in specified language .