mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Fix date and time l10n
QDateTime::toString(const QString & format) uses system locale for month and day names. In order to get localized month and day names for user-choosen locale use QLocale::toString(const QDateTime & datetime, const QString & format) instead. Signed-off-by: Sergey Starosek <sergey.starosek@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
22d56889bb
commit
2a8f32b87e
1 changed files with 5 additions and 3 deletions
|
@ -50,6 +50,7 @@ const char *existing_filename;
|
||||||
static QString shortDateFormat;
|
static QString shortDateFormat;
|
||||||
static QString dateFormat;
|
static QString dateFormat;
|
||||||
static QString timeFormat;
|
static QString timeFormat;
|
||||||
|
static QLocale loc;
|
||||||
|
|
||||||
#if defined(Q_OS_WIN) && QT_VERSION < 0x050000
|
#if defined(Q_OS_WIN) && QT_VERSION < 0x050000
|
||||||
static QByteArray encodeUtf8(const QString &fname)
|
static QByteArray encodeUtf8(const QString &fname)
|
||||||
|
@ -72,10 +73,11 @@ QString uiLanguage(QLocale *callerLoc)
|
||||||
{
|
{
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup("Language");
|
s.beginGroup("Language");
|
||||||
QLocale loc;
|
|
||||||
|
|
||||||
if (!s.value("UseSystemLanguage", true).toBool()) {
|
if (!s.value("UseSystemLanguage", true).toBool()) {
|
||||||
loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString());
|
loc = QLocale(s.value("UiLanguage", QLocale().uiLanguages().first()).toString());
|
||||||
|
} else {
|
||||||
|
loc = QLocale(QLocale().uiLanguages().first());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString uiLang = loc.uiLanguages().first();
|
QString uiLang = loc.uiLanguages().first();
|
||||||
|
@ -392,14 +394,14 @@ QString get_dive_date_string(timestamp_t when)
|
||||||
{
|
{
|
||||||
QDateTime ts;
|
QDateTime ts;
|
||||||
ts.setMSecsSinceEpoch(when * 1000);
|
ts.setMSecsSinceEpoch(when * 1000);
|
||||||
return ts.toUTC().toString(dateFormat + " " + timeFormat);
|
return loc.toString(ts.toUTC(), dateFormat + " " + timeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_short_dive_date_string(timestamp_t when)
|
QString get_short_dive_date_string(timestamp_t when)
|
||||||
{
|
{
|
||||||
QDateTime ts;
|
QDateTime ts;
|
||||||
ts.setMSecsSinceEpoch(when * 1000);
|
ts.setMSecsSinceEpoch(when * 1000);
|
||||||
return ts.toUTC().toString(shortDateFormat + " " + timeFormat);
|
return loc.toString(ts.toUTC(), shortDateFormat + " " + timeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString get_trip_date_string(timestamp_t when, int nr)
|
QString get_trip_date_string(timestamp_t when, int nr)
|
||||||
|
|
Loading…
Add table
Reference in a new issue