In v1.92+ with an updated backend, glyph ranges are handled dynamically
and do not need to be specified. Remove GetGlyphRangesChineseSimplifiedCommon(),
the zh_label_ranges English stub, and the explicit SizePixels on AddFontDefault()
that was added to work around the ImplicitRefSize assertion. Use plain
MergeMode instead.
misc/ already hosts optional supplemental modules (cpp/imgui_stdlib,
freetype/, fonts/). i18n fits the same pattern: opt-in, not part of
the core library. Update all include paths, Makefile, Xcode project
and README accordingly.
- Do not translate 'Hello, world!' (universally recognized programming example)
- Do not translate 'This is some useful text.' (standard example boilerplate)
- Do not translate 'float' / 'counter = %d' (C++ type/variable labels)
- Keep 'blah blah blah' as-is (intentional nonsense filler, not real content)
- Keep 'dear imgui' brand name untranslated in greeting message
- Fix 'Another bullet point' -> 正确翻译为项目符号而非叶节点
- Fix 'Metrics/Debugger' -> 指标/调试器 (Metrics = indicators, not performance)
- Remove redundant identity entries for API function names (IsItemXxx etc.)
- Wrap RebuildFonts(), g_need_font_rebuild, and font rebuild calls in
#ifdef IMGUI_DEMO_ENABLE_I18N so main.mm compiles cleanly without i18n
- Include imgui_i18n.h unconditionally (provides no-op Tr() stub when
IMGUI_DEMO_ENABLE_I18N is not defined, enabling Tr() in the demo window)
- Remove IMGUI_DEMO_ENABLE_I18N and i18n sources from iOS Xcode target
(untested on iOS; macOS-only system font paths would not work on device)
Add imgui_i18n.cpp and locale/zh_CN.cpp to both iOS and macOS targets.
Set IMGUI_DEMO_ENABLE_I18N=1 in GCC_PREPROCESSOR_DEFINITIONS for all
four build configurations (iOS/macOS × Debug/Release).
- imgui_demo.cpp: wrap all user-visible string literals with Tr(); add
Language menu in DemoWindowMenuBar (guarded by IMGUI_DEMO_ENABLE_I18N);
guard extern g_need_font_rebuild with IMGUI_DEMO_ENABLE_I18N + __APPLE__
- examples/example_apple_metal/main.mm: CJK font loading via RebuildFonts()
(always loads 2-glyph stub in English, full range in zh_CN); Language menu
triggers font atlas rebuild before next NewFrame(); wrap demo window strings
with Tr(); fix v1.92 ImplicitRefSize assertion by passing explicit SizePixels
to AddFontDefault()
- examples/example_apple_metal/Makefile: add i18n sources and
-DIMGUI_DEMO_ENABLE_I18N flag
- Add i18n/ module: imgui_i18n.h (Tr() macro + stub when disabled),
imgui_i18n.cpp (lookup table, Meyers singleton, placeholder substitution),
locale/zh_CN.cpp (Simplified Chinese translation table),
tools/extract_strings.py (helper to extract translatable strings)
- Opt-in via IMGUI_DEMO_ENABLE_I18N build flag; without it Tr(s) expands
to (s) at compile time with zero overhead and no extra dependencies
- See i18n/README.md for integration guide and how to add a new language
Inverting the pattern means that for our typical 3x3 grid we don't need to draw 1+4 rounded rectangles, only 1.
This also fix the slightly rounding mismatch when switching from a=255 to a<255 paths.