3 Replies Latest reply on Jan 14, 2008 5:38 PM by Pete Muir

    localize Strings

    m k Newbie

      Hi,

      the localization features in Seam work very well for logging and facesMessages but how can i localize a String with parameters ?

      I have tried to achieve this with the Messages component. But this returns only a map which have no variable resolving methods....

      What i want to do is localising a String with parameters similar to the facesMessages for example:

      facesMessages.addFromResourceBundle("message.sendEmail", email );
      


      the messages_en.properties key looks like:
      message.sendEmail.invoice = send invoice to {0}
      


      Any help is appreciated.

      Best regards

      mki

        • 1. Re: localize Strings
          Pete Muir Master

          Run the String through the interpolator. Like

          String result = Interpolator.instance().interpolate(messages.get("message.sendEmail"), email);


          • 2. Re: localize Strings
            Andrew Elegante Newbie

            I found it easier to use the 'template' function like this:

            facesMessages.add(FacesMessage.SEVERITY_INFO, messages.get("feeAgreementSearch.activateSelectedAlreadyActiveWarning"),fa.getFeeAgreementId());
            


            In your case this would look like:
            facesMessages.add(messages.get("message.sendEmail"), email );
            


            Also, I believe the templating params for seam look like #0 not {0}

            Is there any plan to allow for a templated message in the messages bundle that will be resolved first and then have the appropriate parameters substituted?

            Drew

            • 3. Re: localize Strings
              Pete Muir Master

               

              "UTDrew" wrote:
              I found it easier to use the 'template' function like this:


              Yes, I forgot about this ;)

              Also, I believe the templating params for seam look like #0 not {0}


              No, it should be {0}, #0 is for log messages

              Is there any plan to allow for a templated message in the messages bundle that will be resolved first and then have the appropriate parameters substituted?


              ? Don't understand.