@@ -240,18 +240,33 @@ void DesktopFileAMParser::updateActions()
240240 auto actionNames = m_applicationInterface->actionName ();
241241
242242 for (auto action : actions) {
243- auto localeName = actionNames.value (action). value (currentLanguageCode );
243+ auto localeName = getLocaleName (currentLanguageCode, actionNames.value (action));
244244 auto fallbackDefaultName = actionNames.value (action).value (DEFAULT_KEY);
245245 m_actions.append ({action, localeName.isEmpty () ? fallbackDefaultName : localeName});
246246 }
247247}
248248
249+ QString DesktopFileAMParser::getLocaleName (const QString& currentLanguageCode,const QStringMap& names)
250+ {
251+ auto localeName = names.value (currentLanguageCode);
252+ if (currentLanguageCode.contains (' _' ) &&
253+ !(names.contains (currentLanguageCode)))
254+ {
255+ auto prefix = currentLanguageCode.split (' _' )[0 ];
256+ if (names.contains (prefix)){
257+ localeName =names.value (prefix);
258+ }
259+ }
260+ return localeName;
261+ }
262+
249263void DesktopFileAMParser::updateLocalName ()
250264{
251265 QString currentLanguageCode = QLocale::system ().name ();
252266 auto names = m_applicationInterface->name ();
253- auto localeName = names. value (currentLanguageCode);
267+ auto localeName = getLocaleName (currentLanguageCode,names );
254268 auto fallbackName = names.value (DEFAULT_KEY);
269+
255270 m_name = localeName.isEmpty () ? fallbackName : localeName;
256271}
257272
@@ -264,8 +279,9 @@ void DesktopFileAMParser::updateLocalGenericName()
264279{
265280 QString currentLanguageCode = QLocale::system ().name ();
266281 auto genericNames = m_applicationInterface->genericName ();
267- auto localeGenericName = genericNames. value (currentLanguageCode);
282+ auto localeGenericName = getLocaleName (currentLanguageCode,genericNames );
268283 auto fallBackGenericName = genericNames.value (DEFAULT_KEY);
284+
269285 m_genericName = localeGenericName.isEmpty () ? fallBackGenericName : localeGenericName;
270286}
271287
0 commit comments