Wt::WMessageResourceBundle Class Reference

A class which manages text messages that may be adapted to the current locale. More...

#include <WMessageResourceBundle>

List of all members.

Public Member Functions

void use (const std::string &path, bool loadInMemory=true)
 Add a (series) of message resource files to be used.
std::wstring getValue (const WString &s)
 Get the value for a particular string in the current locale.
std::string getUTF8Value (const WString &s)
 Get the UTF8-encoded value for a particular string in the current locale.
void refresh ()
 Reread the message resources.


Detailed Description

A class which manages text messages that may be adapted to the current locale.

The resource bundle manages a number of resource files, which allow the developer to conceptually manage its messages in a number of libraries.

For example, a WApplication may have a generic message library, that is shared with many other libraries, with re-occurring messages (such as 'welcome', 'add to shopping cart', and 'pay'), and a specific message library for specific messages.


Member Function Documentation

void Wt::WMessageResourceBundle::use ( const std::string &  path,
bool  loadInMemory = true 
)

Add a (series) of message resource files to be used.

When you give as path: /path/to/name, then the following message resource files will be used:

The message file that will be currently used depends on the application's locale.

A Message resource file must be formatted as follows:

     <messages>
       <message id='welcome-text'>
         Welcome dear visiter, {1} of the WFooBar magic website !
       </message>
       <message id='company-policy'>
         The company policy is to <b>please our share-holders</b>.
       </message>
     </messages>

To refer the two messages defined in this resource file, use WString::tr("welcome-text").arg(userName) or WWidget::tr("company-policy").

See also:
WApplication::locale(), WString::tr(), WWidget::tr()


The documentation for this class was generated from the following files:
Generated on Mon Apr 14 15:15:01 2008 for Wt by doxygen 1.5.3