Translation of keyboard shortcuts does not change when language is switched
Original Reporter info from Mantis: wp @wpam
-
Reporter name:
Original Reporter info from Mantis: wp @wpam
- Reporter name:
Description:
Keyboard shortcuts can be assigned to the items of a menu and are displayed at the right side of the menu caption, e.g. "Ctrl+O".
When i18n is used and the language of an application changes the modifier names are never translated although translations are contained within the lclstrconsts file.
The problem is that the combined menu item text, consisting of item caption and shortcut name, uses the function "ShortcutToText, and this initializes the list of key names only once in the procedure "InitializeMenuKeyCaps" (in unit "LCLProc"). There is a variable "MenuKeyCapsInited" which is set to true once this procedure has been executed and cannot be changed back because the variable is declared within the implementation part of the unit.
I would propose to declare "MenuKeyCapsInited" in the interface part of the unit and to reset it in the "LCLTranslator" unit whenever the language changes (-> see patch "accelerator-keys")
Steps to reproduce:
Run attached demo which contains English and German translation files along with the corresponding copy of the lclstrconsts po files.
The main menu has several short-cuts which are shown when the "File" menu is opened.
The demo opens with English translation, the accelerator keys are displayed as "Ctrl" and "Shift"
When the language is switched to German, the accelerator keys are still "Ctrl" and "Shift" - they should be "Strg" and "Umsch".
On the other hand, when the appliation starts with German (by replacing the const "DEFAULT_LANG = 'en'" with "DEFAULT_LANG = 'de'") the accelerator keys are in German but do not change back to English any more when the language is switched to English.
The provided patch fixes the issue.
Mantis conversion info:
- Mantis ID: 34045
- Version: 1.9 (SVN)
- Fixed in version: 1.10
- Fixed in revision: 58661 (#2afa0403)