Rogue Wave Views 5.6 |
Rogue Wave Views |
Rogue Wave Views Documentation Home |
Message handling class. More...
#include <ilviews/base/message.h>
Public Member Functions | |
virtual void | clean () |
Cleans the message database. More... | |
const char * | getMessage (const char *msgid, const IlSymbol *language) const |
Gets a message. More... | |
void | putMessage (const char *msgid, IlSymbol *language, const char *value, IlBoolean copy=IlTrue) |
Adds a message. More... | |
virtual IlBoolean | read (ILVSTDPREF istream &istr, const IlvDisplay *display=0, const char *fName=0) |
Reads a message database from the input stream. More... | |
IlBoolean | read (const char *filename, const IlvDisplay *d=0, const char *fName=0) |
Reads a message database from a file. More... | |
virtual void | remove (IlSymbol *language) |
Removes all messages for a language. More... | |
virtual IlBoolean | removeMessage (const char *msgid) |
Removes a message. More... | |
virtual void | write (ILVSTDPREF ostream &ostr, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const |
Writes the message database to the output stream. More... | |
void | write (const char *filename, const IlSymbol *language=0, IlEncoding encoding=IlNoEncoding) const |
Writes the message database to a file. More... | |
Message handling class.
Library: display
Rogue Wave Views provides a simple mechanism to help you localize applications. The IlvMessageDatabase
class allows to associate several translations strings with single message identifier (one translation per language), and provides a way to retrieve the right translation at runtime, based on the current language.
Each instance of the IlvDisplay
class creates its own message database. It reads the database description from the file name provided in the environment variable ILVDB
, or views.dbm
if this variable is not set. This file is searched for in the display path. You can access this database by calling the member function IlvDisplay::getDatabase()
. Each string that you plan to show in different languages can be stored in the database with its different possible translations. We say that you associate a message identifier with different message strings, depending on the language you target. The language is specified in a symbol.
|
virtual |
Cleans the message database.
Empties the database. Every message is deleted from every language.
const char* IlvMessageDatabase::getMessage | ( | const char * | msgid, |
const IlSymbol * | language | ||
) | const |
Gets a message.
Retrieves the message string associated with the message identifier msgid for the language language. This string should not be modified or deleted by the user.
msgid | The message identifier of the message to be retrieved. |
language | The language. |
void IlvMessageDatabase::putMessage | ( | const char * | msgid, |
IlSymbol * | language, | ||
const char * | value, | ||
IlBoolean | copy = IlTrue |
||
) |
Adds a message.
Associates the message string value with the message identifier msgid for the language language. A copy of value is performed if copy is omitted or set to IlTrue
. Any previous definition is discarded.
msgid | The message identifier. |
language | The language. |
value | The message string. |
copy | A Boolean value to copy rather than move the string. |
|
virtual |
Reads a message database from the input stream.
Reads the description of a database from the input stream istr and appends this description to the current database.
istr | The input stream. |
IlFalse
if there has been an error loading the message database. IlBoolean IlvMessageDatabase::read | ( | const char * | filename, |
const IlvDisplay * | d = 0 , |
||
const char * | fName = 0 |
||
) |
Reads a message database from a file.
Reads this database from the file filename. If the display parameter is not 0
, the file is searched for in the display path, provided that filename is a relative path name. If you are using the internationalization feature, you should be aware that it will be impossible to read a message database located in a locale directory if the display argument is not provided.
filename | The input file. |
display | The display path to search for a relative filename. |
IlFalse
if an error occurred while loading the message database.
|
virtual |
Removes all messages for a language.
Removes the definition of every message for the language language.
language | The language whose messages are to be removed. |
|
virtual |
Removes a message.
Removes every definition of the message identifier msgid.
msgid | The message identifier to be removed. |
IlFalse
if no such message identifier was found in the database.
|
virtual |
Writes the message database to the output stream.
Saves this database to the output stream ostr.
ostr | The output stream. |
void IlvMessageDatabase::write | ( | const char * | filename, |
const IlSymbol * | language = 0 , |
||
IlEncoding | encoding = IlNoEncoding |
||
) | const |
Writes the message database to a file.
Saves this database to the file filename.
filename | The output file. |
© Copyright 2012, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.