@@ -106,11 +106,19 @@ void AMAppItem::setOnDesktop(bool on)
106106 AppItem::setOnDesktop (on);
107107}
108108
109- QString AMAppItem::getLocaleOrDefaultValue (const QStringMap &value, const QString &targetKey , const QString &fallbackKey)
109+ QString AMAppItem::getLocaleOrDefaultValue (const QStringMap &value, const QString &localeCode , const QString &fallbackKey)
110110{
111- auto targetValue = value.value (targetKey);
112- auto fallbackValue = value.value (fallbackKey);
113- return !targetValue.isEmpty () ? targetValue : fallbackValue;
111+ if (value.contains (localeCode)) {
112+ return value.value (localeCode);
113+ } else {
114+ QString fallbackValue = value.value (fallbackKey);
115+ if (localeCode.contains (' _' )) {
116+ QString prefix = localeCode.split (' _' )[0 ];
117+ return value.value (prefix, fallbackValue);
118+ } else {
119+ return fallbackValue;
120+ }
121+ }
114122}
115123
116124void AMAppItem::onPropertyChanged (const QDBusMessage &msg)
@@ -133,7 +141,7 @@ void AMAppItem::onPropertyChanged(const QDBusMessage &msg)
133141 AppItem::setAppName (name);
134142 }
135143
136- auto iconName = getLocaleOrDefaultValue ( Application::icons (), DESKTOP_ENTRY_ICON_KEY, " " );
144+ auto iconName = Application::icons (). value ( DESKTOP_ENTRY_ICON_KEY);
137145 AppItem::setAppIconName (iconName);
138146
139147 AppItem::setNoDisPlay (Application::noDisplay ());
@@ -160,7 +168,7 @@ void AMAppItem::updateActions(const QStringList &actions, const PropMap &actionN
160168 auto localeNames = actionName.value (action);
161169 QJsonObject actionObject;
162170 actionObject.insert (QStringLiteral (" id" ), action);
163- actionObject.insert (QStringLiteral (" name" ), getLocaleOrDefaultValue (localeNames, action , DEFAULT_KEY));
171+ actionObject.insert (QStringLiteral (" name" ), getLocaleOrDefaultValue (localeNames, locale , DEFAULT_KEY));
164172 actionsArray.append (actionObject);
165173 }
166174 if (actions.size () > 0 ) {
0 commit comments