Guiliani  Version 2.5 revision 7293 (documentation build 13)
CGUILocalisationHandler Class Reference

This class is used to store international texts. More...

#include <GUILocalisationHandler.h>

Inheritance diagram for CGUILocalisationHandler:

Public Member Functions

TextResource_t AddDynamicText (const eC_String &kNewText)
 
void DeInit ()
 
void FreeDynamicText (const TextResource_t eID)
 
eC_String GetLocalisationFilename () const
 
eC_UInt GetNOFLocalisationTexts () const
 
const eC_String * GetText (const TextResource_t &eTextResourcesIdx) const
 
eC_Bool IsValidID (const TextResource_t &eID) const
 
void LoadLocalisationFile (const eC_String &kLangFileName)
 
void RegisterTextFragments (const TextResource_t &eID, const eC_UInt &uiCount)
 
eC_Bool SetNOFLocalisationTexts (eC_UInt uiNOFLocalisationTexts)
 
void SetText (TextResource_t eID, const eC_String &rkText, eC_Bool bNotifyObservers=true)
 
void SetTextFragment (const TextResource_t &eID, const eC_UInt &uiFragmentIndex, const eC_String &kText, const eC_Bool &bNotifyObservers=false)
 
void UnregisterTextFragments (const TextResource_t &eID)
 
eC_Bool WriteLocalisationFile (const eC_String &kPath) const
 
- Public Member Functions inherited from CGUISubject
 CGUISubject ()
 Default constructor.
 
virtual ~CGUISubject ()
 Default destructor.
 
void AddObserver (CGUIObserver *pObserver)
 
void ClearObservers ()
 Removes all observers from the internal list.
 
const eC_TListDoubleLinked< CGUIObserver * > & GetObserverList () const
 
void NotifyObservers ()
 
void NotifyObservers (const CGUIObject *const pkUpdatedObject)
 
void NotifyObservers (const CGUIValue &kObservedValue, const CGUIObject *const pkUpdatedObject, const eC_UInt uiX=0, const eC_UInt uiY=0)
 
void NotifyObservers (const eC_String &kMessage)
 
void RemoveObserver (CGUIObserver *pObserver)
 

Static Public Member Functions

static void CreateInstance ()
 
static void DeleteInstance ()
 

Friends

class CGUI
 
class CGUIComponentManager
 

Detailed Description

This class is used to store international texts.

The localisation handler maps abstract text resource identifiers (of type TextResource_t) to strings of the currently active language. (Please refer to chapter Internationalization for further details on how internationalization is handled within Guiliani.)

Switching between two languages is therefore only a matter of loading another language file. Language files are generally UTF-8 encoded text files in which each line of text corresponds to one TextTesource ID. Note that strings within the language file must be in the same order as their corresponding TextResource IDs (which are typically stored in UserTextResource.h)

Note that the localisation handler is an observable subject, and all CGUIText objects within the user interface will be automatically notified via the subject/observer pattern when a TextResource gets updated by a call to SetText().

Example code for loading a language file:

GETLOCALEHDL.LoadLocalisationFile("English.lng");

Example code for retrieving the string which is associated with a TextResource ID (defined in UserTextResource.h) within the given language:

const eC_String* pString = GETLOCALEHDL.GetText(TXT_HELLO);

Member Function Documentation

◆ AddDynamicText()

TextResource_t CGUILocalisationHandler::AddDynamicText ( const eC_String &  kNewText)

Adds a new Text and returns the associated dynamically created TextResource ID.

Parameters
kNewTextString for which a new TextResource ID shall be created
Returns
New TextResource ID.

◆ CreateInstance()

static void CGUILocalisationHandler::CreateInstance ( )
static

Create instance

◆ DeInit()

void CGUILocalisationHandler::DeInit ( )

Should only be called by the destructor. As a workaround for memory leak detection ~CGUI() may call it too, but it is forbidden to be called by other code.

◆ DeleteInstance()

static void CGUILocalisationHandler::DeleteInstance ( )
static

Delete instance

◆ FreeDynamicText()

void CGUILocalisationHandler::FreeDynamicText ( const TextResource_t  eID)

Frees the given TextResource ID.

Parameters
eIDTextID which shall be freed

◆ GetLocalisationFilename()

eC_String CGUILocalisationHandler::GetLocalisationFilename ( ) const

Return the name of the currenly loaded localisation-file

Returns
localisation-filename

◆ GetNOFLocalisationTexts()

eC_UInt CGUILocalisationHandler::GetNOFLocalisationTexts ( ) const

Returns the total number of localisation texts

Returns
number of texts

◆ GetText()

const eC_String * CGUILocalisationHandler::GetText ( const TextResource_t eTextResourcesIdx) const

Retrieves a text from the internal text table.

Parameters
eTextResourcesIdxIndex of text to retrieve.
Returns
Constant pointer to the corresponding text string. If eTextResourcesIdx is DUMMY_TEXT or points to an uninitialized text, a pointer to an empty string is returned.

◆ IsValidID()

eC_Bool CGUILocalisationHandler::IsValidID ( const TextResource_t eID) const

Checks if TextResource ID is valid.

Parameters
eIDTextResourceID to check.
Returns
True if valid else False.

◆ LoadLocalisationFile()

void CGUILocalisationHandler::LoadLocalisationFile ( const eC_String &  kLangFileName)

Loads international text strings from a file to a table. In case of error, the state of the internally stored Textstrings is undefined.

Parameters
kLangFileNameFile to load texts from.

◆ RegisterTextFragments()

void CGUILocalisationHandler::RegisterTextFragments ( const TextResource_t eID,
const eC_UInt &  uiCount 
)

Register text-fragments for a TextResource

Parameters
eIDID of the TextResource
uiCountnumber of fragments which should be registered

◆ SetNOFLocalisationTexts()

eC_Bool CGUILocalisationHandler::SetNOFLocalisationTexts ( eC_UInt  uiNOFLocalisationTexts)

Sets the total number of texts.

Parameters
uiNOFLocalisationTextsNumber of texts
Returns
True if internal storage has been successfully adapted to support the requested number of texts. False otherwise.

◆ SetText()

void CGUILocalisationHandler::SetText ( TextResource_t  eID,
const eC_String &  rkText,
eC_Bool  bNotifyObservers = true 
)

Sets (changes) the text for a specific ID.

Parameters
eIDThe ID of the text to be changed.
rkTextThe text to be used for the ID.
bNotifyObserversIf true notification of all obeservers will be done.

◆ SetTextFragment()

void CGUILocalisationHandler::SetTextFragment ( const TextResource_t eID,
const eC_UInt &  uiFragmentIndex,
const eC_String &  kText,
const eC_Bool &  bNotifyObservers = false 
)

Set the text for a text-fragment

Parameters
eIDID of the TextResource
uiFragmentIndexindex of the fragment
kTexttext to use in placeholder
bNotifyObserversif true all observers are notified

◆ UnregisterTextFragments()

void CGUILocalisationHandler::UnregisterTextFragments ( const TextResource_t eID)

Unregister text-fragments for a TextResource

Parameters
eIDID of the TextResource

◆ WriteLocalisationFile()

eC_Bool CGUILocalisationHandler::WriteLocalisationFile ( const eC_String &  kPath) const

Writes all registered TextResources of the GUI to File.

Parameters
kPathPath and name of the destination file.
Returns
Always returns true
Exceptions
CGUIExceptionif destinationfile could not be opened.

Friends And Related Function Documentation

◆ CGUI

friend class CGUI
friend

◆ CGUIComponentManager

friend class CGUIComponentManager
friend

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