Better localized strings for date/numbers, fixes #539
This commit is contained in:
@@ -111,6 +111,18 @@ namespace lms::ui
|
||||
return res;
|
||||
}
|
||||
|
||||
Wt::WLocale createLocale(const std::string& name)
|
||||
{
|
||||
Wt::WLocale locale{ name };
|
||||
locale.setDecimalPoint(Wt::WString::tr("Lms.locale.decimal-point").toUTF8());
|
||||
locale.setGroupSeparator(Wt::WString::tr("Lms.locale.group-separator").toUTF8());
|
||||
locale.setDateFormat(Wt::WString::tr("Lms.locale.date-format").toUTF8());
|
||||
locale.setTimeFormat(Wt::WString::tr("Lms.locale.time-format").toUTF8());
|
||||
locale.setDateTimeFormat(Wt::WString::tr("Lms.locale.date-time-format").toUTF8());
|
||||
|
||||
return locale;
|
||||
}
|
||||
|
||||
enum IdxRoot
|
||||
{
|
||||
IdxExplore = 0,
|
||||
@@ -274,6 +286,7 @@ namespace lms::ui
|
||||
|
||||
setTitle();
|
||||
setLocalizedStrings(getOrCreateMessageBundle());
|
||||
setLocale(createLocale(Wt::WLocale::currentLocale().name()));
|
||||
|
||||
// Handle Media Scanner events and other session events
|
||||
enableUpdates(true);
|
||||
@@ -362,7 +375,7 @@ namespace lms::ui
|
||||
|
||||
setUserInfo(userId, strongAuth);
|
||||
|
||||
LMS_LOG(UI, INFO, "User '" << getUserLoginName() << "' logged in from '" << environment().clientAddress() << "', user agent = " << environment().userAgent());
|
||||
LMS_LOG(UI, INFO, "User '" << getUserLoginName() << "' logged in from '" << environment().clientAddress() << "', user agent = " << environment().userAgent() << ", locale = '" << locale().name() << "'");
|
||||
|
||||
_appManager.registerApplication(*this);
|
||||
_appManager.applicationRegistered.connect(this, [this](LmsApplication& otherApplication) {
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <Wt/Http/Response.h>
|
||||
#include <Wt/WCheckBox.h>
|
||||
#include <Wt/WDateTime.h>
|
||||
#include <Wt/WLocale.h>
|
||||
#include <Wt/WPushButton.h>
|
||||
#include <Wt/WResource.h>
|
||||
|
||||
@@ -40,17 +41,7 @@ namespace lms::ui
|
||||
{
|
||||
std::string durationToString(const Wt::WDateTime& begin, const Wt::WDateTime& end)
|
||||
{
|
||||
const auto secs{ std::chrono::duration_cast<std::chrono::seconds>(end.toTimePoint() - begin.toTimePoint()).count() };
|
||||
|
||||
std::ostringstream oss;
|
||||
|
||||
if (secs >= 3600)
|
||||
oss << secs / 3600 << "h";
|
||||
if (secs >= 60)
|
||||
oss << std::setw(2) << std::setfill('0') << (secs % 3600) / 60 << "m";
|
||||
oss << std::setw(2) << std::setfill('0') << (secs % 60) << "s";
|
||||
|
||||
return oss.str();
|
||||
return begin.timeTo(end).toUTF8();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@@ -222,7 +213,8 @@ namespace lms::ui
|
||||
_lastScanStatus->setText(Wt::WString::tr("Lms.Admin.ScannerController.last-scan-status")
|
||||
.arg(status.lastCompleteScanStats->nbFiles())
|
||||
.arg(durationToString(status.lastCompleteScanStats->startTime, status.lastCompleteScanStats->stopTime))
|
||||
.arg(status.lastCompleteScanStats->stopTime.toString())
|
||||
.arg(status.lastCompleteScanStats->stopTime.date().toString(Wt::WLocale::currentLocale().dateFormat()))
|
||||
.arg(status.lastCompleteScanStats->stopTime.time().toString(Wt::WLocale::currentLocale().timeFormat()))
|
||||
.arg(status.lastCompleteScanStats->errors.size())
|
||||
.arg(status.lastCompleteScanStats->duplicates.size()));
|
||||
|
||||
@@ -249,7 +241,8 @@ namespace lms::ui
|
||||
|
||||
case IScannerService::State::Scheduled:
|
||||
_status->setText(Wt::WString::tr("Lms.Admin.ScannerController.status-scheduled")
|
||||
.arg(status.nextScheduledScan.toString()));
|
||||
.arg(status.nextScheduledScan.date().toString(Wt::WLocale::currentLocale().dateFormat()))
|
||||
.arg(status.nextScheduledScan.time().toString(Wt::WLocale::currentLocale().timeFormat())));
|
||||
_stepStatus->setText("");
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user