Commit f2e16d59 authored by Volker Krause's avatar Volker Krause
Browse files

Port static message tables from I18N_NOOP to KLazyLocalizedString

parent 16b5edef
Pipeline #119787 passed with stage
in 57 seconds
......@@ -12,7 +12,7 @@ project(KOSMIndoorMap VERSION ${RELEASE_SERVICE_VERSION})
option(BUILD_STANDALONE_APP "Build and install the stand-alone test/demo app." OFF)
find_package(ECM 5.85 REQUIRED NO_MODULE)
find_package(ECM 5.89 REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH} ${ECM_KDE_MODULE_DIR})
include(KDECompilerSettings NO_POLICY_SCOPE)
......
......@@ -492,7 +492,7 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
if ((*it).isEmpty() || (*it) == "yes" || (*it) == "vending_machine") {
continue;
}
out.push_back(translateValue((*it).constData(), amenity_map, "OSM::amenity/shop"));
out.push_back(translateValue((*it).constData(), amenity_map));
}
std::sort(out.begin(), out.end());
......@@ -512,13 +512,13 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
}
return QLocale().createSeparatedList(l);
}
case Cuisine: return translateValues(m_element.tagValue("cuisine"), cuisine_map, "OSM::cuisine");
case Cuisine: return translateValues(m_element.tagValue("cuisine"), cuisine_map);
case Diet:
{
QStringList l;
for (const auto &d : diet_type_map) {
const auto v = m_element.tagValue(d.keyName);
const auto label = i18nc("OSM::diet_type", d.label);
const auto label = d.label.toString();
if (v == "yes") {
l.push_back(label);
} else if (v == "only") {
......@@ -539,7 +539,7 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
continue;
}
auto s = i18nc("OSM::charging_station_socket", socket.label);
auto s = socket.label.toString();
QStringList details;
if (value != "yes") {
......@@ -628,11 +628,11 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
if (v.isEmpty() || v == "no") {
continue;
}
l.push_back(i18nc("OSM::charging_station_authentication", auth.label));
l.push_back(auth.label.toString());
}
return QLocale().createSeparatedList(l);
}
case BicycleParking: return translateValues(m_element.tagValue("bicycle_parking"), bicycle_parking_map, "OSM::bicycle_parking");
case BicycleParking: return translateValues(m_element.tagValue("bicycle_parking"), bicycle_parking_map);
case Capacity: return QString::fromUtf8(m_element.tagValue("capacity"));
case CapacityDisabled: return capacitryValue("capacity:disabled");
case CapacityWomen: return capacitryValue("capacity:women");
......@@ -679,7 +679,7 @@ QVariant OSMElementInformationModel::valueForKey(Info info) const
} else {
wheelchair = m_element.tagValue("wheelchair");
}
const auto a = translateValue(wheelchair.constData(), wheelchair_map, "OSM::wheelchair_access");
const auto a = translateValue(wheelchair.constData(), wheelchair_map);
const auto d = QString::fromUtf8(m_element.tagValue("wheelchair:description", QLocale()));
if (!d.isEmpty()) {
return QString(a + QLatin1String(" (") + d + QLatin1Char(')'));
......@@ -746,7 +746,7 @@ QString OSMElementInformationModel::paymentMethodList(OSMElementInformationModel
continue;
}
if (m_element.tagValue(payment.keyName) == "yes") {
l.push_back(i18nc("OSM::payment_method", payment.label));
l.push_back(payment.label.toString());
}
}
std::sort(l.begin(), l.end());
......
......@@ -8,6 +8,7 @@
#define KOSMINDOORMAP_OSMELEMENTINFORMATIONMODEL_P_H
#include <KLocalizedString>
#include <KLazyLocalizedString>
#include <QCoreApplication>
#include <QLocale>
......@@ -20,7 +21,7 @@ namespace KOSMIndoorMap {
struct ValueMapEntry
{
const char *keyName;
const char *label;
const KLazyLocalizedString label;
};
template <typename MapEntry, std::size_t N>
......@@ -37,7 +38,7 @@ inline constexpr bool isSortedLookupTable(const MapEntry(&map)[N])
}
template <typename MapEntry, std::size_t N>
inline QString translateValue(const char *keyName, const MapEntry(&map)[N], const char *context)
inline QString translateValue(const char *keyName, const MapEntry(&map)[N])
{
const auto it = std::lower_bound(std::begin(map), std::end(map), keyName, [](const auto &lhs, auto rhs) {
return std::strcmp(lhs.keyName, rhs) < 0;
......@@ -46,17 +47,17 @@ inline QString translateValue(const char *keyName, const MapEntry(&map)[N], cons
return QString::fromUtf8(keyName);
}
return i18nc(context, (*it).label);
return (*it).label.toString();
}
template <typename MapEntry, std::size_t N>
inline QString translateValues(const QByteArray &values, const MapEntry(&map)[N], const char *context)
inline QString translateValues(const QByteArray &values, const MapEntry(&map)[N])
{
const auto l = values.split(';');
QStringList out;
out.reserve(l.size());
for (const auto &value : l) {
const auto s = translateValue(value.constData(), map, context);
const auto s = translateValue(value.constData(), map);
if (!s.isEmpty()) {
out.push_back(s);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment