PixelLightAPI  .
Public Member Functions | Static Public Member Functions | Static Public Attributes
PLCore::Localization Class Reference

Localization manager. More...

#include <Localization.h>

List of all members.

Public Member Functions

String GetLanguage () const
 Returns the current language.
void SetLanguage (const String &sLanguage)
 Sets the current language.
PLCORE_API String Get (const String &sText, const String &sGroup=PixelLight) const
 Returns the translation of the given text.
uint32 GetNumOfGroups () const
 Returns the number of groups.
LocalizationGroupGetGroup (uint32 nIndex) const
 Returns a group by index.
LocalizationGroupGetGroup (const String &sName) const
 Returns a group by name.
PLCORE_API LocalizationGroupAddGroup (const String &sName)
 Adds a new group.
PLCORE_API bool RemoveGroup (uint32 nIndex)
 Removes a group by index.
PLCORE_API bool RemoveGroup (const String &sName)
 Removes a group by name.
PLCORE_API void RemoveAllGroups ()
 Removes all groups.

Static Public Member Functions

static PLCORE_API LocalizationGetInstance ()
static PLCORE_API bool HasInstance ()

Static Public Attributes

static PLCORE_API const String PixelLight

Detailed Description

Localization manager.

Remarks:
The localization manager is used to 'translate' a given text into the current active language. This is done by using the given text to translate as 'key' within a certain group and each project can have it's own localization group to avoid conflicts. If the given text to translate was found within the given localization group, the translation result is returned, else the given text is returned instead. As result, within your code you ALWAYS have to use a native language (within PixelLight, this is english) which is used if a text is not translated. The default localization group is called 'PixelLight' and should ONLY be used for engine texts!
*    Usage example:
*    String sString = PLT("Translate this text");
*    String sMyString = PL_TEXT("Translate this text", "MyProject");
*  

Member Function Documentation

static PLCORE_API Localization* PLCore::Localization::GetInstance ( ) [static]
static PLCORE_API bool PLCore::Localization::HasInstance ( ) [static]

Returns the current language.

Returns:
The current language
void PLCore::Localization::SetLanguage ( const String sLanguage) [inline]

Sets the current language.

Parameters:
[in]sLanguageThe new current language
Returns:
'true' if all went fine, else 'false'
Note:
  • You can use the System::GetLocaleLanguage() function to get the current program locale language
  • It's recommended to call this function ONLY on startup because it's possible that some texts can't be updated on runtime if another language is set
PLCORE_API String PLCore::Localization::Get ( const String sText,
const String sGroup = PixelLight 
) const

Returns the translation of the given text.

Parameters:
[in]sTextText to translate
[in]sGroupGroup the text to translate is in
Returns:
The translation of the given text, if no translation is available for this text the given text is returned instead by default
uint32 PLCore::Localization::GetNumOfGroups ( ) const [inline]

Returns the number of groups.

Returns:
The number of groups
LocalizationGroup * PLCore::Localization::GetGroup ( uint32  nIndex) const [inline]

Returns a group by index.

Parameters:
[in]nIndexIndex of the group
Returns:
The requested group, a null pointer on error
LocalizationGroup * PLCore::Localization::GetGroup ( const String sName) const [inline]

Returns a group by name.

Parameters:
[in]sNameName of the group
Returns:
The requested group, a null pointer on error

Adds a new group.

Parameters:
[in]sNameName of the new group
Returns:
The new group, a null pointer on error (maybe there's already a group with the given name?)
PLCORE_API bool PLCore::Localization::RemoveGroup ( uint32  nIndex)

Removes a group by index.

Parameters:
[in]nIndexIndex of the group
Returns:
'true' if all went fine, else 'false' (maybe there's no group with the given name?)
PLCORE_API bool PLCore::Localization::RemoveGroup ( const String sName)

Removes a group by name.

Parameters:
[in]sNameName of the group
Returns:
'true' if all went fine, else 'false' (maybe there's no group with the given name?)

Removes all groups.


Member Data Documentation

PLCORE_API const String PLCore::Localization::PixelLight [static]

"PixelLight" (default)


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


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:28
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported