This branch moves the translation logic out of the DevicePlugin into the JsonRpc layers (JsonRpcHandlers and Rest handlers) and deprecates the Configuration.SetLanguage method call. Instead it adds a "locale" property in the JSONRPC.Hello message. This will allow multiple clients to connect to a single core using different languages.
34 lines
692 B
C++
34 lines
692 B
C++
#ifndef TRANSLATOR_H
|
|
#define TRANSLATOR_H
|
|
|
|
#include "typeutils.h"
|
|
#include "types/deviceclass.h"
|
|
|
|
#include <QTranslator>
|
|
|
|
class DevicePlugin;
|
|
class DeviceManager;
|
|
|
|
class Translator
|
|
{
|
|
public:
|
|
Translator(DeviceManager *deviceManager);
|
|
~Translator();
|
|
|
|
QString translate(const PluginId &pluginId, const QString &string, const QLocale &locale);
|
|
|
|
private:
|
|
void loadTranslator(DevicePlugin *plugin, const QLocale &locale);
|
|
|
|
private:
|
|
DeviceManager *m_deviceManager = nullptr;
|
|
|
|
struct TranslatorContext {
|
|
PluginId pluginId;
|
|
QHash<QLocale, QTranslator*> translators;
|
|
};
|
|
QHash<PluginId, TranslatorContext> m_translatorContexts;
|
|
};
|
|
|
|
#endif // TRANSLATOR_H
|