-
Notifications
You must be signed in to change notification settings - Fork 212
Localization
zufuliu edited this page Oct 26, 2024
·
58 revisions
- Please open a new issue when you want to localize for a new language, I will add required files for you, or you can add these files directly by using https://github.com/zufuliu/notepad4/tree/main/locale/Locale.py with command
python Locale.py new <locale-name>
where<locale-name>
is locale name for the language, such asfr
(French),pt-BR
(Portuguese - Brazil), etc. - If you have knowledge about Windows Resource Files, clone this repository locally (or download Notepad4.rc and matepath.rc directly from https://github.com/zufuliu/notepad4/tree/main/locale folder). After translated strings in resource files, open a pull request or attach translated files to the issue.
- Else, you can use https://github.com/zufuliu/notepad4/tree/main/locale/Locale.py to extract resource strings (with command
python Locale.py string
), then translate extracted string files (please don't translate escape sequence and format specifiers).
- Read how to Build Notepad4 and matepath.
- Read the document for Resource Files.
- 🙏 [Recommend] Set
NP2_ENABLE_APP_LOCALIZATION_DLL
(in config.h) to 1 to enable using external localized resource DLLs. - Change language
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
to target language. - DON'T change the code page (
#pragma code_page(65001)
) to target code page like#pragma code_page(1252)
. The file MUST be saved in UTF-8 (without BOM). Some notes:- Visual C++'s rc.exe supports ANSI, UTF-8 (without BOM), UTF-16LE (with BOM), while GCC's windres.exe supports ANSI, UTF-8 (with or without BOM). For portable reason, it's not suggested to save file in ANSI encoding.
- When building with MSYS2's Clang with LTO, resource files MUST be compiled (by
windres.exe
) with--output-format=res
flag.
-
[Optional] Localize Version Information Resource: Notepad4.ver and matepath.ver
- Localize hard-coded string in version.h
- Change
0x409
inVALUE "Translation", 0x409, 1200
to target language ID found on https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource; - Change
0409
inBLOCK "040904b0"
to target language ID without0x
prefix.
-
[Optional] you can enable
NP2_ENABLE_CUSTOMIZE_TOOLBAR_LABELS
(in config.h), but I think it's not useful for localized program. - After translated all strings, build and test each program, ensure translated strings not been truncated. You may need to re-translate those long strings or adjust UI control's width.
- Fix bugs you found. It's better to make an issue when you find a bug.
-
[Optional] enable
NP2_ENABLE_LOCALIZE_LEXER_NAME
and/orNP2_ENABLE_LOCALIZE_STYLE_NAME
(in config.h), add string table for lexers and styles with corresponding resource ID likeNP2LEX_CPP
(in EditLexer.h) orNP2STYLE_Keyword
(in EditStyle.h). EditLexer.h contains all lexer name, EditStyleX.h contains all style name.
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#include "EditLexer.h" // resource ID for lexers
#include "EditLexers/EditStyle.h" // resource ID for styles
STRINGTABLE
BEGIN
// string table for lexers, see EditLexer.h
NP2LEX_TEXTFILE "Text File"
NP2LEX_CPP "C/C++ Source"
// others
NP2LEX_2NDTEXTFILE "2nd Text File"
NP2LEX_ANSI "ANSI Art"
NP2LEX_GLOBAL "Global Styles"
// string table for styles, see EditLexers/EditStyleX.h
NP2STYLE_MarginLineNumber "Margin and Line Number"
// others
NP2STYLE_CallTip "CallTip"
NP2STYLE_Default "Default"
NP2STYLE_Comment "Comment"
NP2STYLE_Keyword "Keyword"
// others
END
String like %d
or %s
are format specifiers, don't translate them. Exchange order of format specifiers will need to change corresponding code that use the string, otherwise program may crash or produce undesired result.
- Localization for Arabic and Hebrew may need re-layout all dialogs.
- Change some keyboard bindings according to the keyboard layout used in target locale.
- Enable some locale-dependent settings by default. e.g.:
- Localization for Korean may change default caret style to line width 2 instead of line width 1.
- Localization for Arabic and Hebrew need to add code to automatically enable bidirectional or RTL layout.
After you localized Notepad4 and/or matepath, you can make a new issue to add link for your localization to here and in readme.md.
- Deutsch at https://github.com/zufuliu/notepad4/tree/main/locale/de
- French at https://github.com/zufuliu/notepad4/tree/main/locale/fr
- Italiano at https://github.com/zufuliu/notepad4/tree/main/locale/it
- Русский at https://github.com/zufuliu/notepad4/tree/main/locale/ru
- 日本語 at https://github.com/zufuliu/notepad4/tree/main/locale/ja
- 中文 (简体) at https://github.com/zufuliu/notepad4/tree/main/locale/zh-Hans
- 中文 (繁體) at https://github.com/zufuliu/notepad4/tree/main/locale/zh-Hant
- 한국어 at https://github.com/zufuliu/notepad4/tree/main/locale/ko
- 한국어 at https://teus.me/Notepad4