# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NLMISC::CI18N Class Reference

Class for the internationalisation. More...

#include <i18n.h>

Collaboration diagram for NLMISC::CI18N:

Collaboration graph
[legend]
List of all members.

Static Public Methods

const std::vector<ucstring>& getLanguageNames ()
 Return a vector with all language available. The vector contains the name of the language. The index in the vector is used in load() function. More...

void load (uint32 lid)
 Load a language file depending of the language. More...

const ucstringget (const char *str)
 Find a string in the selected language and return his association. More...

void setPath (const char* str)
 Temporary, we don't have file system for now, so we do a tricky cheat. there s not check so be careful! More...


Private Types

typedef std::map<std::string,
ucstring>::iterator 
ItStrMap
typedef std::map<std::string,
ucstring>::value_type 
ValueStrMap

Static Private Methods

ucchar eatChar (IStream &is)
void checkASCII7B (ucchar c)
void createLanguageFile (uint32 lid)
void createLanguageEntry (const std::string &lval, const std::string &rval)
void skipComment (IStream &is, int &line)
ucchar skipWS (IStream &is, int &line)

Static Private Attributes

std::map<std::string, ucstring_StrMap
bool _StrMapLoaded = false
std::string _Path = ""
std::string _FileName = ""
const char* _LanguageFiles [] = { "english", "french", "fun" }
std::vector<ucstring_LanguageNames
bool _LanguagesNamesLoaded = false

Detailed Description

Class for the internationalisation.

It's a singleton pattern.

This class provide an easy way to localise all string. First you have to get all available language with getLanguageNames(). If you already know the number of the language (that is the index in the vector returns by getLanguagesNames()), you can load the language file with load(). Now, you can get a localised string with his association with get().

        // get all language names
        CI18N::getLanguageNames ();
        // load the language 1 (french)
        CI18N::load (1);
        // display "Salut" that is the "hi" string in the selected language (french).
        nlinfo (CI18N::get("hi").c_str ());
        // display "rms est un master", the french version of the string
        nlinfo (CI18N::get("%s is a master").c_str (), "rms");

If the string doesn't exist, it will be automatically added in all language files with a <Not Translated> mention. If the language file doesn't exist, it'll be automatically create.

Author(s):
Vianney Lecroart , Nevrax France
Date:
2000

Definition at line 64 of file i18n.h.


Member Typedef Documentation

typedef std::map<std::string, ucstring>::iterator NLMISC::CI18N::ItStrMap [private]
 

Definition at line 83 of file i18n.h.

typedef std::map<std::string, ucstring>::value_type NLMISC::CI18N::ValueStrMap [private]
 

Definition at line 84 of file i18n.h.


Member Function Documentation

void NLMISC::CI18N::checkASCII7B ( ucchar c ) [static, private]
 

Definition at line 106 of file i18n.cpp.

void NLMISC::CI18N::createLanguageEntry ( const std::string & lval,
const std::string & rval ) [static, private]
 

Definition at line 174 of file i18n.cpp.

void NLMISC::CI18N::createLanguageFile ( uint32 lid ) [static, private]
 

Definition at line 160 of file i18n.cpp.

ucchar NLMISC::CI18N::eatChar ( IStream & is ) [static, private]
 

Definition at line 47 of file i18n.cpp.

const ucstring & NLMISC::CI18N::get ( const char * str ) [static]
 

Find a string in the selected language and return his association.

Definition at line 358 of file i18n.cpp.

const vector< ucstring >& NLMISC::CI18N::getLanguageNames ( ) [static]
 

Return a vector with all language available. The vector contains the name of the language. The index in the vector is used in load() function.

Definition at line 386 of file i18n.cpp.

void NLMISC::CI18N::load ( uint32 lid ) [static]
 

Load a language file depending of the language.

Definition at line 225 of file i18n.cpp.

void NLMISC::CI18N::setPath ( const char * str ) [static]
 

Temporary, we don't have file system for now, so we do a tricky cheat. there s not check so be careful!

Definition at line 220 of file i18n.cpp.

void NLMISC::CI18N::skipComment ( IStream & is,
int & line ) [static, private]
 

Definition at line 115 of file i18n.cpp.

ucchar NLMISC::CI18N::skipWS ( IStream & is,
int & line ) [static, private]
 

Definition at line 142 of file i18n.cpp.


Member Data Documentation

string NLMISC::CI18N::_FileName = "" [static, private]
 

Definition at line 42 of file i18n.cpp.

const char * NLMISC::CI18N::_LanguageFiles[] = { "english", "french", "fun" } [static, private]
 

Definition at line 37 of file i18n.cpp.

vector< ucstring > NLMISC::CI18N::_LanguageNames [static, private]
 

Definition at line 44 of file i18n.cpp.

bool NLMISC::CI18N::_LanguagesNamesLoaded = false [static, private]
 

Definition at line 45 of file i18n.cpp.

string NLMISC::CI18N::_Path = "" [static, private]
 

Definition at line 41 of file i18n.cpp.

map< string,ucstring > NLMISC::CI18N::_StrMap [static, private]
 

Definition at line 39 of file i18n.cpp.

bool NLMISC::CI18N::_StrMapLoaded = false [static, private]
 

Definition at line 40 of file i18n.cpp.


The documentation for this class was generated from the following files: