QuasarAppLib 1.0.530.c9fba11
QuasarAppUtils::Locales Class Reference

The Locales class for parese local files Example :. More...

#include <locales.h>

Inheritance diagram for QuasarAppUtils::Locales:
Inheritance graph
Collaboration diagram for QuasarAppUtils::Locales:
Collaboration graph

Signals

void sigTranslationChanged ()
 sigTranslationChanged Emitted when set new locale for application.

Static Public Member Functions

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.

Detailed Description

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.
Definition locales.cpp:157
Note
If you want to add you own location of the qm files then add this into second arguments of the Locales::init method.
QuasarAppUtils::Locales::init(QLocale::system(), "myPath");
Note
All translations qm files should be named with lower case example : en.qm

Definition at line 39 of file locales.h.

Member Function Documentation

◆ 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
locationThis is a new location of the qm files.

Definition at line 237 of file locales.cpp.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:

◆ init() [1/2]

bool Locales::init ( const QList< QLocale > & locales,
const QSet< QString > & location = {} )
static

init This method initialize translations of application.

Parameters
localesThis is list of locales that you want to locad to application cache. See info about QLocale.
locationPath to folder with qm files. example (:/tr).
Returns
return true if locale set for application.

Definition at line 157 of file locales.cpp.

Here is the call graph for this function:

◆ init() [2/2]

bool Locales::init ( const QLocale & locale = QLocale::system(),
const QSet< QString > & location = {} )
static

init This method initialize translation of application.

Parameters
localeSee info about QLocale.
locationPath to folder with qm files. example (:/tr).
Returns
return true if locale set for application.

Definition at line 162 of file locales.cpp.

Here is the call graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
localeThis is new locale.
forceThis 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.

Here is the call graph for this function:

◆ 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
sourceThis is source string of translations.
localeThis 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.

Here is the call graph for this function:

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