internationalizing flash messages.

28 views
Skip to first unread message

Josh Kamau

unread,
May 9, 2015, 10:33:01 AM5/9/15
to acti...@googlegroups.com
Hi ;

I am trying to resolve flash message text from the activeweb_messages.properties. 

In the controller, i have 'flash("message", "member.invalidUsername");'
in the messages i have 'member.invalidUsername=Your username is invalid.'
In the view, i have: <@flash name="message"/>   

Its displaying  "member.invalidUsername" and not the message in the properties file. Am i making a mistake?

Josh                   

Igor Polevoy

unread,
May 9, 2015, 11:23:58 AM5/9/15
to acti...@googlegroups.com
Josh, the FlashTag is not internationalized. However, you can do this using one of two methods.

Lets say your activeweb_messages_properties file contains this entry:

book_added=A book {0} was added to your library. Author: {1}


Method 1: Use class Messages in controller:

In controller:

      flash("saved", Messages.message("book_added", bookName, author ));

In view: 

      <@flash name="saved" />


This will print:  

       A book Hunger Games was added to your library. Author: Suzanne Collins

Method 2: Use MessageTag:


In controller:

      flash("saved");

In view: 

   <@flash name="saved">
      <@message key="book_added"/>
   </@flash>

This will print: 
    
    A book {0} was added to your library. Author: {1}

Method 1 should be used when you have parametrized messages. There is no way to pass a parameter to the MessageTag in method 2, because it is running in a different request (after redirect).

Choose a method that most appropriate for your app

tx

Igor Polevoy

unread,
May 9, 2015, 11:46:52 AM5/9/15
to acti...@googlegroups.com

Josh Kamau

unread,
May 9, 2015, 3:40:53 PM5/9/15
to acti...@googlegroups.com
Wow. This is fantastic.

Thanks.
Josh 

--
--
You received this message because you are subscribed to the Google
Groups "ActiveWeb Group" group.
To post to this group, send email to acti...@googlegroups.com
To unsubscribe from this group, send email to
activeweb+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/activeweb?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "ActiveWeb Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activeweb+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages