4
0
mirror of https://github.com/QuasarApp/QuasarAppLib.git synced 2025-05-04 13:39:42 +00:00

added example

This commit is contained in:
Andrei Yankovich 2021-02-12 13:28:47 +03:00
parent b5316127aa
commit 81e4ef9bb4
2 changed files with 15 additions and 7 deletions

@ -39,7 +39,12 @@ bool Locales::setLocale(const QLocale &locale) {
return obj->setLocalePrivate(locale);
}
bool Locales::translate(const QLocale &locale, QString location) {
bool Locales::init(const QLocale &locale, QString location) {
auto obj = instance();
return obj->initPrivate(locale, location);
}
bool Locales::initPrivate(const QLocale &locale, QString location) {
auto translator = getTranslator();
if (location.isEmpty())

@ -21,6 +21,10 @@ namespace QuasarAppUtils {
/**
* @brief The Locales class for parese local files
* Example :
* @code{cpp}
* QuasarAppUtils::Locales::init()
* @endcode
*/
class QUASARAPPSHARED_EXPORT Locales : public QObject
{
@ -30,20 +34,18 @@ public:
/**
* @brief setLocale This method sets locale for application and loaded all translations for this locale.
* @param locale This is new locale.
* @param location This is localtion of the qm file. if you want to load files from resource set patht to resources files
* Example :(:/tr/)
* @return true if the all ltranstations files loaded successful.
*/
static bool setLocale(const QLocale &locale);
/**
* @brief translate init translation of applictaion
* @brief init This method initialize translation of applictaion
* @param locale - see info about QLocale
* @param location - path to folder with qm files. example (:/tr)
* @return return true if locale set for application
*/
bool translate(const QLocale &locale = QLocale::system(),
QString location = "");
static bool init(const QLocale &locale = QLocale::system(),
QString location = "");
/**
* @brief instance
@ -60,7 +62,8 @@ signals:
private:
Locales() = default;
bool setLocalePrivate(const QLocale &locale = QLocale::system());
bool initPrivate(const QLocale &locale = QLocale::system(),
QString location = "");
/**
* @brief getTranslator