2018-09-29 15:56:04 +03:00
|
|
|
/*
|
2021-01-05 13:04:05 +03:00
|
|
|
* Copyright (C) 2018-2021 QuasarApp.
|
2018-09-29 15:56:04 +03:00
|
|
|
* Distributed under the lgplv3 software license, see the accompanying
|
|
|
|
* Everyone is permitted to copy and distribute verbatim copies
|
|
|
|
* of this license document, but changing it is not allowed.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LOCALES_H
|
|
|
|
#define LOCALES_H
|
|
|
|
|
|
|
|
#include "quasarapp_global.h"
|
|
|
|
|
2020-05-16 15:46:41 +03:00
|
|
|
#include <QLocale>
|
2020-05-15 01:43:32 +03:00
|
|
|
#include <QString>
|
|
|
|
|
2018-09-29 15:56:04 +03:00
|
|
|
class QCoreApplication;
|
|
|
|
class QTranslator;
|
|
|
|
|
|
|
|
namespace QuasarAppUtils {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief The Locales class for parese local files
|
|
|
|
*/
|
2020-05-16 15:46:41 +03:00
|
|
|
class QUASARAPPSHARED_EXPORT Locales : public QObject
|
2018-09-29 15:56:04 +03:00
|
|
|
{
|
2020-05-16 15:46:41 +03:00
|
|
|
Q_OBJECT
|
2018-09-29 15:56:04 +03:00
|
|
|
public:
|
|
|
|
|
|
|
|
/**
|
2021-02-12 12:39:46 +03:00
|
|
|
* @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.
|
2020-05-15 01:43:32 +03:00
|
|
|
*/
|
2021-02-12 12:39:46 +03:00
|
|
|
static bool setLocale(const QLocale &locale);
|
2020-05-16 15:46:41 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief translate init 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
|
|
|
|
*/
|
2021-02-12 12:39:46 +03:00
|
|
|
bool translate(const QLocale &locale = QLocale::system(),
|
|
|
|
QString location = "");
|
2020-05-15 01:43:32 +03:00
|
|
|
|
|
|
|
/**
|
2020-05-16 15:46:41 +03:00
|
|
|
* @brief instance
|
|
|
|
* @return return static object
|
2020-05-15 01:43:32 +03:00
|
|
|
*/
|
2020-05-16 15:46:41 +03:00
|
|
|
static Locales *instance();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
/**
|
|
|
|
* @brief sigTranslationChanged - emited when set new locale for application.
|
|
|
|
*/
|
|
|
|
void sigTranslationChanged();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Locales() = default;
|
2021-02-12 12:39:46 +03:00
|
|
|
bool setLocalePrivate(const QLocale &locale = QLocale::system());
|
|
|
|
|
2020-05-15 01:43:32 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief getTranslator
|
|
|
|
* @return instance of Translation
|
2018-09-29 15:56:04 +03:00
|
|
|
*/
|
2020-05-15 01:43:32 +03:00
|
|
|
static QTranslator* getTranslator();
|
2021-02-12 12:39:46 +03:00
|
|
|
QString _location;
|
2018-09-29 15:56:04 +03:00
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // LOCALES_H
|