Cppcheck
|
A class handling the available translations. More...
#include <translationhandler.h>
Public Member Functions | |
TranslationHandler (QObject *parent=nullptr) | |
const QList< TranslationInfo > & | getTranslations () const |
Get a list of available translations. More... | |
bool | setLanguage (const QString &code) |
Set active translation. More... | |
const QString & | getCurrentLanguage () const |
Get currently selected translation. More... | |
QString | suggestLanguage () const |
Get translation suggestion for the system. More... | |
Protected Member Functions | |
void | addTranslation (const char *name, const char *filename) |
Add new translation to list of available translations. More... | |
int | getLanguageIndexByCode (const QString &code) const |
Find language in the list and return its index. More... | |
Private Attributes | |
QString | mCurrentLanguage |
ISO 639 language code of the currently selected translation. More... | |
QList< TranslationInfo > | mTranslations |
List of available translations. More... | |
QTranslator * | mTranslator {} |
Translator class instance. More... | |
A class handling the available translations.
This class contains a list of available translations. The class also keeps track which translation is the currently active translation.
Definition at line 62 of file translationhandler.h.
|
explicit |
Definition at line 43 of file translationhandler.cpp.
References addTranslation().
|
protected |
Add new translation to list of available translations.
name | Name of the translation ("English"). |
filename | Filename of the translation. |
Definition at line 167 of file translationhandler.cpp.
References TranslationInfo::mCode, TranslationInfo::mFilename, TranslationInfo::mName, and mTranslations.
Referenced by TranslationHandler().
const QString & TranslationHandler::getCurrentLanguage | ( | ) | const |
Get currently selected translation.
Definition at line 145 of file translationhandler.cpp.
References mCurrentLanguage.
Referenced by SettingsDialog::initTranslationsList(), MainWindow::saveSettings(), and MainWindow::setLanguage().
|
protected |
Find language in the list and return its index.
code | ISO 639 language code. |
Definition at line 177 of file translationhandler.cpp.
References mTranslations.
Referenced by setLanguage(), and suggestLanguage().
|
inline |
Get a list of available translations.
Definition at line 72 of file translationhandler.h.
References mTranslations.
Referenced by SettingsDialog::initTranslationsList().
bool TranslationHandler::setLanguage | ( | const QString & | code | ) |
Set active translation.
code | ISO 639 language code for new selected translation. |
Definition at line 65 of file translationhandler.cpp.
References error, getDataDir(), getLanguageIndexByCode(), mCurrentLanguage, mTranslations, and mTranslator.
Referenced by MainWindow::setLanguage().
QString TranslationHandler::suggestLanguage | ( | ) | const |
Get translation suggestion for the system.
This function checks the current system locale and determines which of the available translations is best as current translation. If none of the available translations is good then it returns English ("en").
Definition at line 150 of file translationhandler.cpp.
References getLanguageIndexByCode().
|
private |
ISO 639 language code of the currently selected translation.
Definition at line 125 of file translationhandler.h.
Referenced by getCurrentLanguage(), and setLanguage().
|
private |
List of available translations.
Definition at line 131 of file translationhandler.h.
Referenced by addTranslation(), getLanguageIndexByCode(), getTranslations(), and setLanguage().
|
private |
Translator class instance.
Definition at line 137 of file translationhandler.h.
Referenced by setLanguage().