Fix translating thing classes

This commit is contained in:
Michael Zanetti 2020-05-04 12:45:45 +02:00
parent 9af820b696
commit 688cde9c9c
3 changed files with 52 additions and 0 deletions

View File

@ -919,6 +919,27 @@ ParamType ThingManagerImplementation::translateParamType(const PluginId &pluginI
return translatedParamType;
}
StateType ThingManagerImplementation::translateStateType(const PluginId &pluginId, const StateType &stateType, const QLocale &locale)
{
StateType translatedStateType = stateType;
translatedStateType.setDisplayName(translate(pluginId, stateType.displayName(), locale));
return translatedStateType;
}
EventType ThingManagerImplementation::translateEventType(const PluginId &pluginId, const EventType &eventType, const QLocale &locale)
{
EventType translatedEventType = eventType;
translatedEventType.setDisplayName(translate(pluginId, eventType.displayName(), locale));
return translatedEventType;
}
ActionType ThingManagerImplementation::translateActionType(const PluginId &pluginId, const ActionType &actionType, const QLocale &locale)
{
ActionType translatedActionType = actionType;
translatedActionType.setDisplayName(translate(pluginId, actionType.displayName(), locale));
return translatedActionType;
}
ThingClass ThingManagerImplementation::translateThingClass(const ThingClass &thingClass, const QLocale &locale)
{
ThingClass translatedThingClass = thingClass;
@ -929,6 +950,31 @@ ThingClass ThingManagerImplementation::translateThingClass(const ThingClass &thi
translatedSettingsTypes.append(translateParamType(thingClass.pluginId(), paramType, locale));
}
translatedThingClass.setSettingsTypes(translatedSettingsTypes);
ParamTypes translatedParamTypes;
foreach (const ParamType &paramType, thingClass.paramTypes()) {
translatedParamTypes.append(translateParamType(thingClass.pluginId(), paramType, locale));
}
translatedThingClass.setParamTypes(translatedParamTypes);
StateTypes translatedStateTypes;
foreach (const StateType &stateType, thingClass.stateTypes()) {
translatedStateTypes.append(translateStateType(thingClass.pluginId(), stateType, locale));
}
translatedThingClass.setStateTypes(translatedStateTypes);
EventTypes translatedEventTypes;
foreach (const EventType &eventType, thingClass.eventTypes()) {
translatedEventTypes.append(translateEventType(thingClass.pluginId(), eventType, locale));
}
translatedThingClass.setEventTypes(translatedEventTypes);
ActionTypes translatedActionTypes;
foreach (const ActionType &actionType, thingClass.actionTypes()) {
translatedActionTypes.append(translateActionType(thingClass.pluginId(), actionType, locale));
}
translatedThingClass.setActionTypes(translatedActionTypes);
return translatedThingClass;
}

View File

@ -115,6 +115,9 @@ public:
QString translate(const PluginId &pluginId, const QString &string, const QLocale &locale) override;
ParamType translateParamType(const PluginId &pluginId, const ParamType &paramType, const QLocale &locale) override;
StateType translateStateType(const PluginId &pluginId, const StateType &stateType, const QLocale &locale) override;
EventType translateEventType(const PluginId &pluginId, const EventType &eventType, const QLocale &locale) override;
ActionType translateActionType(const PluginId &pluginId, const ActionType &actionType, const QLocale &locale) override;
ThingClass translateThingClass(const ThingClass &thingClass, const QLocale &locale) override;
Vendor translateVendor(const Vendor &vendor, const QLocale &locale) override;

View File

@ -91,6 +91,9 @@ public:
virtual QString translate(const PluginId &pluginId, const QString &string, const QLocale &locale) = 0;
virtual ParamType translateParamType(const PluginId &pluginId, const ParamType &paramType, const QLocale &locale) = 0;
virtual StateType translateStateType(const PluginId &pluginId, const StateType &stateType, const QLocale &locale) = 0;
virtual EventType translateEventType(const PluginId &pluginId, const EventType &eventType, const QLocale &locale) = 0;
virtual ActionType translateActionType(const PluginId &pluginId, const ActionType &actionType, const QLocale &locale) = 0;
virtual ThingClass translateThingClass(const ThingClass &thingClass, const QLocale &locale) = 0;
virtual Vendor translateVendor(const Vendor &vendor, const QLocale &locale) = 0;
signals: