From 81e4ef9bb468055e7af8647eb7d30f25d2971859 Mon Sep 17 00:00:00 2001 From: EndrII Date: Fri, 12 Feb 2021 13:28:47 +0300 Subject: [PATCH] added example --- locales.cpp | 7 ++++++- locales.h | 15 +++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/locales.cpp b/locales.cpp index ed4db53..c13e861 100644 --- a/locales.cpp +++ b/locales.cpp @@ -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()) diff --git a/locales.h b/locales.h index e471eb7..3c4dfeb 100644 --- a/locales.h +++ b/locales.h @@ -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