[Settings][KBM]Fix "All Apps" localization (#22097)

This commit is contained in:
Jaime Bernardo 2022-11-18 15:34:17 +00:00 committed by GitHub
parent 89330986f4
commit 2a6de71767
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -386,6 +386,10 @@
<value>Shortcuts</value>
<comment>Keyboard Manager remap keyboard header</comment>
</data>
<data name="KeyboardManager_All_Apps_Description" xml:space="preserve">
<value>All Apps</value>
<comment>Should be the same as EditShortcuts_AllApps from keyboard manager editor</comment>
</data>
<data name="Shortcuts.Header" xml:space="preserve">
<value>Shortcuts</value>
</data>

View File

@ -18,6 +18,7 @@ using Microsoft.PowerToys.Settings.UI.Library.Interfaces;
using Microsoft.PowerToys.Settings.UI.Library.Utilities;
using Microsoft.PowerToys.Settings.UI.Library.ViewModels.Commands;
using Microsoft.PowerToys.Settings.Utilities;
using Windows.ApplicationModel.Resources;
namespace Microsoft.PowerToys.Settings.UI.ViewModels
{
@ -167,6 +168,17 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
public static List<AppSpecificKeysDataModel> CombineShortcutLists(List<KeysDataModel> globalShortcutList, List<AppSpecificKeysDataModel> appSpecificShortcutList)
{
string allAppsDescription = "All Apps";
try
{
ResourceLoader resourceLoader = ResourceLoader.GetForViewIndependentUse();
allAppsDescription = resourceLoader.GetString("KeyboardManager_All_Apps_Description");
}
catch (Exception ex)
{
Logger.LogError("Couldn't get translation for All Apps mention in KBM page.", ex);
}
if (globalShortcutList == null && appSpecificShortcutList == null)
{
return new List<AppSpecificKeysDataModel>();
@ -177,11 +189,11 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
}
else if (appSpecificShortcutList == null)
{
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, TargetApp = "All Apps" }).ToList();
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, TargetApp = allAppsDescription }).ToList();
}
else
{
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, TargetApp = "All Apps" }).Concat(appSpecificShortcutList).ToList();
return globalShortcutList.ConvertAll(x => new AppSpecificKeysDataModel { OriginalKeys = x.OriginalKeys, NewRemapKeys = x.NewRemapKeys, TargetApp = allAppsDescription }).Concat(appSpecificShortcutList).ToList();
}
}