The Locales class for parese local files Example :.
More...
#include <locales.h>
|
| static bool | setLocale (const QLocale &locale, bool force=false) |
| | setLocale This method sets locale for application and loaded all translations for this locale.
|
| static bool | init (const QList< QLocale > &locales, const QSet< QString > &location={}) |
| | init This method initialize translations of application.
|
| static bool | init (const QLocale &locale=QLocale::system(), const QSet< QString > &location={}) |
| | init This method initialize translation of application.
|
| static void | addLocation (const QString &location) |
| | addLocation This method add location for qm files. Use This method if you create a own library with translations supports.
|
| static Locales * | instance () |
| | instance This method return pointer to the Locales service.
|
| static const QLocale & | currentLocate () |
| | currentLocate This method return current locate of applicatuon.
|
| static QString | tr (const char *source, const QLocale &locale) |
| | tr This method will translate single string to chosen language.
|
The Locales class for parese local files Example :.
static bool init(const QList< QLocale > &locales, const QSet< QString > &location={})
init This method initialize translations of application.
- Note
- If you want to add you own location of the qm files then add this into second arguments of the Locales::init method.
- Note
- All translations qm files should be named with lower case example : en.qm
Definition at line 39 of file locales.h.
◆ addLocation()
| void Locales::addLocation |
( |
const QString & | location | ) |
|
|
static |
addLocation This method add location for qm files. Use This method if you create a own library with translations supports.
- Parameters
-
| location | This is a new location of the qm files. |
Definition at line 237 of file locales.cpp.
◆ currentLocate()
| const QLocale & Locales::currentLocate |
( |
| ) |
|
|
static |
currentLocate This method return current locate of applicatuon.
- Returns
- current or last sets locate of application.
Definition at line 142 of file locales.cpp.
◆ init() [1/2]
| bool Locales::init |
( |
const QList< QLocale > & | locales, |
|
|
const QSet< QString > & | location = {} ) |
|
static |
init This method initialize translations of application.
- Parameters
-
| locales | This is list of locales that you want to locad to application cache. See info about QLocale. |
| location | Path to folder with qm files. example (:/tr). |
- Returns
- return true if locale set for application.
Definition at line 157 of file locales.cpp.
◆ init() [2/2]
| bool Locales::init |
( |
const QLocale & | locale = QLocale::system(), |
|
|
const QSet< QString > & | location = {} ) |
|
static |
init This method initialize translation of application.
- Parameters
-
| locale | See info about QLocale. |
| location | Path to folder with qm files. example (:/tr). |
- Returns
- return true if locale set for application.
Definition at line 162 of file locales.cpp.
◆ instance()
| Locales * Locales::instance |
( |
| ) |
|
|
static |
instance This method return pointer to the Locales service.
- Returns
- return pointer to the Locales static object
Definition at line 218 of file locales.cpp.
◆ setLocale()
| bool Locales::setLocale |
( |
const QLocale & | locale, |
|
|
bool | force = false ) |
|
static |
setLocale This method sets locale for application and loaded all translations for this locale.
- Parameters
-
| locale | This is new locale. |
| force | This is a flag that forces reload of the translations even if the locale was already set. |
- Returns
- true if the all ltranstations files loaded successful.
Definition at line 152 of file locales.cpp.
◆ sigTranslationChanged
| void QuasarAppUtils::Locales::sigTranslationChanged |
( |
| ) |
|
|
signal |
sigTranslationChanged Emitted when set new locale for application.
◆ tr()
| QString Locales::tr |
( |
const char * | source, |
|
|
const QLocale & | locale ) |
|
static |
tr This method will translate single string to chosen language.
- Parameters
-
| source | This is source string of translations. |
| locale | This is chosen language. |
- Returns
- translated string value.
- Note
- use instant QOBject::tr, This method must be read by the lupdate utility
Definition at line 147 of file locales.cpp.
The documentation for this class was generated from the following files: