Skip to content

Localization

zufuliu edited this page Oct 26, 2024 · 58 revisions

Localization Steps

Localization Steps for Self Build

  • 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
  • [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.

Localize Lexer and Style Names

  • [Optional] enable NP2_ENABLE_LOCALIZE_LEXER_NAME and/or NP2_ENABLE_LOCALIZE_STYLE_NAME (in config.h), add string table for lexers and styles with corresponding resource ID like NP2LEX_CPP (in EditLexer.h) or NP2STYLE_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

Format Specifiers

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.

Locale Dependent

  • 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.

Available Localization

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.