Skip to content

Commit 2fe3b01

Browse files
committed
fix: Change the translation language of the application in dock #1100
Configure name retrieval in three levels fix-Bug-translation
1 parent 123fdb4 commit 2fe3b01

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

panels/dock/taskmanager/desktopfileamparser.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,17 +240,41 @@ void DesktopFileAMParser::updateActions()
240240
auto actionNames = m_applicationInterface->actionName();
241241

242242
for (auto action : actions) {
243+
<<<<<<< HEAD
243244
auto localeName = actionNames.value(action).value(currentLanguageCode);
245+
=======
246+
auto localeName = getLocaleName(currentLanguageCode, actionNames.value(action));
247+
>>>>>>> 69273dc (fix: Change the translation language of the application in dock #1100)
244248
auto fallbackDefaultName = actionNames.value(action).value(DEFAULT_KEY);
245249
m_actions.append({action, localeName.isEmpty() ? fallbackDefaultName : localeName});
246250
}
247251
}
248252

253+
<<<<<<< HEAD
254+
=======
255+
QString DesktopFileAMParser::getLocaleName(const QString& currentLanguageCode, const QStringMap& names)
256+
{
257+
auto localeName = names.value(currentLanguageCode);
258+
if ( currentLanguageCode.contains('_') && !(names.contains(currentLanguageCode))) {
259+
{
260+
auto prefix = currentLanguageCode.split('_')[0];
261+
if (names.contains(prefix)) {
262+
localeName = names.value(prefix);
263+
}
264+
}
265+
return localeName;
266+
}
267+
268+
>>>>>>> 69273dc (fix: Change the translation language of the application in dock #1100)
249269
void DesktopFileAMParser::updateLocalName()
250270
{
251271
QString currentLanguageCode = QLocale::system().name();
252272
auto names = m_applicationInterface->name();
273+
<<<<<<< HEAD
253274
auto localeName = names.value(currentLanguageCode);
275+
=======
276+
auto localeName = getLocaleName(currentLanguageCode, names);
277+
>>>>>>> 69273dc (fix: Change the translation language of the application in dock #1100)
254278
auto fallbackName = names.value(DEFAULT_KEY);
255279
m_name = localeName.isEmpty() ? fallbackName : localeName;
256280
}
@@ -264,7 +288,11 @@ void DesktopFileAMParser::updateLocalGenericName()
264288
{
265289
QString currentLanguageCode = QLocale::system().name();
266290
auto genericNames = m_applicationInterface->genericName();
291+
<<<<<<< HEAD
267292
auto localeGenericName = genericNames.value(currentLanguageCode);
293+
=======
294+
auto localeGenericName = getLocaleName(currentLanguageCode, genericNames);
295+
>>>>>>> 69273dc (fix: Change the translation language of the application in dock #1100)
268296
auto fallBackGenericName = genericNames.value(DEFAULT_KEY);
269297
m_genericName = localeGenericName.isEmpty() ? fallBackGenericName : localeGenericName;
270298
}

panels/dock/taskmanager/desktopfileamparser.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ class DesktopFileAMParser : public DesktopfileAbstractParser
4747
QString id2dbusPath(const QString& id);
4848
void connectToAmDBusSignal(const QString& propertyName, const char* slot);
4949
void launchByAMTool(const QString &action = QString());
50+
<<<<<<< HEAD
51+
=======
52+
QString getLocaleName(const QString& currentLanguageCode, const QStringMap& names);
53+
>>>>>>> 69273dc (fix: Change the translation language of the application in dock #1100)
5054

5155
private Q_SLOTS:
5256
void updateActions();

0 commit comments

Comments
 (0)