From e048f834205f022ac8be68060239a7596abad5f8 Mon Sep 17 00:00:00 2001 From: Don Ho Date: Tue, 11 Jan 2022 05:11:13 +0100 Subject: [PATCH] Make menu folders on context menu translatable Make the following context menu items translatable: 1. "Style all occurrences of token" 2. "Style one token" 3. "Clear style" 4. "Plugin commands" Note for translators: to test your translation, you have to replace the old "contextMenu.xml" with the new one (modified in this commit). Fix partially #8972 Fix #9713, close #11031 --- PowerEditor/installer/nativeLang/english.xml | 4 ++ PowerEditor/installer/nativeLang/french.xml | 4 ++ .../nativeLang/taiwaneseMandarin.xml | 4 ++ PowerEditor/src/Parameters.cpp | 13 +++++-- PowerEditor/src/contextMenu.xml | 39 ++++++++++--------- 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/PowerEditor/installer/nativeLang/english.xml b/PowerEditor/installer/nativeLang/english.xml index 68cf39a55..0ccbe551f 100644 --- a/PowerEditor/installer/nativeLang/english.xml +++ b/PowerEditor/installer/nativeLang/english.xml @@ -1506,6 +1506,10 @@ Find in all files but exclude all folders log or logs recursively: + + + + diff --git a/PowerEditor/installer/nativeLang/french.xml b/PowerEditor/installer/nativeLang/french.xml index 15b014ab5..9d7b7bc01 100644 --- a/PowerEditor/installer/nativeLang/french.xml +++ b/PowerEditor/installer/nativeLang/french.xml @@ -1460,6 +1460,10 @@ Rechercher dans tous les fichiers mais pas dans les dossiers log ou logs récurs + + + + diff --git a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml index 74515187f..f0cccebeb 100644 --- a/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml +++ b/PowerEditor/installer/nativeLang/taiwaneseMandarin.xml @@ -1453,6 +1453,10 @@ + + + + diff --git a/PowerEditor/src/Parameters.cpp b/PowerEditor/src/Parameters.cpp index db1539077..ccf3dba40 100644 --- a/PowerEditor/src/Parameters.cpp +++ b/PowerEditor/src/Parameters.cpp @@ -2018,6 +2018,7 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU plugins return false; WcharMbcsConvertor& wmc = WcharMbcsConvertor::getInstance(); + NativeLangSpeaker* pNativeSpeaker = (NppParameters::getInstance()).getNativeLangSpeaker(); TiXmlNodeA *contextMenuRoot = root->FirstChildElement("ScintillaContextMenu"); if (contextMenuRoot) @@ -2026,13 +2027,19 @@ bool NppParameters::getContextMenuFromXmlTree(HMENU mainMenuHadle, HMENU plugins childNode ; childNode = childNode->NextSibling("Item") ) { - const char *folderNameA = (childNode->ToElement())->Attribute("FolderName"); + const char *folderNameDefaultA = (childNode->ToElement())->Attribute("FolderName"); + const char *folderNameTranslateID_A = (childNode->ToElement())->Attribute("TranslateID"); const char *displayAsA = (childNode->ToElement())->Attribute("ItemNameAs"); generic_string folderName; generic_string displayAs; - folderName = folderNameA?wmc.char2wchar(folderNameA, SC_CP_UTF8):TEXT(""); - displayAs = displayAsA?wmc.char2wchar(displayAsA, SC_CP_UTF8):TEXT(""); + folderName = folderNameDefaultA ? wmc.char2wchar(folderNameDefaultA, SC_CP_UTF8) : TEXT(""); + displayAs = displayAsA ? wmc.char2wchar(displayAsA, SC_CP_UTF8) : TEXT(""); + + if (folderNameTranslateID_A) + { + folderName = pNativeSpeaker->getLocalizedStrFromID(folderNameTranslateID_A, folderName); + } int id; const char *idStr = (childNode->ToElement())->Attribute("id", &id); diff --git a/PowerEditor/src/contextMenu.xml b/PowerEditor/src/contextMenu.xml index ec0eb44dd..58f31c081 100644 --- a/PowerEditor/src/contextMenu.xml +++ b/PowerEditor/src/contextMenu.xml @@ -29,38 +29,39 @@ https://npp-user-manual.org/docs/config-files/#the-context-menu-contextmenu-xml Use FolderName (optional) to create sub-menu. FolderName can be used in any type of item. FolderName value can be in any language. + TranslateID is for translating FolderName's value. If you create your FolderName, don't add TranslateID. --> - - - - - + + + + + - - - - - + + + + + - - - - - - + + + + + + - - + + - +