ScummVM API documentation
Common::TranslationManager Class Reference

#include <translation.h>

Inheritance diagram for Common::TranslationManager:
Common::NonCopyable Common::MainTranslationManager

Public Member Functions

 TranslationManager (const Common::String &fileName)
 
String getLangById (int id) const
 
void setLanguage (const String &lang)
 
void setLanguage (int id)
 
int parseLanguage (const String &lang) const
 
U32String getTranslation (const char *message) const
 
U32String getTranslation (const String &message) const
 
U32String getTranslation (const char *message, const char *context) const
 
U32String getTranslation (const String &message, const String &context) const
 
const TLangArray getSupportedLanguageNames () const
 
String getCurrentLanguage () const
 
int getCurrentLanguageId () const
 
bool currentIsBuiltinLanguage () const
 

Detailed Description

Message translation manager.

Constructor & Destructor Documentation

◆ TranslationManager()

Common::TranslationManager::TranslationManager ( const Common::String fileName)

Constructor that sets the current language to the default language.

The default language is the detected system language.

Member Function Documentation

◆ getLangById()

String Common::TranslationManager::getLangById ( int  id) const

Retrieve the language string from the given ID.

Parameters
idID of the language.
Returns
Matching string description of the language.

◆ setLanguage() [1/2]

void Common::TranslationManager::setLanguage ( const String lang)

Set the current translation language to the one specified in the parameter.

If the parameter is an empty string, it sets the translation language to the default system language.

Parameters
langLanguage to set up.

◆ setLanguage() [2/2]

void Common::TranslationManager::setLanguage ( int  id)
inline

Set the current translation language to the one specified by the id parameter.

Parameters
idID of the language.

◆ parseLanguage()

int Common::TranslationManager::parseLanguage ( const String lang) const

Get the ID for the given language string.

Parameters
langLanguage string.
Returns
ID of the language or kTranslationBuiltinId in case the language could not be found.

◆ getTranslation() [1/4]

U32String Common::TranslationManager::getTranslation ( const char *  message) const

Return the translation of message into the current language.

In case the message is not found in the translation catalog, return the original untranslated message, as a U32String.

◆ getTranslation() [2/4]

U32String Common::TranslationManager::getTranslation ( const String message) const

Return the translation of message into the current language.

In case the message is not found in the translation catalog, return the original untranslated message, as a U32String.

◆ getTranslation() [3/4]

U32String Common::TranslationManager::getTranslation ( const char *  message,
const char *  context 
) const

Return the translation of message into the current language.

In case the message is not found in the translation catalog, return the original untranslated message, as a U32String.

If a translation is found for the given context, return that translation. Otherwise, look for a translation for the same message without a context or with a different context.

◆ getTranslation() [4/4]

U32String Common::TranslationManager::getTranslation ( const String message,
const String context 
) const

Return the translation of message into the current language.

In case the message is not found in the translation catalog, return the original untranslated message, as a U32String.

If a translation is found for the given context, return that translation. Otherwise, look for a translation for the same message without a context or with a different context.

◆ getSupportedLanguageNames()

const TLangArray Common::TranslationManager::getSupportedLanguageNames ( ) const

Return a list of supported languages.

Returns
The list of supported languages in a user-readable format.

◆ getCurrentLanguage()

String Common::TranslationManager::getCurrentLanguage ( ) const

Return the currently selected translation language.

◆ getCurrentLanguageId()

int Common::TranslationManager::getCurrentLanguageId ( ) const

Return the id of the selected translation language.

◆ currentIsBuiltinLanguage()

bool Common::TranslationManager::currentIsBuiltinLanguage ( ) const

Return true if the current language is the builtin language and false if it is another language.


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