diff --git a/locales.cpp b/locales.cpp index 1fe5503..28f2d6b 100644 --- a/locales.cpp +++ b/locales.cpp @@ -24,7 +24,7 @@ bool Locales::setLocalePrivate(const QLocale &locale) { QFileInfoList qmFiles; for (const auto &location: qAsConst(_locations)) { - qmFiles += QDir(location).entryInfoList({"*" + locale.bcp47Name() + "*.qm"}, QDir::Files); + qmFiles += QDir(location).entryInfoList({"*" + locale.bcp47Name() + "*.qm"}, QDir::Files); } for (const auto & file: qAsConst(qmFiles)) { @@ -80,6 +80,15 @@ void Locales::removeOldTranslation() { } } +void Locales::addLocationPrivate(const QString &location) { + _locations += location; +} + +void Locales::addLocation(const QString &location) { + auto obj = instance(); + obj->addLocationPrivate(location); +} + Locales::~Locales() { removeOldTranslation(); } diff --git a/locales.h b/locales.h index 7102ed4..6d8ead3 100644 --- a/locales.h +++ b/locales.h @@ -53,6 +53,13 @@ public: */ static bool init(const QLocale &locale = QLocale::system(), const QSet & location = {}); + + /** + * @brief addLocation This method add location for qm files. Use This method if you create a own library with translations supports. + * @param location This is a new location of the qm files. + */ + static void addLocation(const QString& location); + /** * @brief instance This method return pointer to the Locales service. * @return return pointer to the Locales static object @@ -73,6 +80,7 @@ private: bool initPrivate(const QLocale &locale = QLocale::system(), const QSet &location = {}); void removeOldTranslation(); + void addLocationPrivate(const QString& location); QSet _locations; QList _translations;