QuasarAppLib
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 Emited 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 applictaion.
 
static bool init (const QLocale &locale=QLocale::system(), const QSet< QString > &location={})
 init This method initialize translation of applictaion.
 
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 Localesinstance ()
 instance This method return pointer to the Locales service.
 
static const QLocalecurrentLocate ()
 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 choosed 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 applictaion.
Definition locales.cpp:157
Note
If you want to add you own location of the qm files then add this into seccond 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 applciation.

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

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

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.
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 Emited 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 choosed language.

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