QuasarAppLib
1.0.530.c9fba11
Toggle main menu visibility
locales.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2018-2026 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
19
class
QCoreApplication;
20
class
QTranslator;
21
22
namespace
QuasarAppUtils
{
23
39
class
QUASARAPPSHARED_EXPORT
Locales :
public
QObject
40
{
41
Q_OBJECT
42
public
:
43
50
static
bool
setLocale
(
const
QLocale &locale,
bool
force =
false
);
51
58
static
bool
init
(
const
QList<QLocale> & locales,
59
const
QSet<QString> & location = {});
60
67
static
bool
init
(
const
QLocale &locale = QLocale::system(),
68
const
QSet<QString> & location = {});
69
74
static
void
addLocation
(
const
QString& location);
75
80
static
Locales *
instance
();
81
86
static
const
QLocale &
currentLocate
();
87
95
static
QString
tr
(
const
char
*source,
const
QLocale& locale);
96
97
signals:
101
void
sigTranslationChanged
();
102
103
private
:
104
Locales() =
default
;
105
~Locales();
106
114
bool
setLocalePrivate(
const
QLocale &locale = QLocale::system(),
bool
force =
false
,
bool
install =
true
);
121
bool
initPrivate(
const
QLocale &locale = QLocale::system(),
122
const
QSet<QString> &location = {});
123
130
bool
initPrivate(
const
QList<QLocale> &locales,
131
const
QSet<QString> &location = {});
132
137
void
clearCache(
const
QLocale& locale);
141
void
clearCache();
142
147
void
removeOldTranslation(
const
QLocale& locale);
148
153
void
addLocationPrivate(
const
QString& location);
154
159
const
QLocale ¤tLocatePrivate()
const
;
160
167
bool
findQm(QString localePrefix,
168
QList<QTranslator *> &result);
175
bool
findQmPrivate(
const
QString &prefix,
176
QList<QTranslator *> &qmFiles);
181
void
installTranslations(QList<QTranslator *> &qmFiles);
188
QString translatePrivate(
const
char
*source,
const
QLocale& locale);
189
191
QLocale _currentLocate;
192
194
QSet<QString> _locations;
195
197
QHash<QLocale, QList<QTranslator *>> _translations;
198
199
};
200
}
201
202
203
#endif
// LOCALES_H
QuasarAppUtils::Locales::setLocale
static bool setLocale(const QLocale &locale, bool force=false)
setLocale This method sets locale for application and loaded all translations for this locale.
Definition
locales.cpp:152
QuasarAppUtils::Locales::addLocation
static void addLocation(const QString &location)
addLocation This method add location for qm files. Use This method if you create a own library with t...
Definition
locales.cpp:237
QuasarAppUtils::Locales::tr
static QString tr(const char *source, const QLocale &locale)
tr This method will translate single string to chosen language.
Definition
locales.cpp:147
QuasarAppUtils::Locales::sigTranslationChanged
void sigTranslationChanged()
sigTranslationChanged Emitted when set new locale for application.
QuasarAppUtils::Locales::init
static bool init(const QList< QLocale > &locales, const QSet< QString > &location={})
init This method initialize translations of application.
Definition
locales.cpp:157
QuasarAppUtils::Locales::instance
static Locales * instance()
instance This method return pointer to the Locales service.
Definition
locales.cpp:218
QuasarAppUtils::Locales::currentLocate
static const QLocale & currentLocate()
currentLocate This method return current locate of applicatuon.
Definition
locales.cpp:142
QuasarAppUtils
The QuasarAppUtils namespace contains the base functions for all applications of the QuasarApp group....
Definition
crc32constexper.h:16
quasarapp_global.h
QUASARAPPSHARED_EXPORT
#define QUASARAPPSHARED_EXPORT
Definition
quasarapp_global.h:11
locales.h
Generated by
1.18.0