![]() |
Mapper
0.9.0
API documentation
|
A simplified interface to searching and loading translations. More...
#include <translation_util.h>
Classes | |
struct | Language |
A struct for representing the language of a translation. More... | |
Public Types | |
using | LanguageList = std::vector< Language > |
A collection of languages. More... | |
Public Member Functions | |
TranslationUtil () | |
Creates a new translation utility for the file or language from the settings. More... | |
TranslationUtil (const QSettings &settings) | |
Creates a new translation utility for the file or language from the given settings. More... | |
TranslationUtil (const QString &code, QString translation_file={}) | |
Creates a new translation utility for the given language. More... | |
QString | code () const |
Returns the code of the language. More... | |
QString | displayName () const |
Returns the display name of the language. More... | |
QTranslator & | getQtTranslator () |
Returns a translator for Qt strings. More... | |
QTranslator & | getAppTranslator () |
Returns a translator for application strings. More... | |
std::unique_ptr< QTranslator > | load (const QString &translation_name) const |
Tries to create a QTranslator for the named translation. More... | |
Static Public Member Functions | |
static void | setBaseName (const QLatin1String &name) |
Sets the common base name of the application's translation files. More... | |
static LanguageList | availableLanguages () |
Returns a collection of available languages for this application. More... | |
static Language | languageFromFilename (const QString &path) |
Returns the language for a given translation file. More... | |
static Language | languageFromCode (const QString &code) |
Returns the language for a language name. More... | |
static Language | languageFromSettings (const QSettings &settings) |
Returns the language for the given settings object. More... | |
Protected Member Functions | |
bool | load (QTranslator &translator, const QString &translation_name) const |
Finds a named translation from the search path and loads it to the translator. More... | |
Protected Attributes | |
Language | language |
QTranslator | qt_translator |
QTranslator | app_translator |
Static Protected Attributes | |
static QString | base_name |
A simplified interface to searching and loading translations.
using OpenOrienteering::TranslationUtil::LanguageList = std::vector<Language> |
A collection of languages.
OpenOrienteering::TranslationUtil::TranslationUtil | ( | ) |
Creates a new translation utility for the file or language from the settings.
The base name of the translation files must be set in advance.
OpenOrienteering::TranslationUtil::TranslationUtil | ( | const QSettings & | settings | ) |
Creates a new translation utility for the file or language from the given settings.
The base name of the translation files must be set in advance.
OpenOrienteering::TranslationUtil::TranslationUtil | ( | const QString & | code, |
QString | translation_file = {} |
||
) |
Creates a new translation utility for the given language.
The base name of the translation files must be set in advance.
|
static |
Returns a collection of available languages for this application.
|
inline |
Returns the code of the language.
|
inline |
Returns the display name of the language.
|
inline |
Returns a translator for application strings.
|
inline |
Returns a translator for Qt strings.
|
static |
Returns the language for a language name.
|
static |
Returns the language for a given translation file.
|
static |
Returns the language for the given settings object.
std::unique_ptr< QTranslator > OpenOrienteering::TranslationUtil::load | ( | const QString & | translation_name | ) | const |
Tries to create a QTranslator for the named translation.
If the named translation cannot be loaded from the search path, returns an unset unique_prt.
|
protected |
Finds a named translation from the search path and loads it to the translator.
|
static |
Sets the common base name of the application's translation files.
|
protected |
|
staticprotected |
|
protected |
|
protected |