Skip to content

Expose hotkeys to localisation.#21588

Merged
PunkPun merged 4 commits into
OpenRA:bleedfrom
RoosterDragon:hotkeys-ftl
Oct 17, 2024
Merged

Expose hotkeys to localisation.#21588
PunkPun merged 4 commits into
OpenRA:bleedfrom
RoosterDragon:hotkeys-ftl

Conversation

@RoosterDragon

Copy link
Copy Markdown
Member

Allows the Settings > Hotkeys screen to be localised, including hotkey decriptions, groups and contexts.

The hotkey names are exposed to localisation via KeycodeExts. Hotkey modifiers are similarly exposed via ModifersExts.

The Settings > Input screen has a Zoom Modifier dropdown, which shows the localised modifier name.

The --check-yaml utility command is taught to recognise all hotkey translation, so it can validate their usage.

image

image

Comment thread mods/common/hotkeys/chat.yaml Outdated
Comment thread mods/cnc/hotkeys.yaml Outdated
Comment thread mods/common/languages/en.ftl
Comment thread OpenRA.Game/Input/IInputHandler.cs
Comment thread mods/common/hotkeys/chat.yaml Outdated
Comment thread mods/common/hotkeys/chat.yaml Outdated
ret = (Platform.CurrentPlatform == PlatformType.OSX ? "Cmd + " : "Meta + ") + ret;
ret = $"{ModifiersExts.DisplayString(Modifiers.Meta)} + {ret}";

return ret;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should really be called only once and cached . Key is a readonly value

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that's a worthwhile trade. Caching it would be an expense for callers the create a Hotkey but never call DisplayString - and there's not many callers of DisplayString.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to keep keys in memory at all, so I dunno if it's a tradeoff

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand your comment.

Comment thread OpenRA.Game/Input/Keycode.cs Outdated
return k.ToString();

return ret;
return TranslationProvider.GetString(translationKey);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be cached, this is only used in Hotkey so might be better to move it there for LoB

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As previous

Comment thread OpenRA.Mods.Common/Lint/CheckTranslationReference.cs Outdated
@RoosterDragon RoosterDragon force-pushed the hotkeys-ftl branch 4 times, most recently from 27f045d to a271d3b Compare October 8, 2024 16:33

@PunkPun PunkPun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like we are repeating lint errors

Screenshot 2024-10-12 at 13 51 51

could these be deduplicated?

Allows the Settings > Hotkeys screen to be localised, including hotkey decriptions, groups and contexts.

The hotkey names are exposed to localisation via KeycodeExts. Hotkey modifiers are similarly exposed via ModifersExts.

The Settings > Input screen has a Zoom Modifier dropdown, which shows the localised modifier name.

The --check-yaml utility command is taught to recognise all hotkey translation, so it can validate their usage.
@RoosterDragon

Copy link
Copy Markdown
Member Author

They're not duplicates - the message just isn't providing all the detail. I have pushed a commit which provides more detail in the message:
image

@PunkPun PunkPun merged commit ef1390b into OpenRA:bleed Oct 17, 2024
@PunkPun

PunkPun commented Oct 17, 2024

Copy link
Copy Markdown
Member

changelog

@RoosterDragon RoosterDragon deleted the hotkeys-ftl branch October 17, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants