MCPcopy Create free account
hub / github.com/KDAB/GammaRay / readLocalized

Function readLocalized

common/plugininfo.cpp:90–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

88}
89
90static QString readLocalized(const QLocale &locale, const QJsonObject &obj, const QString &baseKey)
91{
92 const QString qtcLanguage = qApp->property("qtc_locale").toString();
93 QStringList names = locale.uiLanguages();
94 if (!qtcLanguage.isEmpty())
95 names.prepend(qtcLanguage);
96
97 for (auto name : std::as_const(names)) {
98 const QLocale uiLocale(name);
99
100 // We are natively English, skip...
101 if (uiLocale.language() == QLocale::English || uiLocale.language() == QLocale::C) {
102 return obj.value(baseKey).toString();
103 }
104
105 // Check against name
106 QString key = baseKey + '[' + name + ']';
107 auto it = obj.find(key);
108
109 // Check against language
110 if (it == obj.end()) {
111 name.replace('-', '_');
112 name = name.section(QLatin1Char('_'), 0, -2);
113 if (!name.isEmpty()) {
114 key = baseKey + '[' + name + ']';
115 it = obj.find(key);
116 }
117 }
118
119 if (it != obj.end())
120 return it.value().toString();
121 }
122
123 return obj.value(baseKey).toString();
124}
125
126bool PluginInfo::isStatic() const
127{

Callers 1

initFromJSONMethod · 0.85

Calls 4

endMethod · 0.80
propertyMethod · 0.45
isEmptyMethod · 0.45
valueMethod · 0.45

Tested by

no test coverage detected