QuasarAppLib
locales.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8
9#ifndef LOCALES_H
10#define LOCALES_H
11
12#include "quasarapp_global.h"
13
14#include <QLocale>
15#include <QSet>
16#include <QString>
17#include <QDir>
18
19class QCoreApplication;
20class QTranslator;
21
22namespace QuasarAppUtils {
23
39class QUASARAPPSHARED_EXPORT Locales : public QObject
40{
41 Q_OBJECT
42public:
43
49 static bool setLocale(const QLocale &locale, bool force = false);
50
57 static bool init(const QList<QLocale> & locales,
58 const QSet<QString> & location = {});
59
66 static bool init(const QLocale &locale = QLocale::system(),
67 const QSet<QString> & location = {});
68
73 static void addLocation(const QString& location);
74
79 static Locales *instance();
80
85 static const QLocale &currentLocate();
86
94 static QString tr(const char *source, const QLocale& locale);
95
96signals:
101
102private:
103 Locales() = default;
104 ~Locales();
105
106 bool setLocalePrivate(const QLocale &locale = QLocale::system(), bool force = false, bool install = true);
107 bool initPrivate(const QLocale &locale = QLocale::system(),
108 const QSet<QString> &location = {});
109
110 bool initPrivate(const QList<QLocale> &locales,
111 const QSet<QString> &location = {});
112
113 void clearCache(const QLocale& locale);
114 void clearCache();
115
116 void removeOldTranslation(const QLocale& locale);
117
118 void addLocationPrivate(const QString& location);
119
120 const QLocale &currentLocatePrivate() const;
121
122 bool findQm(QString localePrefix,
123 QList<QTranslator *> &result);
124 bool findQmPrivate(const QString &prefix,
125 QList<QTranslator *> &qmFiles);
126 void installTranslations(QList<QTranslator *> &qmFiles);
127 QString translatePrivate(const char *source, const QLocale& locale);
128
129
130 QLocale _currentLocate;
131 QSet<QString> _locations;
132 QHash<QLocale, QList<QTranslator *>> _translations;
133
134};
135}
136
137
138#endif // LOCALES_H
The Locales class for parese local files Example :
Definition locales.h:40
void sigTranslationChanged()
sigTranslationChanged Emited when set new locale for application.
The QuasaraAppUtils class This lib include base functions for the all applications of QuasarApp group...
Definition helpdata.cpp:18
#define QUASARAPPSHARED_EXPORT