mirror of
https://github.com/ocornut/imgui.git
synced 2026-09-27 00:13:29 +03:00
Merge 552986072a into 8c131021b0
This commit is contained in:
commit
7074c4e7df
14 changed files with 3174 additions and 729 deletions
|
|
@ -5,8 +5,10 @@ IMGUI_DIR = ../../
|
|||
SOURCES = main.mm
|
||||
SOURCES += $(IMGUI_DIR)/imgui.cpp $(IMGUI_DIR)/imgui_demo.cpp $(IMGUI_DIR)/imgui_draw.cpp $(IMGUI_DIR)/imgui_tables.cpp $(IMGUI_DIR)/imgui_widgets.cpp
|
||||
SOURCES += $(IMGUI_DIR)/backends/imgui_impl_osx.mm $(IMGUI_DIR)/backends/imgui_impl_metal.mm
|
||||
SOURCES += $(IMGUI_DIR)/misc/i18n/imgui_i18n.cpp
|
||||
SOURCES += $(IMGUI_DIR)/misc/i18n/locale/zh_CN.cpp
|
||||
|
||||
CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends
|
||||
CXXFLAGS = -std=c++11 -ObjC++ -fobjc-arc -Wall -Wextra -I$(IMGUI_DIR) -I$(IMGUI_DIR)/backends -I$(IMGUI_DIR)/misc/i18n -DIMGUI_DEMO_ENABLE_I18N
|
||||
FRAMEWORKS = -framework AppKit -framework Metal -framework MetalKit -framework QuartzCore -framework GameController
|
||||
|
||||
all: $(EXE)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
/* Begin PBXBuildFile section */
|
||||
05318E0F274C397200A8DE2E /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 05318E0E274C397200A8DE2E /* GameController.framework */; };
|
||||
A1I18N00000000000000001B /* imgui_i18n.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1I18N00000000000000F001 /* imgui_i18n.cpp */; };
|
||||
A1I18N00000000000000002B /* zh_CN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1I18N00000000000000F002 /* zh_CN.cpp */; };
|
||||
07A82ED82139413D0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 07A82ED72139413C0078D120 /* imgui_widgets.cpp */; };
|
||||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5079822D257677DB0038A28D /* imgui_tables.cpp */; };
|
||||
|
|
@ -59,6 +61,8 @@
|
|||
83BBEA0220EB54E700295997 /* imgui_demo.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_demo.cpp; path = ../../imgui_demo.cpp; sourceTree = "<group>"; };
|
||||
83BBEA0320EB54E700295997 /* imgui.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui.cpp; path = ../../imgui.cpp; sourceTree = "<group>"; };
|
||||
83BBEA0420EB54E700295997 /* imconfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = imconfig.h; path = ../../imconfig.h; sourceTree = "<group>"; };
|
||||
A1I18N00000000000000F001 /* imgui_i18n.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = imgui_i18n.cpp; path = ../../misc/i18n/imgui_i18n.cpp; sourceTree = "<group>"; };
|
||||
A1I18N00000000000000F002 /* zh_CN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = zh_CN.cpp; path = ../../misc/i18n/locale/zh_CN.cpp; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
|
|
@ -162,6 +166,8 @@
|
|||
83BBEA0120EB54E700295997 /* imgui_draw.cpp */,
|
||||
07A82ED62139413C0078D120 /* imgui_internal.h */,
|
||||
07A82ED72139413C0078D120 /* imgui_widgets.cpp */,
|
||||
A1I18N00000000000000F001 /* imgui_i18n.cpp */,
|
||||
A1I18N00000000000000F002 /* zh_CN.cpp */,
|
||||
);
|
||||
name = imgui;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -288,6 +294,8 @@
|
|||
5079822E257677DB0038A28D /* imgui_tables.cpp in Sources */,
|
||||
07A82ED92139418F0078D120 /* imgui_widgets.cpp in Sources */,
|
||||
8309BDA8253CCC080045E2A1 /* main.mm in Sources */,
|
||||
A1I18N00000000000000001B /* imgui_i18n.cpp in Sources (macOS) */,
|
||||
A1I18N00000000000000002B /* zh_CN.cpp in Sources (macOS) */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
@ -452,6 +460,10 @@
|
|||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"IMGUI_DEMO_ENABLE_I18N=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
|
@ -473,6 +485,10 @@
|
|||
COMBINE_HIDPI_IMAGES = YES;
|
||||
DEAD_CODE_STRIPPING = YES;
|
||||
DEVELOPMENT_TEAM = "";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"IMGUI_DEMO_ENABLE_I18N=1",
|
||||
"$(inherited)",
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/macOS/Info-macOS.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@
|
|||
#import <MetalKit/MetalKit.h>
|
||||
|
||||
#include "imgui.h"
|
||||
// i18n support: include unconditionally — when IMGUI_DEMO_ENABLE_I18N is not defined
|
||||
// the header provides a no-op Tr(s) stub with zero overhead.
|
||||
#include "misc/i18n/imgui_i18n.h"
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#include "imgui_impl_metal.h"
|
||||
#if TARGET_OS_OSX
|
||||
#include "imgui_impl_osx.h"
|
||||
|
|
@ -38,6 +44,36 @@
|
|||
// AppViewController
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
bool g_need_font_rebuild = false;
|
||||
|
||||
static void RebuildFonts()
|
||||
{
|
||||
ImGuiIO& io = ImGui::GetIO();
|
||||
io.Fonts->ClearFonts();
|
||||
io.Fonts->AddFontDefault();
|
||||
|
||||
// Merge a CJK font so the Language menu and translated strings render correctly.
|
||||
// In v1.92+ with an updated backend, glyph ranges are handled dynamically and do not need to be specified.
|
||||
// Hiragino Sans GB is designed for Simplified Chinese; fall back to STHeiti.
|
||||
const char* font_paths[] = {
|
||||
"/System/Library/Fonts/Hiragino Sans GB.ttc",
|
||||
"/System/Library/Fonts/STHeiti Light.ttc",
|
||||
nullptr
|
||||
};
|
||||
const char* chosen = nullptr;
|
||||
for (int i = 0; font_paths[i]; ++i) {
|
||||
if (access(font_paths[i], R_OK) == 0) { chosen = font_paths[i]; break; }
|
||||
}
|
||||
if (chosen) {
|
||||
ImFontConfig cfg;
|
||||
cfg.MergeMode = true;
|
||||
io.Fonts->AddFontFromFileTTF(chosen, 0.0f, &cfg); // 0.0f = implicit ref size, matches AddFontDefault()
|
||||
}
|
||||
io.Fonts->Build();
|
||||
}
|
||||
#endif // IMGUI_DEMO_ENABLE_I18N
|
||||
|
||||
@implementation AppViewController
|
||||
|
||||
-(instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil
|
||||
|
|
@ -110,6 +146,11 @@
|
|||
ImGui_ImplOSX_Init(self.view);
|
||||
[NSApp activateIgnoringOtherApps:YES];
|
||||
#endif
|
||||
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
// Build initial font atlas with CJK glyphs so the Language menu renders correctly from the start.
|
||||
RebuildFonts();
|
||||
#endif
|
||||
}
|
||||
|
||||
-(void)drawInMTKView:(MTKView*)view
|
||||
|
|
@ -134,6 +175,14 @@
|
|||
return;
|
||||
}
|
||||
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
// Rebuild font atlas after language switch (must be before NewFrame to avoid use-after-free).
|
||||
if (g_need_font_rebuild) {
|
||||
g_need_font_rebuild = false;
|
||||
RebuildFonts();
|
||||
}
|
||||
#endif
|
||||
|
||||
// Start the Dear ImGui frame
|
||||
ImGui_ImplMetal_NewFrame(renderPassDescriptor);
|
||||
#if TARGET_OS_OSX
|
||||
|
|
@ -155,30 +204,31 @@
|
|||
static float f = 0.0f;
|
||||
static int counter = 0;
|
||||
|
||||
ImGui::Begin("Hello, world!"); // Create a window called "Hello, world!" and append into it.
|
||||
// "Hello, world!" is the canonical ImGui getting-started window title — kept in English.
|
||||
ImGui::Begin("Hello, world!");
|
||||
|
||||
ImGui::Text("This is some useful text."); // Display some text (you can use a format strings too)
|
||||
ImGui::Checkbox("Demo Window", &show_demo_window); // Edit bools storing our window open/close state
|
||||
ImGui::Checkbox("Another Window", &show_another_window);
|
||||
ImGui::Text("This is some useful text."); // standard example text, kept in English
|
||||
ImGui::Checkbox(Tr("Demo Window"), &show_demo_window);
|
||||
ImGui::Checkbox(Tr("Another Window"), &show_another_window);
|
||||
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // Edit 1 float using a slider from 0.0f to 1.0f
|
||||
ImGui::ColorEdit3("clear color", (float*)&clear_color); // Edit 3 floats representing a color
|
||||
ImGui::SliderFloat("float", &f, 0.0f, 1.0f); // "float" labels the C++ type, not translated
|
||||
ImGui::ColorEdit3(Tr("clear color"), (float*)&clear_color);
|
||||
|
||||
if (ImGui::Button("Button")) // Buttons return true when clicked (most widgets return true when edited/activated)
|
||||
if (ImGui::Button(Tr("Button")))
|
||||
counter++;
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", counter);
|
||||
ImGui::Text("counter = %d", counter); // variable name, not translated
|
||||
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)", 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::Text(Tr("Application average %.3f ms/frame (%.1f FPS)"), 1000.0f / io.Framerate, io.Framerate);
|
||||
ImGui::End();
|
||||
}
|
||||
|
||||
// 3. Show another simple window.
|
||||
if (show_another_window)
|
||||
{
|
||||
ImGui::Begin("Another Window", &show_another_window); // Pass a pointer to our bool variable (the window will have a closing button that will clear the bool when clicked)
|
||||
ImGui::Text("Hello from another window!");
|
||||
if (ImGui::Button("Close Me"))
|
||||
ImGui::Begin(Tr("Another Window"), &show_another_window);
|
||||
ImGui::Text("%s", Tr("Hello from another window!"));
|
||||
if (ImGui::Button(Tr("Close Me")))
|
||||
show_another_window = false;
|
||||
ImGui::End();
|
||||
}
|
||||
|
|
|
|||
206
i18n/README.md
Normal file
206
i18n/README.md
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
# Dear ImGui — i18n (Internationalization)
|
||||
|
||||
Runtime language switching for `imgui_demo.cpp`.
|
||||
Currently ships with **Simplified Chinese** (`zh_CN`).
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
| Component | Role |
|
||||
|-----------|------|
|
||||
| `imgui_i18n.h` | `Tr()` macro + namespace declaration |
|
||||
| `imgui_i18n.cpp` | Lookup table, fallback, `$1`/`$2` placeholder substitution |
|
||||
| `locale/zh_CN.cpp` | Chinese translation table (static initializer, auto-registered) |
|
||||
| `tools/extract_strings.py` | Helper to extract translatable strings from a source range |
|
||||
|
||||
Every user-visible string literal in `imgui_demo.cpp` is wrapped with `Tr("...")`.
|
||||
`Tr()` looks up the active locale table and returns the translated string, or falls back to the original English if no translation exists.
|
||||
|
||||
### Opt-in build flag
|
||||
|
||||
Define **`IMGUI_DEMO_ENABLE_I18N`** in your build to activate i18n.
|
||||
Without it, `Tr(s)` expands to `(s)` at compile time — zero overhead, no extra files needed.
|
||||
|
||||
---
|
||||
|
||||
## Quick Start (macOS example_apple_metal)
|
||||
|
||||
```bash
|
||||
# Makefile already includes IMGUI_DEMO_ENABLE_I18N and the i18n sources.
|
||||
cd examples/example_apple_metal
|
||||
make && ./example_apple_metal
|
||||
# Open the Language menu in the demo window menu bar → switch to 中文
|
||||
```
|
||||
|
||||
For other platforms/examples, see **Integrating into Your Build** below.
|
||||
|
||||
---
|
||||
|
||||
## Adding a New Language
|
||||
|
||||
### 1. Create a locale file
|
||||
|
||||
Copy `locale/zh_CN.cpp` to `locale/<locale_id>.cpp` (e.g. `locale/ja_JP.cpp`).
|
||||
|
||||
```cpp
|
||||
// locale/ja_JP.cpp
|
||||
#include "../imgui_i18n.h"
|
||||
|
||||
namespace {
|
||||
struct JaJPRegistrar {
|
||||
JaJPRegistrar() {
|
||||
imgui_i18n::registerLocale("ja_JP", {
|
||||
{"Configuration", "設定"},
|
||||
{"Dear ImGui Demo","Dear ImGui デモ"},
|
||||
// ... add all entries
|
||||
});
|
||||
}
|
||||
} s_ja_jp;
|
||||
} // namespace
|
||||
```
|
||||
|
||||
**Key rules:**
|
||||
- The **key** is the exact English string as it appears in `imgui_demo.cpp` (including punctuation and newlines).
|
||||
- Missing keys automatically fall back to English — you can ship a partial translation.
|
||||
- For strings containing `##` (ImGui internal IDs like `"Configuration##2"`), the key in the table is only the visible part (`"Configuration"`); the `##2` suffix is appended in code.
|
||||
|
||||
### 2. Add the locale file to your build
|
||||
|
||||
**Makefile (Linux/macOS):**
|
||||
```makefile
|
||||
SOURCES += $(IMGUI_DIR)/i18n/imgui_i18n.cpp
|
||||
SOURCES += $(IMGUI_DIR)/i18n/locale/ja_JP.cpp # add your new locale
|
||||
CXXFLAGS += -I$(IMGUI_DIR)/i18n -DIMGUI_DEMO_ENABLE_I18N
|
||||
```
|
||||
|
||||
**CMake:**
|
||||
```cmake
|
||||
target_sources(my_app PRIVATE
|
||||
${IMGUI_DIR}/i18n/imgui_i18n.cpp
|
||||
${IMGUI_DIR}/i18n/locale/ja_JP.cpp
|
||||
)
|
||||
target_include_directories(my_app PRIVATE ${IMGUI_DIR}/i18n)
|
||||
target_compile_definitions(my_app PRIVATE IMGUI_DEMO_ENABLE_I18N)
|
||||
```
|
||||
|
||||
**Xcode:** Add both `.cpp` files to the target's *Compile Sources* phase.
|
||||
|
||||
### 3. Add a menu item for the new language
|
||||
|
||||
In `imgui_demo.cpp`, find the Language menu (search for `BeginMenu(Tr("Language"))`):
|
||||
|
||||
```cpp
|
||||
if (ImGui::MenuItem("日本語", nullptr, is_ja) && !is_ja)
|
||||
{
|
||||
imgui_i18n::setLocale("ja_JP");
|
||||
#if defined(__APPLE__)
|
||||
g_need_font_rebuild = true; // triggers CJK font reload on Apple Metal
|
||||
#endif
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Font loading (CJK / non-Latin scripts)
|
||||
|
||||
For languages requiring non-Latin glyphs, add font loading logic in your platform's
|
||||
`main` file (see `examples/example_apple_metal/main.mm` → `RebuildFonts()` for reference).
|
||||
|
||||
The pattern:
|
||||
1. Call `io.Fonts->AddFontDefault(&cfg)` with explicit `SizePixels` first (required by ImGui v1.92+).
|
||||
2. Merge the target-language font with `cfg.MergeMode = true`.
|
||||
3. Choose glyph ranges: use `io.Fonts->GetGlyphRangesChineseSimplifiedCommon()` for Chinese,
|
||||
`GetGlyphRangesJapanese()` for Japanese, etc.
|
||||
4. Call `io.Fonts->Build()`.
|
||||
|
||||
---
|
||||
|
||||
## Translation Guidelines
|
||||
|
||||
Follow these rules when translating strings to ensure quality and consistency.
|
||||
|
||||
### What to translate
|
||||
|
||||
Translate user-visible UI labels: menu items, button labels, window titles, section
|
||||
headers, tooltip descriptions, and status messages.
|
||||
|
||||
### What NOT to translate
|
||||
|
||||
| Category | Example | Reason |
|
||||
|----------|---------|--------|
|
||||
| Universally recognized programming examples | `"Hello, world!"` | Part of global programming culture; keeping English avoids confusion for learners following tutorials |
|
||||
| Standard boilerplate example text | `"This is some useful text."` | Canonical ImGui getting-started template text |
|
||||
| C++ type/variable names used as labels | `"float"`, `"counter = %d"` | Labels the underlying type or variable name, not a description |
|
||||
| Intentional filler/nonsense | `"blah blah blah"` | The meaninglessness is the message; translating it to real words defeats the purpose |
|
||||
| API / function names | `"IsItemHovered()"` | Must remain identical to the actual API; adding an entry that maps to itself is redundant |
|
||||
| Brand / product names | `"Dear ImGui"`, `"dear imgui"` | Proper nouns; do not translate |
|
||||
| `##`-suffixed ImGui IDs | `"Config##2"` | The `##` part is a disambiguation suffix handled in code, not user-visible |
|
||||
|
||||
### Translation quality rules
|
||||
|
||||
1. **Accuracy over literalness.** Translate meaning, not word-by-word.
|
||||
Bad: `Metrics` → `性能` (performance)
|
||||
Good: `Metrics` → `指标` (indicators/measurements)
|
||||
|
||||
2. **Preserve format specifiers.** `%d`, `%s`, `%.3f`, `$1`, `$2` must appear unchanged in the translated string.
|
||||
|
||||
3. **Preserve newlines.** `\n` positions in the translation may differ from the English, but must be present where the UI needs line breaks.
|
||||
|
||||
4. **Preserve punctuation intent.** If the English ends with `:`, the translation should too (adjusted for the target language's punctuation conventions).
|
||||
|
||||
5. **Redundant identity entries are noise.** If a string needs no translation (e.g. an API function name), do **not** add `{"Foo()", "Foo()"}` to the table. The fallback mechanism returns the key automatically.
|
||||
|
||||
---
|
||||
|
||||
## Extracting Strings for Translation
|
||||
|
||||
Use the helper script to generate a translation skeleton for a range of lines:
|
||||
|
||||
```bash
|
||||
cd imgui-master # or wherever imgui_demo.cpp lives
|
||||
python3 i18n/tools/extract_strings.py imgui_demo.cpp <start_line> <end_line>
|
||||
```
|
||||
|
||||
Output is ready-to-paste `{"English key", ""},` entries.
|
||||
Paste them into your locale file and fill in the translated values.
|
||||
|
||||
---
|
||||
|
||||
## Integrating into Your Build (Other Examples)
|
||||
|
||||
Only `example_apple_metal` ships with i18n enabled by default.
|
||||
To enable it for any other example:
|
||||
|
||||
1. Add `imgui_i18n.cpp` and your locale `.cpp` files to the build.
|
||||
2. Add `-I<imgui_root>/i18n` to include paths.
|
||||
3. Add `-DIMGUI_DEMO_ENABLE_I18N` to compiler flags.
|
||||
4. Add font loading + language-switch UI to your platform's `main` file
|
||||
(use `examples/example_apple_metal/main.mm` as a reference).
|
||||
|
||||
---
|
||||
|
||||
## API Reference
|
||||
|
||||
```cpp
|
||||
// imgui_i18n.h (available when IMGUI_DEMO_ENABLE_I18N is defined)
|
||||
|
||||
Tr("key") // translate key, return const char*
|
||||
TrF("Draw $1 of $2", {"3","10"}) // translate + substitute placeholders
|
||||
|
||||
imgui_i18n::setLocale("zh_CN"); // switch language (call before NewFrame)
|
||||
imgui_i18n::getLocale(); // returns current locale string ("" = English)
|
||||
imgui_i18n::registerLocale( // called by locale/*.cpp static initializers
|
||||
"locale_id",
|
||||
{ {"English key", "Translation"}, ... }
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Current Translations
|
||||
|
||||
| Locale | Language | Coverage |
|
||||
|--------|----------|----------|
|
||||
| *(default)* | English | 100% (source) |
|
||||
| `zh_CN` | Simplified Chinese | ~100% of `imgui_demo.cpp` |
|
||||
|
||||
Contributions welcome — see **Adding a New Language** above.
|
||||
61
i18n/imgui_i18n.cpp
Normal file
61
i18n/imgui_i18n.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// i18n/imgui_i18n.cpp
|
||||
#include "imgui_i18n.h"
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
namespace imgui_i18n {
|
||||
|
||||
// Meyers Singleton: guarantees initialization before first use across translation units, avoiding SIOF.
|
||||
static std::string& locale() {
|
||||
static std::string s;
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, std::unordered_map<std::string, std::string>>& tables() {
|
||||
static std::unordered_map<std::string, std::unordered_map<std::string, std::string>> s;
|
||||
return s;
|
||||
}
|
||||
|
||||
void setLocale(const char* loc) {
|
||||
locale() = loc ? loc : "";
|
||||
}
|
||||
|
||||
const char* getLocale() {
|
||||
return locale().c_str();
|
||||
}
|
||||
|
||||
const char* translate(const char* key) {
|
||||
if (!key) return "";
|
||||
if (locale().empty()) return key; // English fast path
|
||||
auto it = tables().find(locale());
|
||||
if (it == tables().end()) return key;
|
||||
auto it2 = it->second.find(key);
|
||||
if (it2 == it->second.end()) return key;
|
||||
return it2->second.c_str();
|
||||
}
|
||||
|
||||
std::string fmt(const char* key, std::initializer_list<std::string> args) {
|
||||
std::string result = translate(key);
|
||||
int i = 1;
|
||||
for (const auto& arg : args) {
|
||||
std::string ph = "$" + std::to_string(i++);
|
||||
size_t pos;
|
||||
while ((pos = result.find(ph)) != std::string::npos)
|
||||
result.replace(pos, ph.size(), arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void registerLocale(
|
||||
const char* loc,
|
||||
std::initializer_list<std::pair<const char*, const char*>> entries)
|
||||
{
|
||||
// All registerLocale() calls must complete before the first translate() call (normally guaranteed
|
||||
// by static initializers). Do not add entries after translate() has been called: unordered_map
|
||||
// rehashing would invalidate the c_str() pointers returned by translate().
|
||||
auto& table = tables()[loc];
|
||||
for (const auto& e : entries)
|
||||
table[e.first] = e.second;
|
||||
}
|
||||
|
||||
} // namespace imgui_i18n
|
||||
47
i18n/imgui_i18n.h
Normal file
47
i18n/imgui_i18n.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// dear imgui - i18n (internationalization) module
|
||||
// Provides runtime language switching for imgui_demo.cpp.
|
||||
//
|
||||
// Usage:
|
||||
// Define IMGUI_DEMO_ENABLE_I18N in your build system to opt in.
|
||||
// Without it, Tr(s) is a no-op and other examples are unaffected.
|
||||
//
|
||||
// See i18n/README.md for details and how to add a new language.
|
||||
#pragma once
|
||||
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
|
||||
#include <string>
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
// Wrap every user-visible string literal in imgui_demo.cpp with Tr().
|
||||
#define Tr(s) imgui_i18n::translate(s)
|
||||
// Variant with $1/$2/... placeholder substitution.
|
||||
#define TrF(s, ...) imgui_i18n::fmt(s, __VA_ARGS__)
|
||||
|
||||
namespace imgui_i18n {
|
||||
|
||||
// Set active locale: "" or "en" = English (default, zero-overhead fast path).
|
||||
void setLocale(const char* locale);
|
||||
const char* getLocale();
|
||||
|
||||
// Look up key in the active locale table; falls back to key itself if not found.
|
||||
const char* translate(const char* key);
|
||||
|
||||
// Replace $1, $2, ... placeholders with args (in order).
|
||||
std::string fmt(const char* key, std::initializer_list<std::string> args);
|
||||
|
||||
// Register a translation table for a locale (called by locale/*.cpp static initializers).
|
||||
void registerLocale(
|
||||
const char* locale,
|
||||
std::initializer_list<std::pair<const char*, const char*>> entries);
|
||||
|
||||
} // namespace imgui_i18n
|
||||
|
||||
#else // IMGUI_DEMO_ENABLE_I18N not defined
|
||||
|
||||
// Stub: Tr() is a compile-time identity — zero overhead, no dependencies.
|
||||
#define Tr(s) (s)
|
||||
#define TrF(s, ...) (s)
|
||||
|
||||
#endif // IMGUI_DEMO_ENABLE_I18N
|
||||
820
i18n/locale/zh_CN.cpp
Normal file
820
i18n/locale/zh_CN.cpp
Normal file
|
|
@ -0,0 +1,820 @@
|
|||
// i18n/locale/zh_CN.cpp
|
||||
// Simplified Chinese (zh_CN) translation table. Auto-registered before main() via static initializer.
|
||||
#include "../imgui_i18n.h"
|
||||
|
||||
namespace {
|
||||
struct ZhCNRegistrar {
|
||||
ZhCNRegistrar() {
|
||||
imgui_i18n::registerLocale("zh_CN", {
|
||||
// === Step 1: Demo Window + MenuBar ===
|
||||
{"Dear ImGui Demo", "Dear ImGui 演示"},
|
||||
{"Configuration", "配置"},
|
||||
{"Window options", "窗口选项"},
|
||||
{"No titlebar", "无标题栏"},
|
||||
{"No scrollbar", "无滚动条"},
|
||||
{"No menu", "无菜单"},
|
||||
{"No move", "禁止移动"},
|
||||
{"No resize", "禁止缩放"},
|
||||
{"No collapse", "禁止折叠"},
|
||||
{"No close", "无关闭按钮"},
|
||||
{"No nav", "无键盘/手柄导航"},
|
||||
{"No background", "无背景"},
|
||||
{"No bring to front", "不置顶"},
|
||||
{"Unsaved document", "未保存标记"},
|
||||
{"Widgets", "控件"},
|
||||
{"Layout & Scrolling", "布局与滚动"},
|
||||
{"Popups & Modal windows", "弹窗与模态框"},
|
||||
{"Tables & Columns", "表格与列"},
|
||||
{"Inputs & Focus", "输入与焦点"},
|
||||
{"Disable All", "全部禁用"},
|
||||
{"Disable (section)", "禁用(区域)"},
|
||||
{"Menu", "菜单"},
|
||||
{"Examples", "示例"},
|
||||
{"Main menu bar", "主菜单栏"},
|
||||
{"Assets Browser", "资产浏览器"},
|
||||
{"Console", "控制台"},
|
||||
{"Custom rendering", "自定义渲染"},
|
||||
{"Documents", "文档管理"},
|
||||
{"Image Viewer", "图片查看器"},
|
||||
{"Log", "日志"},
|
||||
{"Property editor", "属性编辑器"},
|
||||
{"Simple layout", "简单布局"},
|
||||
{"Simple overlay", "简单浮层"},
|
||||
{"Mini apps", "迷你应用"},
|
||||
{"Concepts", "概念演示"},
|
||||
{"Auto-resizing window", "自动调整大小的窗口"},
|
||||
{"Constrained-resizing window", "约束调整大小的窗口"},
|
||||
{"Fullscreen window", "全屏窗口"},
|
||||
{"Long text display", "长文本显示"},
|
||||
{"Manipulating window titles", "操控窗口标题"},
|
||||
{"Tools", "工具"},
|
||||
{"Metrics/Debugger", "指标/调试器"},
|
||||
{"Debug Options", "调试选项"},
|
||||
{"Highlight ID Conflicts", "高亮 ID 冲突"},
|
||||
{"Assert on error recovery", "错误恢复时断言"},
|
||||
{"(see Demo->Configuration for more)", "(详见 Demo->配置)"},
|
||||
{"Debug Log", "调试日志"},
|
||||
{"ID Stack Tool", "ID 栈工具"},
|
||||
{"Item Picker", "元素拾取器"},
|
||||
{"Style Editor", "样式编辑器"},
|
||||
{"About Dear ImGui", "关于 Dear ImGui"},
|
||||
{"Language", "语言"},
|
||||
{"File", "文件"},
|
||||
{"New", "新建"},
|
||||
{"Open", "打开"},
|
||||
{"Open Recent", "最近打开"},
|
||||
{"Save", "保存"},
|
||||
{"Save As..", "另存为.."},
|
||||
{"Export", "导出"},
|
||||
{"Quit", "退出"},
|
||||
{"Options", "选项"},
|
||||
{"Enabled", "已启用"},
|
||||
{"Size", "大小"},
|
||||
{"Color", "颜色"},
|
||||
{"SeparatorText", "分隔文字"},
|
||||
{"Dear ImGui Style Editor", "Dear ImGui 样式编辑器"},
|
||||
// --- Step 1 supplement: Configuration panel ---
|
||||
{"dear imgui says hello! (%s) (%d)", "dear imgui 向你问好!(%s) (%d)"},
|
||||
{"<<PRESS SPACE TO DISABLE>>", "<<按空格键禁用>>"},
|
||||
{"Also see Style->Rendering for rendering options.", "另见 样式->渲染 中的渲染选项。"},
|
||||
{"General", "通用"},
|
||||
{"Keyboard/Gamepad Navigation", "键盘/手柄导航"},
|
||||
{"Windows", "窗口"},
|
||||
{"Error Handling", "错误处理"},
|
||||
{"Debug", "调试"},
|
||||
{"Backend Flags", "后端标志"},
|
||||
{"Style, Fonts", "样式与字体"},
|
||||
{"Capture/Logging", "截图/日志"},
|
||||
{"Copy \"Hello, world!\" to clipboard", "复制 \"Hello, world!\" 到剪贴板"},
|
||||
// === Step 2: WidgetsBasic + Bullets + CollapsingHeaders ===
|
||||
{"Basic", "基础"},
|
||||
{"Selectable", "可选项"},
|
||||
{"Images", "图片"},
|
||||
{"Combos", "下拉框"},
|
||||
{"Drag and Drop", "拖放"},
|
||||
{"Color/Picker Widgets", "颜色/选色控件"},
|
||||
{"Multi-component Widgets", "多组件控件"},
|
||||
{"Plotting", "绘图"},
|
||||
{"Progress Bars", "进度条"},
|
||||
{"Text Input", "文本输入"},
|
||||
{"Drags and Sliders", "拖拽与滑块"},
|
||||
{"Selectables", "可选列表项"},
|
||||
{"Tree Nodes", "树节点"},
|
||||
{"Collapsing Headers", "折叠标题"},
|
||||
{"Tooltips", "提示框"},
|
||||
{"Tabs", "标签页"},
|
||||
{"Text", "文字"},
|
||||
{"List Boxes", "列表框"},
|
||||
{"Vertical Sliders", "垂直滑块"},
|
||||
{"Filtered Text Input", "过滤文本输入"},
|
||||
{"Disable Widgets", "禁用控件"},
|
||||
{"Data Types", "数据类型"},
|
||||
{"Multi-Select", "多选"},
|
||||
{"Bullet Widgets", "项目符号控件"},
|
||||
{"Bullet point 1", "项目符号 1"},
|
||||
{"Bullet point 2\nOn multiple lines", "项目符号 2\n(多行文本)"},
|
||||
{"Button", "按钮"},
|
||||
{"Click me", "点击我"},
|
||||
{"Clicked!", "已点击!"},
|
||||
{"Arrows", "箭头按钮"},
|
||||
{"Toggle disabled", "切换禁用"},
|
||||
{"Checkbox", "复选框"},
|
||||
{"RadioButton", "单选按钮"},
|
||||
{"(Disabled)", "(禁用)"},
|
||||
{"(Enabled)", "(启用)"},
|
||||
{"Hold to repeat:", "长按重复:"},
|
||||
{"Press and hold to repeat", "长按重复"},
|
||||
{"Right-click on buttons too!", "按钮也支持右键!"},
|
||||
{"Hovering over me changes the cursor to an arrow!", "悬停切换为箭头光标!"},
|
||||
{"Hovering over me changes the cursor to a hand!", "悬停切换为手形光标!"},
|
||||
{"Tooltip when hovering:", "悬停提示:"},
|
||||
{"Tooltip always visible:", "始终显示提示:"},
|
||||
{"Hold to repeat (filtered)", "长按重复(过滤)"},
|
||||
{"Another bullet point", "另一个项目符号"},
|
||||
{"Header 1: open by default", "标题 1:默认展开"},
|
||||
{"Header 2: do not show a bullet", "标题 2:无项目符号"},
|
||||
{"(more empty content)", "(更多空内容)"},
|
||||
{"(see Widgets->Selectable for more)", "(详见 控件->可选列表项)"},
|
||||
{"Thanks for clicking me!", "感谢点击!"},
|
||||
{"checkbox", "复选框"},
|
||||
{"radio a", "单选 a"},
|
||||
{"radio b", "单选 b"},
|
||||
{"radio c", "单选 c"},
|
||||
{"Click", "点击"},
|
||||
{"Tooltip", "提示"},
|
||||
{"I am a tooltip", "我是一个提示框"},
|
||||
{"label", "标签"},
|
||||
{"Value", "值"},
|
||||
{"input text", "输入文本"},
|
||||
{"input text (w/ hint)", "输入文本(带提示)"},
|
||||
{"enter text here", "在此输入"},
|
||||
{"input int", "输入整数"},
|
||||
{"input float", "输入浮点数"},
|
||||
{"input double", "输入双精度"},
|
||||
{"input scientific", "科学计数法输入"},
|
||||
{"input float3", "输入 float3"},
|
||||
{"drag int", "拖拽整数"},
|
||||
{"drag int 0..100", "拖拽整数 0..100"},
|
||||
{"drag int wrap 100..200", "拖拽整数环绕 100..200"},
|
||||
{"drag float", "拖拽浮点数"},
|
||||
{"drag small float", "拖拽小浮点数"},
|
||||
{"slider int", "滑块整数"},
|
||||
{"slider float", "滑块浮点数"},
|
||||
{"slider float (log)", "滑块浮点数(对数)"},
|
||||
{"slider angle", "滑块角度"},
|
||||
{"slider enum", "滑块枚举"},
|
||||
{"color 1", "颜色 1"},
|
||||
{"color 2", "颜色 2"},
|
||||
{"combo", "下拉框"},
|
||||
{"listbox", "列表框"},
|
||||
{"Bullets", "项目符号"},
|
||||
{"Tree node", "树节点"},
|
||||
{"Bullet point 3 (two calls)", "项目符号 3(两次调用)"},
|
||||
{"Show 2nd header", "显示第 2 个标题"},
|
||||
{"Header", "标题"},
|
||||
{"Header with a close button", "带关闭按钮的标题"},
|
||||
{"IsItemHovered: %d", "IsItemHovered: %d"},
|
||||
{"Some content %d", "部分内容 %d"},
|
||||
{"More content %d", "更多内容 %d"},
|
||||
{"Inputs", "输入"},
|
||||
{"Drags", "拖拽"},
|
||||
{"Sliders", "滑块"},
|
||||
{"Selectors/Pickers", "选择器/拾色器"},
|
||||
// === Step 3: ComboBoxes + ListBoxes + Tabs ===
|
||||
{"Combo", "下拉框"},
|
||||
{"One-liner variants", "单行变体"},
|
||||
{"Only makes a difference if the popup is larger than the combo", "仅在弹窗比下拉框宽时有效"},
|
||||
{"Highlight hovered item in second listbox", "在第二个列表框中高亮悬停项"},
|
||||
{"Full-width:", "全宽:"},
|
||||
{"This is the Avocado tab!\nblah blah blah blah blah", "这是鳄梨标签页!\nblah blah blah blah blah"},
|
||||
{"This is the Broccoli tab!\nblah blah blah blah blah", "这是西兰花标签页!\nblah blah blah blah blah"},
|
||||
{"This is the Cucumber tab!\nblah blah blah blah blah", "这是黄瓜标签页!\nblah blah blah blah blah"},
|
||||
{"Advanced & Close Button", "高级与关闭按钮"},
|
||||
{"Opened:", "已打开:"},
|
||||
{"This is the %s tab!", "这是 %s 标签页!"},
|
||||
{"I am an odd tab.", "我是一个奇数标签页。"},
|
||||
{"TabItemButton & Leading/Trailing flags", "标签按钮与前导/尾随标志"},
|
||||
{"Show Leading TabItemButton()", "显示前导标签按钮"},
|
||||
{"Show Trailing TabItemButton()", "显示尾随标签按钮"},
|
||||
{"Hello!", "你好!"},
|
||||
// === Step 4: DragsSliders + DataTypes + VerticalSliders ===
|
||||
{"Drag Int", "拖拽整数"},
|
||||
{"Drag Float", "拖拽浮点"},
|
||||
{"Drag small float", "拖拽小浮点"},
|
||||
{"Slider Int", "整数滑块"},
|
||||
{"Slider Float", "浮点滑块"},
|
||||
{"Slider angle", "角度滑块"},
|
||||
{"Reversed", "反向"},
|
||||
{"Clamp On Input", "限制输入范围"},
|
||||
{"Round to format", "按格式取整"},
|
||||
{"Logarithmic", "对数"},
|
||||
{"Whole Numbers", "整数"},
|
||||
{"Without border", "无边框"},
|
||||
{"With border", "有边框"},
|
||||
{"Input", "输入"},
|
||||
{"Sliders (DragXXX, SliderXXX)", "拖拽与滑块(DragXXX, SliderXXX)"},
|
||||
{"Drag/Slider Flags", "拖拽/滑块标志"},
|
||||
{"Underlying float value: %f", "底层浮点值:%f"},
|
||||
{"Cannot drop here!", "无法拖放到此处!"},
|
||||
{"drag me", "拖动我"},
|
||||
{"Clamp integers to 0..50", "将整数限制在 0..50"},
|
||||
{"Sliders (reverse)", "反向滑块"},
|
||||
{"Show step buttons", "显示步进按钮"},
|
||||
{"Misc", "其他"},
|
||||
{"Saturation", "饱和度"},
|
||||
{"As 0..255", "范围 0..255"},
|
||||
// === Step 5: Text + TextFilter + TextInput ===
|
||||
{"Text Display", "文字显示"},
|
||||
{"Colored Text", "彩色文字"},
|
||||
{"Word Wrapping", "自动换行"},
|
||||
{"UTF-8 Text", "UTF-8 文字"},
|
||||
{"Single-line text input", "单行文本输入"},
|
||||
{"Password input", "密码输入"},
|
||||
{"Multi-line text input", "多行文本输入"},
|
||||
{"Completion:", "补全:"},
|
||||
{"History:", "历史:"},
|
||||
{"Info:", "信息:"},
|
||||
{"Lock And Scroll", "锁定并滚动"},
|
||||
{"Read-only", "只读"},
|
||||
{"Resize according to text", "根据文本自动缩放"},
|
||||
{"Filtered Input", "过滤输入"},
|
||||
{"Misc inputs", "其他输入"},
|
||||
{"Upper-case input", "大写输入"},
|
||||
{"Filter with a callback", "回调过滤"},
|
||||
{"No spaces", "无空格"},
|
||||
{"Hexadecimal", "十六进制"},
|
||||
{"Scientific", "科学计数"},
|
||||
{"Custom", "自定义"},
|
||||
{"Password", "密码"},
|
||||
{"In a popup", "在弹窗中"},
|
||||
{"Pressing ENTER will submit", "按 Enter 提交"},
|
||||
{"Multiline", "多行"},
|
||||
{"Editable", "可编辑"},
|
||||
{"Font Size", "字体大小"},
|
||||
// === Step 6: Color/Pickers + Images + Plotting + ProgressBars ===
|
||||
{"Color widget:", "颜色控件:"},
|
||||
{"Color widget HSV with Alpha:", "HSV 带透明度:"},
|
||||
{"Color widget with Float Display:", "浮点显示颜色:"},
|
||||
{"Color button with Custom Picker Popup:", "自定义选色弹窗:"},
|
||||
{"my color", "我的颜色"},
|
||||
{"Color picker", "颜色选取器"},
|
||||
{"Set defaults in code:", "在代码中设置默认值:"},
|
||||
{"Both types:", "两种类型:"},
|
||||
{"HSV encoded colors", "HSV 编码颜色"},
|
||||
{"Color widget with InputHSV:", "InputHSV 颜色控件:"},
|
||||
{"Hover the texture for a zoomed view!", "悬停纹理查看放大视图!"},
|
||||
{"Image()/ImageWithBg() function", "Image()/ImageWithBg() 函数"},
|
||||
{"Interactive Image Viewer", "交互式图片查看器"},
|
||||
{"Textured Buttons", "纹理按钮"},
|
||||
{"And now some textured buttons..", "以下是一些纹理按钮.."},
|
||||
{"Need better plotting and graphing? Consider using ImPlot:", "需要更好的绘图?考虑使用 ImPlot:"},
|
||||
{"Animate", "动画"},
|
||||
{"Frame Times", "帧时间"},
|
||||
{"Histogram", "直方图"},
|
||||
{"Functions", "函数"},
|
||||
{"Sample count", "采样数"},
|
||||
// === Step 7: DragDrop + QueryingStatuses + DisableBlocks ===
|
||||
{"Disable Blocks", "禁用块"},
|
||||
{"Disable entire section above", "禁用上方全部控件"},
|
||||
{"Demonstrate using BeginDisabled()/EndDisabled() across other sections.", "演示跨区域使用 BeginDisabled()/EndDisabled()。"},
|
||||
{"Drag and drop in standard widgets", "在标准控件中拖放"},
|
||||
{"You can drag from the color squares.", "可以从颜色方块拖动。"},
|
||||
{"Drag and drop to copy/swap items", "拖放以复制/交换项目"},
|
||||
{"Copy", "复制"},
|
||||
{"Move", "移动"},
|
||||
{"Swap", "交换"},
|
||||
{"Drag to reorder items (simple)", "拖放重新排序(简单)"},
|
||||
{"Tooltip at target location", "目标位置工具提示"},
|
||||
{"Drag to re-order", "拖放以重新排序"},
|
||||
{"Hold CTRL to copy", "按住 CTRL 复制"},
|
||||
{"Querying Item Status (Edited/Active/Hovered etc.)", "查询控件状态(已编辑/激活/悬停等)"},
|
||||
{"Querying Window Status (Focused/Hovered etc.)", "查询窗口状态(聚焦/悬停等)"},
|
||||
{"Embed everything inside a child window for testing _RootWindow flag.", "将所有内容嵌入子窗口以测试 _RootWindow 标志。"},
|
||||
{"Querying Mouse Status", "查询鼠标状态"},
|
||||
{"Disabled Widgets", "禁用控件"},
|
||||
{"Disable all items", "禁用所有控件"},
|
||||
{"First", "第一"},
|
||||
{"Second", "第二"},
|
||||
{"Third", "第三"},
|
||||
// IsItemXxx()/GetItemXxx() API names are not translated (fallback to English key).
|
||||
{"Mouse Cursors", "鼠标光标"},
|
||||
{"Display all cursors", "显示所有光标"},
|
||||
{"Hovering over them changes the mouse cursor.", "悬停改变光标样式。"},
|
||||
|
||||
// === Step 8: Selectables + MultiSelect + TreeNodes + Tooltips ===
|
||||
{"1. Direct output", "1. 直接输出"},
|
||||
{"2. Checkbox-like behavior", "2. 复选框行为"},
|
||||
{"3. Mixed usage", "3. 混合用法"},
|
||||
{"4. Full-width selectable, with a custom overlay", "4. 全宽可选项(带覆盖层)"},
|
||||
{"5. Rendering more items (150)", "5. 渲染更多项目(150 个)"},
|
||||
{"Multiple items on the same line", "同行多项目"},
|
||||
{"In Tables", "在表格中"},
|
||||
{"Grid", "网格"},
|
||||
{"Alignment", "对齐"},
|
||||
{"Selection: None", "选中:无"},
|
||||
{"(Selection: None)", "(选中:无)"},
|
||||
{"Selection State & Multi-Select", "选中状态与多选"},
|
||||
{"Single-Select", "单选"},
|
||||
{"Multi-Select (manual/simplified, without BeginMultiSelect)", "多选(手动简化版,不使用 BeginMultiSelect)"},
|
||||
{"Supported features:", "支持的功能:"},
|
||||
{"Added features:", "新增功能:"},
|
||||
{"Dynamic list with Delete key support.", "动态列表(支持 Delete 键删除)。"},
|
||||
{"Multi-Select (with clipper)", "多选(带裁剪器)"},
|
||||
{"Multi-Select (with deletion)", "多选(含删除)"},
|
||||
{"Multi-Select (dual list box)", "多选(双列表框)"},
|
||||
{"Multi-Select (in a table)", "多选(在表格中)"},
|
||||
{"Multi-Select (checkboxes)", "多选(复选框)"},
|
||||
{"In a list of checkboxes (not selectable):", "复选框列表(非 Selectable):"},
|
||||
{"Using _NoAutoSelect + _NoAutoClear flags.", "使用 _NoAutoSelect + _NoAutoClear 标志。"},
|
||||
{"Shift+Click to check multiple boxes.", "Shift+点击 勾选多个框。"},
|
||||
{"Shift+Keyboard to copy current value to other boxes.", "Shift+键盘 将当前值复制到其他框。"},
|
||||
{"Multi-Select (multiple scopes)", "多选(多作用域)"},
|
||||
{"Selection scope", "选中作用域"},
|
||||
{"Multi-Select (tiled assets browser)", "多选(平铺资产浏览器)"},
|
||||
{"(also access from 'Examples->Assets Browser' in menu)", "(也可从菜单 'Examples->Assets Browser' 进入)"},
|
||||
{"Multi-Select (trees)", "多选(树)"},
|
||||
{"Selection size: %d", "已选:%d"},
|
||||
{"Multi-Select (advanced)", "多选(高级)"},
|
||||
{"Tree nodes", "树节点项"},
|
||||
{"Enable clipper", "启用裁剪器"},
|
||||
{"Enable deletion", "启用删除"},
|
||||
{"Enable drag & drop", "启用拖放"},
|
||||
{"Show in a table", "显示在表格中"},
|
||||
{"Show color button", "显示颜色按钮"},
|
||||
{"Dragging %d objects", "正在拖动 %d 个对象"},
|
||||
{"Close", "关闭"},
|
||||
{"Wiki page:", "Wiki 页面:"},
|
||||
{"Multi-select and multiple columns", "多选与多列"},
|
||||
{"Multi-select tree", "多选树"},
|
||||
{"Multi-select table", "多选表格"},
|
||||
{"Use CTRL+Click to select multiple items.", "CTRL+点击 选择多项。"},
|
||||
{"Hold SHIFT to select a range.", "SHIFT 选择范围。"},
|
||||
{"Basic Trees", "基础树"},
|
||||
{"Hierarchy Lines", "层级连线"},
|
||||
{"Clipping Large Trees", "裁剪大型树"},
|
||||
{"Selectable Nodes", "可选节点"},
|
||||
{"Advanced", "高级"},
|
||||
{"Parent", "父节点"},
|
||||
{"Child 1", "子节点 1"},
|
||||
{"Child 2", "子节点 2"},
|
||||
{"Button for Child 1", "子节点 1 按钮"},
|
||||
{"Button for Child 2", "子节点 2 按钮"},
|
||||
{"Remaining contents", "剩余内容"},
|
||||
{"blah blah", "内容内容"},
|
||||
{"button", "按钮"},
|
||||
{"This is a drag and drop source", "这是一个拖放源"},
|
||||
{"Blah blah\nBlah Blah", "内容内容\n内容内容"},
|
||||
{"<Node contents here>", "<节点内容>"},
|
||||
{"Align label with current X position", "与当前 X 位置对齐标签"},
|
||||
{"Make Tree Nodes as drag & drop sources", "将树节点作为拖放源"},
|
||||
{"Basic trees", "基础树"},
|
||||
{"Advanced, with Selectable nodes", "高级(带可选节点)"},
|
||||
{"Leaf node", "叶节点"},
|
||||
{"Child node 0", "子节点 0"},
|
||||
{"Child node 1", "子节点 1"},
|
||||
{"Fancy", "高级"},
|
||||
{"Curve", "曲线"},
|
||||
{"Sin(time) = %f", "Sin(时间) = %f"},
|
||||
{"Always On", "始终显示"},
|
||||
{"Off", "关闭"},
|
||||
{"Always On (Simple)", "始终显示(简单)"},
|
||||
{"Always On (Advanced)", "始终显示(高级)"},
|
||||
{"I am following you around.", "我在跟随你。"},
|
||||
{"I am a fancy tooltip", "我是一个高级提示框"},
|
||||
{"flags for a specific tooltip instance.", "针对特定提示框实例的标志。"},
|
||||
{"Manual", "手动"},
|
||||
{"I am a manually emitted tooltip.", "我是手动触发的提示框。"},
|
||||
{"DelayNone", "无延迟"},
|
||||
{"I am a tooltip with no delay.", "我是一个无延迟的提示框。"},
|
||||
{"DelayShort", "短延迟"},
|
||||
{"I am a tooltip with a short delay (%0.2f sec).", "我是一个短延迟提示框(%0.2f 秒)。"},
|
||||
{"DelayLong", "长延迟"},
|
||||
{"I am a tooltip with a long delay (%0.2f sec).", "我是一个长延迟提示框(%0.2f 秒)。"},
|
||||
{"Stationary", "静止触发"},
|
||||
{"I am a tooltip requiring mouse to be stationary before activating.", "我需要鼠标静止后才会显示。"},
|
||||
{"Disabled item", "禁用项"},
|
||||
{"I am a tooltip for a disabled item.", "我是禁用项的提示框。"},
|
||||
{"Always on", "始终显示"},
|
||||
{"Delay", "延迟"},
|
||||
{"Programmatic", "程序化"},
|
||||
{"Variable delay", "可变延迟"},
|
||||
{"Short", "短"},
|
||||
{"Long", "长"},
|
||||
{"Stationary delay", "静止延迟"},
|
||||
{"Scroll to select", "滚动选择"},
|
||||
{"Fixed", "固定"},
|
||||
{"(close)", "(关闭)"},
|
||||
{"(Closed)", "(已关闭)"},
|
||||
// === Step 9: Layout ===
|
||||
{"Child windows", "子窗口"},
|
||||
{"Disable Mouse Wheel", "禁用鼠标滚轮"},
|
||||
{"Disable Menu", "禁用菜单"},
|
||||
{"%04d: scrollable region", "%04d: 可滚动区域"},
|
||||
{"Manual-resize", "手动调整大小"},
|
||||
{"Auto-resize with constraints", "带约束的自动调整大小"},
|
||||
{"Lines Count", "行数"},
|
||||
{"Max Height (in Lines)", "最大高度(行数)"},
|
||||
{"Misc/Advanced", "杂项/高级"},
|
||||
{"Offset X", "X 偏移"},
|
||||
{"Override ChildBg color", "覆盖子窗口背景色"},
|
||||
{"Some test %d", "测试项 %d"},
|
||||
{"Hovered: %d", "悬浮: %d"},
|
||||
{"Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", "子窗口矩形: (%.0f,%.0f) (%.0f,%.0f)"},
|
||||
{"Widgets Width", "控件宽度"},
|
||||
{"Show indented items", "显示缩进项"},
|
||||
{"SetNextItemWidth/PushItemWidth(100)", "SetNextItemWidth/PushItemWidth(100)"},
|
||||
{"Fixed width.", "固定宽度。"},
|
||||
{"SetNextItemWidth/PushItemWidth(-100)", "SetNextItemWidth/PushItemWidth(-100)"},
|
||||
{"Align to right edge minus 100", "对齐到右边缘减 100"},
|
||||
{"SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)", "SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)"},
|
||||
{"Half of available width.\n(~ right-cursor_pos)\n(works within a column set)", "可用宽度的一半。\n(~ 右侧光标位置)\n(在列集中有效)"},
|
||||
{"SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)", "SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)"},
|
||||
{"Align to right edge minus half", "对齐到右边缘减半"},
|
||||
{"SetNextItemWidth/PushItemWidth(-FLT_MIN)", "SetNextItemWidth/PushItemWidth(-FLT_MIN)"},
|
||||
{"Align to right edge", "对齐到右边缘"},
|
||||
{"Basic Horizontal Layout", "基础水平布局"},
|
||||
{"(Use ImGui::SameLine() to keep adding items to the right of the preceding item)", "(使用 ImGui::SameLine() 在前一个控件右侧继续添加控件)"},
|
||||
{"Two items: Hello", "两个控件: Hello"},
|
||||
{"Sailor", "水手"},
|
||||
{"More spacing: Hello", "更大间距: Hello"},
|
||||
{"Normal buttons", "普通按钮"},
|
||||
{"Banana", "香蕉"},
|
||||
{"Apple", "苹果"},
|
||||
{"Corniflower", "矢车菊"},
|
||||
{"Small buttons", "小按钮"},
|
||||
{"Like this one", "像这个"},
|
||||
{"can fit within a text block.", "可以嵌入文本块中。"},
|
||||
{"Aligned", "对齐"},
|
||||
{"x=150", "x=150"},
|
||||
{"x=300", "x=300"},
|
||||
{"My", "我的"},
|
||||
{"Tailor", "裁缝"},
|
||||
{"Is", "是"},
|
||||
{"Rich", "富有的"},
|
||||
{"Lists:", "列表:"},
|
||||
{"Manual wrapping:", "手动换行:"},
|
||||
{"Groups", "分组"},
|
||||
{"Text Baseline Alignment", "文字基线对齐"},
|
||||
{"Text baseline:", "文字基线:"},
|
||||
{"Multi-line text:", "多行文本:"},
|
||||
{"Misc items:", "杂项控件:"},
|
||||
{"Item %d..", "项目 %d.."},
|
||||
{"Scrolling", "滚动"},
|
||||
{"Decoration", "装饰"},
|
||||
{"Item = %d", "项目 = %d"},
|
||||
{"Track", "跟踪"},
|
||||
{"+%.0f px", "+%.0f px"},
|
||||
{"Scroll Offset", "滚动偏移"},
|
||||
{"X/Y = %.0f px", "X/Y = %.0f px"},
|
||||
{"Scroll To Pos", "滚动到位置"},
|
||||
{"Top", "顶部"},
|
||||
{"25%", "25%"},
|
||||
{"Center", "居中"},
|
||||
{"75%", "75%"},
|
||||
{"Bottom", "底部"},
|
||||
{"Item %d", "项目 %d"},
|
||||
{"%.0f/%.0f", "%.0f/%.0f"},
|
||||
{"Left", "左"},
|
||||
{"Right", "右"},
|
||||
{"%s\n%.0f/%.0f", "%s\n%.0f/%.0f"},
|
||||
{"Lines", "行数"},
|
||||
{"Scroll from code", "代码控制滚动"},
|
||||
{"<<", "<<"},
|
||||
{">>", ">>"},
|
||||
{"Show Horizontal contents size demo window", "显示水平内容尺寸演示窗口"},
|
||||
{"Horizontal contents size demo window", "水平内容尺寸演示窗口"},
|
||||
{"Use 'Metrics->Tools->Show windows rectangles' to visualize rectangles.", "使用 'Metrics->Tools->Show windows rectangles' 可视化矩形。"},
|
||||
{"H-scrollbar", "水平滚动条"},
|
||||
{"Text wrapped", "自动换行文本"},
|
||||
{"Columns", "列"},
|
||||
{"Tab bar", "标签栏"},
|
||||
{"Child", "子窗口"},
|
||||
{"Explicit content size", "显式内容尺寸"},
|
||||
{"Scroll %.1f/%.1f %.1f/%.1f", "滚动 %.1f/%.1f %.1f/%.1f"},
|
||||
{"this is a 300-wide button", "这是一个 300 宽的按钮"},
|
||||
{"this is a tree node", "这是一个树节点"},
|
||||
{"another one of those tree node...", "另一个树节点..."},
|
||||
{"Some tree contents", "树节点内容"},
|
||||
{"CollapsingHeader", "折叠标题"},
|
||||
{"This text should automatically wrap on the edge of the work rectangle.", "这段文字应在工作区边缘自动换行。"},
|
||||
{"Tables:", "表格:"},
|
||||
{"Width %.2f", "宽度 %.2f"},
|
||||
{"Columns:", "列:"},
|
||||
{"Text Clipping", "文字裁剪"},
|
||||
{"(Click and drag to scroll)", "(点击并拖拽以滚动)"},
|
||||
{"Overlap Mode", "重叠模式"},
|
||||
{"Enable AllowOverlap", "启用重叠允许"},
|
||||
{"Button 1", "按钮 1"},
|
||||
{"Button 2", "按钮 2"},
|
||||
{"Some Selectable", "可选项"},
|
||||
// === Step 10: Popups + About + UserGuide ===
|
||||
{"Popups", "弹窗"},
|
||||
{"Select..", "选择.."},
|
||||
{"Right-click here", "在此右键"},
|
||||
{"right-click me!", "右键点我!"},
|
||||
{"right-click on this text", "右键点击此文字"},
|
||||
{"Modal windows", "模态框"},
|
||||
{"Delete?", "确认删除?"},
|
||||
{"This is a modal window", "这是一个模态框"},
|
||||
{"Yes", "是"},
|
||||
{"No", "否"},
|
||||
{"Stacked modals", "嵌套模态框"},
|
||||
{"Open another modal", "打开另一个模态框"},
|
||||
{"Popups in a menu", "菜单中的弹窗"},
|
||||
{"Menus", "菜单"},
|
||||
{"Context menus", "右键菜单"},
|
||||
{"Menu in a popup", "弹窗内菜单"},
|
||||
{"Popups with window restoring focus", "弹窗恢复焦点"},
|
||||
{"Open a popup!", "打开弹窗!"},
|
||||
{"Dear ImGui is an immediate mode GUI library for C++.", "Dear ImGui 是一个 C++ 即时模式 GUI 库。"},
|
||||
{"License:", "许可证:"},
|
||||
{"Build Information:", "构建信息:"},
|
||||
{"User Guide", "用户指南"},
|
||||
{"PROGRAMMER GUIDE", "程序员指南"},
|
||||
{"MOUSE & DRAG AND DROP", "鼠标与拖放"},
|
||||
{"KEYBOARD, GAMEPAD & FOCUS", "键盘、手柄与焦点"},
|
||||
{"Read 'Programmer Guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.", "阅读 imgui.cpp 中的《程序员指南》了解集成方法。"},
|
||||
{"Understood!", "明白了!"},
|
||||
{"Oops, button is disabled!", "按钮已被禁用!"},
|
||||
// === Step 11: Tables (first half) ===
|
||||
{"Borders, background", "边框与背景"},
|
||||
{"Resizable, stretch", "可缩放(拉伸)"},
|
||||
{"Resizable, fixed", "可缩放(固定)"},
|
||||
{"Resizable, mixed", "可缩放(混合)"},
|
||||
{"Sizing policies", "尺寸策略"},
|
||||
{"Vertical scrolling, with clipping", "垂直滚动(带裁剪)"},
|
||||
{"Horizontal scrolling", "水平滚动"},
|
||||
{"Columns flags", "列标志"},
|
||||
{"Columns widths", "列宽"},
|
||||
{"Nested tables", "嵌套表格"},
|
||||
{"Row height", "行高"},
|
||||
{"Outer size", "外部尺寸"},
|
||||
{"Reorderable, hideable, with headers", "可重排、可隐藏(带表头)"},
|
||||
{"Padding", "内边距"},
|
||||
{"Disable tree indentation", "禁用树缩进"},
|
||||
{"Expand all", "展开全部"},
|
||||
{"Collapse all", "折叠全部"},
|
||||
{"Display headers", "显示表头"},
|
||||
// === Step 11b: Tables (second half, part 1) ===
|
||||
{"Headers", "表头"},
|
||||
{"Row flags", "行标志"},
|
||||
{"Reordering", "重排"},
|
||||
{"Hiding", "隐藏"},
|
||||
{"Sorting", "排序"},
|
||||
{"Column types", "列类型"},
|
||||
{"Borders", "边框"},
|
||||
{"Full headers", "完整表头"},
|
||||
{"Foot0", "底部0"},
|
||||
{"Foot1", "底部1"},
|
||||
{"Foot2", "底部2"},
|
||||
{"Seat#", "座位号"},
|
||||
{"Age", "年龄"},
|
||||
{"Average", "平均"},
|
||||
{"Sum", "总计"},
|
||||
{"First Name", "名"},
|
||||
{"Last Name", "姓"},
|
||||
{"Bream", "鲷鱼"},
|
||||
{"Haddock", "黑线鳕"},
|
||||
{"Mackerel", "鲭鱼"},
|
||||
{"Pollock", "鳕鱼"},
|
||||
{"Tilefish", "马头鱼"},
|
||||
{"Dragonfruit", "火龙果"},
|
||||
{"Eggplant", "茄子"},
|
||||
{"Fig", "无花果"},
|
||||
{"Guava", "番石榴"},
|
||||
{"Vertical headers", "垂直表头"},
|
||||
{"Custom headers", "自定义表头"},
|
||||
{"Row background color", "行背景色"},
|
||||
// === Step 11b: Tables (second half, part 2) ===
|
||||
{"Background color", "背景色"},
|
||||
{"Tree view", "树形视图"},
|
||||
{"Item width", "条目宽度"},
|
||||
{"Angled headers", "斜角表头"},
|
||||
{"Style settings", "样式设置"},
|
||||
{"Synced instances", "同步实例"},
|
||||
{"Legacy Columns API", "旧版 Columns API"},
|
||||
{"Mixed items", "混合条目"},
|
||||
{"Word-wrapping", "自动换行"},
|
||||
{"Horizontal Scrolling", "水平滚动"},
|
||||
{"Tree", "树形"},
|
||||
{"Name", "名称"},
|
||||
{"Type", "类型"},
|
||||
{"small", "小"},
|
||||
{"half", "半"},
|
||||
{"right-align", "右对齐"},
|
||||
{"Apricot", "杏"},
|
||||
{"Cherry", "樱桃"},
|
||||
{"One", "一"},
|
||||
{"Two", "二"},
|
||||
{"Three", "三"},
|
||||
{"ID", "ID"},
|
||||
{"Action", "操作"},
|
||||
{"Quantity", "数量"},
|
||||
{"Description", "描述"},
|
||||
{"Without border:", "无边框:"},
|
||||
{"With border:", "有边框:"},
|
||||
{"Path", "路径"},
|
||||
{"Hovered", "悬停"},
|
||||
{"horizontal", "水平"},
|
||||
{"vertical", "垂直"},
|
||||
{"Long text that is likely to clip", "很可能被截断的长文本"},
|
||||
{"Hello", "你好"},
|
||||
{"An extra line here.", "这里额外一行。"},
|
||||
{"Category A", "类别 A"},
|
||||
{"Category B", "类别 B"},
|
||||
{"Category C", "类别 C"},
|
||||
{"Blah blah blah", "巴拉巴拉巴拉"},
|
||||
{"Node contents", "节点内容"},
|
||||
{"Tree in column", "列中的树"},
|
||||
{"Even more contents", "更多内容"},
|
||||
{"The quick brown fox jumps over the lazy dog", "快速的棕色狐狸跳过了懒狗"},
|
||||
// === Step 12: Inputs + Style Editor ===
|
||||
{"This is a simplified view. See more detailed input state:\n- in 'Tools->Metrics/Debugger->Inputs'.\n- in 'Tools->Debug Log->IO'.", "这是简化视图。详细输入状态请查看:\n- 'Tools->Metrics/Debugger->Inputs'\n- 'Tools->Debug Log->IO'"},
|
||||
{"Mouse pos: (%g, %g)", "鼠标位置:(%g, %g)"},
|
||||
{"Mouse pos: <INVALID>", "鼠标位置:<无效>"},
|
||||
{"Mouse delta: (%g, %g)", "鼠标增量:(%g, %g)"},
|
||||
{"Mouse down:", "鼠标按下:"},
|
||||
{"Mouse wheel: %.1f", "鼠标滚轮:%.1f"},
|
||||
{"Mouse clicked count:", "鼠标点击次数:"},
|
||||
{"Keys down:", "按下的键:"},
|
||||
{"Keys mods: %s%s%s%s", "修饰键:%s%s%s%s"},
|
||||
{"Chars queue:", "字符队列:"},
|
||||
{"Outputs", "输出"},
|
||||
{"WantCapture override", "捕获覆盖"},
|
||||
{"Hovering the colored canvas will override io.WantCaptureXXX fields.\nNotice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering and true when clicking.", "悬停在彩色画布上将覆盖 io.WantCaptureXXX 字段。\n注意通常情况下(设为 none 时),悬停时 io.WantCaptureKeyboard 为 false,点击时为 true。"},
|
||||
{"None", "无"},
|
||||
{"Set to false", "设为 false"},
|
||||
{"Set to true", "设为 true"},
|
||||
{"SetNextFrameWantCaptureMouse() on hover", "悬停时调用 SetNextFrameWantCaptureMouse()"},
|
||||
{"SetNextFrameWantCaptureKeyboard() on hover", "悬停时调用 SetNextFrameWantCaptureKeyboard()"},
|
||||
{"Shortcuts", "快捷键"},
|
||||
{"Using SetNextItemShortcut()", "使用 SetNextItemShortcut()"},
|
||||
{"Using Shortcut()", "使用 Shortcut()"},
|
||||
{"Factor", "系数"},
|
||||
{"Press Ctrl+A and see who receives it!", "按 Ctrl+A 查看谁接收到了!"},
|
||||
{"Current mouse cursor = %d: %s", "当前鼠标光标 = %d: %s"},
|
||||
{"Hover to see mouse cursors:", "悬停查看鼠标光标:"},
|
||||
{"Tabbing", "Tab 键导航"},
|
||||
{"Use Tab/Shift+Tab to cycle through keyboard editable fields.", "使用 Tab/Shift+Tab 在可编辑字段间切换。"},
|
||||
{"Focus from code", "代码设置焦点"},
|
||||
{"Focus on 1", "聚焦到 1"},
|
||||
{"Focus on 2", "聚焦到 2"},
|
||||
{"Focus on 3", "聚焦到 3"},
|
||||
{"Focus on X", "聚焦到 X"},
|
||||
{"Focus on Y", "聚焦到 Y"},
|
||||
{"Focus on Z", "聚焦到 Z"},
|
||||
{"Dragging", "拖拽"},
|
||||
{"GetMouseDragDelta(0):", "GetMouseDragDelta(0):"},
|
||||
// Style Editor
|
||||
{"For instructions, see:", "使用说明请查看:"},
|
||||
{"Save Ref", "保存参考"},
|
||||
{"Revert Ref", "还原参考"},
|
||||
{"Details", "详细设置"},
|
||||
{"Sizes", "尺寸"},
|
||||
{"Colors", "颜色"},
|
||||
{"Fonts", "字体"},
|
||||
{"Rendering", "渲染"},
|
||||
{"Only Modified Colors", "仅显示修改的颜色"},
|
||||
{"Filter colors", "过滤颜色"},
|
||||
{"Opaque", "不透明"},
|
||||
{"Alpha", "Alpha"},
|
||||
{"Both", "两者"},
|
||||
{"Revert", "还原"},
|
||||
{"Anti-aliased lines", "抗锯齿线条"},
|
||||
{"Anti-aliased lines use texture", "抗锯齿线条使用纹理"},
|
||||
{"Anti-aliased fill", "抗锯齿填充"},
|
||||
{"Curve Tessellation Tolerance", "曲线细分容差"},
|
||||
{"Circle Tessellation Max Error", "圆形细分最大误差"},
|
||||
// === Step 13: Example Apps ===
|
||||
{"Example: Main Menu Bar", "示例:主菜单栏"},
|
||||
{"Edit", "编辑"},
|
||||
{"Undo", "撤销"},
|
||||
{"Redo", "重做"},
|
||||
{"Cut", "剪切"},
|
||||
{"Paste", "粘贴"},
|
||||
{"Example: Console", "示例:控制台"},
|
||||
{"Command:", "命令:"},
|
||||
{"Clear", "清空"},
|
||||
{"Scroll to bottom", "滚动到底部"},
|
||||
{"Auto-scroll", "自动滚动"},
|
||||
{"Enter 'HELP' for help.", "输入 'HELP' 获取帮助。"},
|
||||
{"Example: Log", "示例:日志"},
|
||||
{"Enable scrolling", "启用自动滚动"},
|
||||
{"Add Dummy Text", "添加示例文字"},
|
||||
{"Add Dummy Error", "添加示例错误"},
|
||||
{"Example: Simple Layout", "示例:简单布局"},
|
||||
{"Example: Property editor", "示例:属性编辑器"},
|
||||
{"Example: Long text display", "示例:长文本显示"},
|
||||
{"Example: Auto-resizing window", "示例:自动缩放窗口"},
|
||||
{"Example: Constrained-resizing window", "示例:约束缩放窗口"},
|
||||
{"Example: Simple overlay", "示例:简单浮层"},
|
||||
{"n/a", "不可用"},
|
||||
{"Example: Fullscreen window", "示例:全屏窗口"},
|
||||
{"Example: Manipulating window titles", "示例:操控窗口标题"},
|
||||
{"Example: Custom rendering", "示例:自定义渲染"},
|
||||
{"Example: Documents", "示例:文档管理"},
|
||||
{"(Untitled)", "(未命名)"},
|
||||
{"Erase", "擦除"},
|
||||
{"Stroke", "描边"},
|
||||
{"Primitives", "图元"},
|
||||
{"BG/FG draw lists", "前/后景绘制列表"},
|
||||
{"Mesh", "网格"},
|
||||
{"Textures", "纹理"},
|
||||
{"Example: Assets Browser", "示例:资产浏览器"},
|
||||
{"HELP", "帮助"},
|
||||
{"HISTORY", "历史"},
|
||||
{"CLEAR", "清空"},
|
||||
{"Close Me", "关闭"},
|
||||
// Additional strings from Step 13
|
||||
{"Use work area instead of main area", "使用工作区而非主区域"},
|
||||
{"Close this window", "关闭此窗口"},
|
||||
{"This window has a changing title.", "此窗口具有动态标题。"},
|
||||
{"Simple overlay\n(right-click to change position)", "简单浮层\n(右键更改位置)"},
|
||||
{"Mouse Position: <invalid>", "鼠标位置:<无效>"},
|
||||
{"(Hold Shift to display a dummy viewport)", "(按住 Shift 显示虚拟视口)"},
|
||||
{"Auto-resize", "自动缩放"},
|
||||
{"Constraint", "约束"},
|
||||
{"Use Clipper", "使用裁剪器"},
|
||||
{"Printing unusually long amount of text.", "正在打印超长文本。"},
|
||||
{"Test type", "测试类型"},
|
||||
{"Gradients", "渐变"},
|
||||
{"All primitives", "所有图元"},
|
||||
{"Draw in Background draw list", "在背景绘制列表中绘制"},
|
||||
{"Draw in Foreground draw list", "在前景绘制列表中绘制"},
|
||||
{"Blue shape is drawn first: appears in back", "蓝色形状先绘制:显示在后面"},
|
||||
{"Red shape is drawn after: appears in front", "红色形状后绘制:显示在前面"},
|
||||
{"Blue shape is drawn first, into channel 1: appears in front", "蓝色形状先绘制到通道1:显示在前面"},
|
||||
{"Red shape is drawn after, into channel 0: appears in back", "红色形状后绘制到通道0:显示在后面"},
|
||||
{"After reordering, contents of channel 0 appears below channel 1.", "重排后,通道0的内容显示在通道1下方。"},
|
||||
{"Close All Documents", "关闭所有文档"},
|
||||
{"Rename..", "重命名.."},
|
||||
{"Modify", "修改"},
|
||||
{"Save change to the following items?", "将更改保存到以下项目?"},
|
||||
{"Cancel", "取消"},
|
||||
{"Add 10000 items", "添加10000个项目"},
|
||||
{"Clear items", "清除项目"},
|
||||
{"Delete", "删除"},
|
||||
{"Contents", "内容"},
|
||||
{"Selection Behavior", "选择行为"},
|
||||
{"Layout", "布局"},
|
||||
{"Show Type Overlay", "显示类型覆盖"},
|
||||
{"Allow Sorting", "允许排序"},
|
||||
{"Allow box-selection", "允许框选"},
|
||||
{"Allow box-selection from selected items", "允许从已选项目框选"},
|
||||
{"Allow dragging unselected item", "允许拖拽未选项目"},
|
||||
{"Icon Size", "图标大小"},
|
||||
{"Icon Spacing", "图标间距"},
|
||||
{"Icon Hit Spacing", "图标命中间距"},
|
||||
{"Stretch Spacing", "拉伸间距"},
|
||||
{"Use ScrollX", "启用水平滚动"},
|
||||
{"%d assets", "%d 个资产"},
|
||||
{"Selection: %d items", "已选:%d 个项目"},
|
||||
{"Help", "帮助"},
|
||||
// === main.mm window ===
|
||||
// "Hello, world!" and "This is some useful text." are intentionally kept in English
|
||||
// as they are universally recognized programming example strings.
|
||||
{"Demo Window", "演示窗口"},
|
||||
{"Another Window", "另一个窗口"},
|
||||
// "float" is kept as-is: it labels a SliderFloat() demonstrating the float type.
|
||||
{"clear color", "背景颜色"},
|
||||
{"Application average %.3f ms/frame (%.1f FPS)", "平均 %.3f 毫秒/帧(%.1f FPS)"},
|
||||
{"Hello from another window!", "来自另一个窗口的问候!"},
|
||||
{"Close Me", "关闭"},
|
||||
// === Help collapsing section ===
|
||||
{"ABOUT THIS DEMO:", "关于本演示:"},
|
||||
{"Sections below are demonstrating many aspects of the library.", "下方各章节展示了库的众多特性。"},
|
||||
{"The \"Examples\" menu above leads to more demo contents.", "上方「示例」菜单包含更多演示内容。"},
|
||||
{"The \"Tools\" menu above gives access to: About Box, Style Editor,\nand Metrics/Debugger (general purpose Dear ImGui debugging tool).", "上方「工具」菜单可访问:关于弹窗、样式编辑器\n以及指标/调试器(通用 Dear ImGui 调试工具)。"},
|
||||
{"Web demo (w/ source code browser): ", "在线演示(含源码浏览器):"},
|
||||
{"PROGRAMMER GUIDE:", "程序员指南:"},
|
||||
{"See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!", "参阅 imgui_demo.cpp 中的 ShowDemoWindow() 代码。← 你在这里!"},
|
||||
{"See comments in imgui.cpp.", "参阅 imgui.cpp 中的注释。"},
|
||||
{"See example applications in the examples/ folder.", "参阅 examples/ 目录下的示例程序。"},
|
||||
{"Read the FAQ at ", "阅读 FAQ:"},
|
||||
{"Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.", "设置 'io.ConfigFlags |= NavEnableKeyboard' 以启用键盘控制。"},
|
||||
{"Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.", "设置 'io.ConfigFlags |= NavEnableGamepad' 以启用手柄控制。"},
|
||||
{"USER GUIDE:", "用户指南:"},
|
||||
// === Configuration panel HelpMarker tooltips ===
|
||||
{"Enable keyboard controls.", "启用键盘控制。"},
|
||||
{"Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.", "启用手柄控制。需要后端设置 io.BackendFlags |= ImGuiBackendFlags_HasGamepad。\n\n详情请阅读 imgui.cpp 中的说明。"},
|
||||
{"Instruct dear imgui to disable mouse inputs and interactions.", "禁止 Dear ImGui 处理鼠标输入和交互。"},
|
||||
{"Instruct backend to not alter mouse cursor shape and visibility.", "禁止后端修改鼠标光标形状和可见性。"},
|
||||
{"Instruct dear imgui to disable keyboard inputs and interactions.", "禁止 Dear ImGui 处理键盘输入和交互。"},
|
||||
{"Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.", "启用输入队列滴流:同一帧内提交的某些事件(如按下+抬起)将分散到多帧处理,改善低帧率下的交互体验。"},
|
||||
{"Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).", "让 Dear ImGui 自行渲染鼠标光标。通过 GPU 渲染的软件光标会比硬件光标略有延迟,但与其他画面更同步。\n\n部分桌面应用会同时使用两种光标(如仅在拖拽/缩放时启用软件光标)。"},
|
||||
{"Directional/tabbing navigation teleports the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is difficult", "方向键/Tab 导航会瞬移鼠标光标。在难以移动虚拟鼠标的电视/主机系统上很有用。"},
|
||||
{"Pressing Escape clears focused item.", "按 Escape 键清除焦点控件。"},
|
||||
{"Pressing Escape clears focused window.", "按 Escape 键清除焦点窗口。"},
|
||||
{"Using directional navigation key makes the cursor visible. Mouse click hides the cursor.", "使用方向导航键时显示光标,鼠标点击时隐藏光标。"},
|
||||
{"Navigation cursor is always visible.", "导航光标始终可见。"},
|
||||
{"Enable resizing of windows from their edges and from the lower-left corner.\nThis requires ImGuiBackendFlags_HasMouseCursors for better mouse cursor feedback.", "允许从窗口边缘和左下角调整大小。\n需要 ImGuiBackendFlags_HasMouseCursors 以获得更好的光标反馈。"},
|
||||
{"*EXPERIMENTAL* Ctrl+C copy the contents of focused window into the clipboard.\n\nExperimental because:\n- (1) has known issues with nested Begin/End pairs.\n- (2) text output quality varies.\n- (3) text output is in submission order rather than spatial order.", "*实验性* Ctrl+C 将焦点窗口内容复制到剪贴板。\n\n实验性原因:\n- (1) 嵌套 Begin/End 有已知问题。\n- (2) 文字输出质量不稳定。\n- (3) 输出按提交顺序而非空间顺序排列。"},
|
||||
{"Enable scrolling page by page when clicking outside the scrollbar grab.\nWhen disabled, always scroll to clicked location.\nWhen enabled, Shift+Click scrolls to clicked location.", "点击滚动条轨道时逐页滚动。\n禁用时:始终滚动到点击位置。\n启用时:Shift+点击滚动到点击位置。"},
|
||||
{"Enable blinking cursor (optional as some users consider it to be distracting).", "启用闪烁光标(部分用户认为会分散注意力,可选)。"},
|
||||
{"Pressing Enter will reactivate item and select all text (single-line only).", "按 Enter 键重新激活控件并全选文字(仅单行)。"},
|
||||
{"Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).", "点击 DragXXX 控件后不移动即可切换为文本输入模式。"},
|
||||
{"Swap Cmd<>Ctrl keys, enable various MacOS style behaviors.", "交换 Cmd<>Ctrl 键,启用各种 macOS 风格行为。"},
|
||||
});
|
||||
}
|
||||
} s_zh_cn;
|
||||
} // namespace
|
||||
25
i18n/tools/extract_strings.py
Normal file
25
i18n/tools/extract_strings.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
用法:python3 extract_strings.py imgui_demo.cpp 302 737
|
||||
输出 zh_CN.cpp 条目骨架(key=英文,value 留空供人工翻译)
|
||||
"""
|
||||
import sys, re
|
||||
|
||||
def extract(path, start, end):
|
||||
with open(path) as f:
|
||||
lines = f.readlines()
|
||||
chunk = ''.join(lines[start-1:end-1])
|
||||
strings = re.findall(r'"([^"\n]{2,80})"', chunk)
|
||||
seen = set()
|
||||
results = []
|
||||
skip = re.compile(r'^(##|###|%[0-9.]*[dfsx]$|[0-9.]+$)')
|
||||
for s in strings:
|
||||
if s in seen or skip.match(s): continue
|
||||
seen.add(s)
|
||||
results.append(s)
|
||||
for s in results:
|
||||
escaped = s.replace('\\', '\\\\').replace('"', '\\"')
|
||||
print(f' {{"{escaped}", ""}},')
|
||||
|
||||
if __name__ == '__main__':
|
||||
extract(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
|
||||
1464
imgui_demo.cpp
1464
imgui_demo.cpp
File diff suppressed because it is too large
Load diff
206
misc/i18n/README.md
Normal file
206
misc/i18n/README.md
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
# Dear ImGui — i18n (Internationalization)
|
||||
|
||||
Runtime language switching for `imgui_demo.cpp`.
|
||||
Currently ships with **Simplified Chinese** (`zh_CN`).
|
||||
|
||||
---
|
||||
|
||||
## How It Works
|
||||
|
||||
| Component | Role |
|
||||
|-----------|------|
|
||||
| `imgui_i18n.h` | `Tr()` macro + namespace declaration |
|
||||
| `imgui_i18n.cpp` | Lookup table, fallback, `$1`/`$2` placeholder substitution |
|
||||
| `locale/zh_CN.cpp` | Chinese translation table (static initializer, auto-registered) |
|
||||
| `tools/extract_strings.py` | Helper to extract translatable strings from a source range |
|
||||
|
||||
Every user-visible string literal in `imgui_demo.cpp` is wrapped with `Tr("...")`.
|
||||
`Tr()` looks up the active locale table and returns the translated string, or falls back to the original English if no translation exists.
|
||||
|
||||
### Opt-in build flag
|
||||
|
||||
Define **`IMGUI_DEMO_ENABLE_I18N`** in your build to activate i18n.
|
||||
Without it, `Tr(s)` expands to `(s)` at compile time — zero overhead, no extra files needed.
|
||||
|
||||
---
|
||||
|
||||
## Quick Start (macOS example_apple_metal)
|
||||
|
||||
```bash
|
||||
# Makefile already includes IMGUI_DEMO_ENABLE_I18N and the i18n sources.
|
||||
cd examples/example_apple_metal
|
||||
make && ./example_apple_metal
|
||||
# Open the Language menu in the demo window menu bar → switch to 中文
|
||||
```
|
||||
|
||||
For other platforms/examples, see **Integrating into Your Build** below.
|
||||
|
||||
---
|
||||
|
||||
## Adding a New Language
|
||||
|
||||
### 1. Create a locale file
|
||||
|
||||
Copy `locale/zh_CN.cpp` to `locale/<locale_id>.cpp` (e.g. `locale/ja_JP.cpp`).
|
||||
|
||||
```cpp
|
||||
// locale/ja_JP.cpp
|
||||
#include "../imgui_i18n.h"
|
||||
|
||||
namespace {
|
||||
struct JaJPRegistrar {
|
||||
JaJPRegistrar() {
|
||||
imgui_i18n::registerLocale("ja_JP", {
|
||||
{"Configuration", "設定"},
|
||||
{"Dear ImGui Demo","Dear ImGui デモ"},
|
||||
// ... add all entries
|
||||
});
|
||||
}
|
||||
} s_ja_jp;
|
||||
} // namespace
|
||||
```
|
||||
|
||||
**Key rules:**
|
||||
- The **key** is the exact English string as it appears in `imgui_demo.cpp` (including punctuation and newlines).
|
||||
- Missing keys automatically fall back to English — you can ship a partial translation.
|
||||
- For strings containing `##` (ImGui internal IDs like `"Configuration##2"`), the key in the table is only the visible part (`"Configuration"`); the `##2` suffix is appended in code.
|
||||
|
||||
### 2. Add the locale file to your build
|
||||
|
||||
**Makefile (Linux/macOS):**
|
||||
```makefile
|
||||
SOURCES += $(IMGUI_DIR)/misc/i18n/imgui_i18n.cpp
|
||||
SOURCES += $(IMGUI_DIR)/misc/i18n/locale/ja_JP.cpp # add your new locale
|
||||
CXXFLAGS += -I$(IMGUI_DIR)/i18n -DIMGUI_DEMO_ENABLE_I18N
|
||||
```
|
||||
|
||||
**CMake:**
|
||||
```cmake
|
||||
target_sources(my_app PRIVATE
|
||||
${IMGUI_DIR}/misc/i18n/imgui_i18n.cpp
|
||||
${IMGUI_DIR}/misc/i18n/locale/ja_JP.cpp
|
||||
)
|
||||
target_include_directories(my_app PRIVATE ${IMGUI_DIR}/i18n)
|
||||
target_compile_definitions(my_app PRIVATE IMGUI_DEMO_ENABLE_I18N)
|
||||
```
|
||||
|
||||
**Xcode:** Add both `.cpp` files to the target's *Compile Sources* phase.
|
||||
|
||||
### 3. Add a menu item for the new language
|
||||
|
||||
In `imgui_demo.cpp`, find the Language menu (search for `BeginMenu(Tr("Language"))`):
|
||||
|
||||
```cpp
|
||||
if (ImGui::MenuItem("日本語", nullptr, is_ja) && !is_ja)
|
||||
{
|
||||
imgui_i18n::setLocale("ja_JP");
|
||||
#if defined(__APPLE__)
|
||||
g_need_font_rebuild = true; // triggers CJK font reload on Apple Metal
|
||||
#endif
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Font loading (CJK / non-Latin scripts)
|
||||
|
||||
For languages requiring non-Latin glyphs, add font loading logic in your platform's
|
||||
`main` file (see `examples/example_apple_metal/main.mm` → `RebuildFonts()` for reference).
|
||||
|
||||
The pattern:
|
||||
1. Call `io.Fonts->AddFontDefault(&cfg)` with explicit `SizePixels` first (required by ImGui v1.92+).
|
||||
2. Merge the target-language font with `cfg.MergeMode = true`.
|
||||
3. Choose glyph ranges: use `io.Fonts->GetGlyphRangesChineseSimplifiedCommon()` for Chinese,
|
||||
`GetGlyphRangesJapanese()` for Japanese, etc.
|
||||
4. Call `io.Fonts->Build()`.
|
||||
|
||||
---
|
||||
|
||||
## Translation Guidelines
|
||||
|
||||
Follow these rules when translating strings to ensure quality and consistency.
|
||||
|
||||
### What to translate
|
||||
|
||||
Translate user-visible UI labels: menu items, button labels, window titles, section
|
||||
headers, tooltip descriptions, and status messages.
|
||||
|
||||
### What NOT to translate
|
||||
|
||||
| Category | Example | Reason |
|
||||
|----------|---------|--------|
|
||||
| Universally recognized programming examples | `"Hello, world!"` | Part of global programming culture; keeping English avoids confusion for learners following tutorials |
|
||||
| Standard boilerplate example text | `"This is some useful text."` | Canonical ImGui getting-started template text |
|
||||
| C++ type/variable names used as labels | `"float"`, `"counter = %d"` | Labels the underlying type or variable name, not a description |
|
||||
| Intentional filler/nonsense | `"blah blah blah"` | The meaninglessness is the message; translating it to real words defeats the purpose |
|
||||
| API / function names | `"IsItemHovered()"` | Must remain identical to the actual API; adding an entry that maps to itself is redundant |
|
||||
| Brand / product names | `"Dear ImGui"`, `"dear imgui"` | Proper nouns; do not translate |
|
||||
| `##`-suffixed ImGui IDs | `"Config##2"` | The `##` part is a disambiguation suffix handled in code, not user-visible |
|
||||
|
||||
### Translation quality rules
|
||||
|
||||
1. **Accuracy over literalness.** Translate meaning, not word-by-word.
|
||||
Bad: `Metrics` → `性能` (performance)
|
||||
Good: `Metrics` → `指标` (indicators/measurements)
|
||||
|
||||
2. **Preserve format specifiers.** `%d`, `%s`, `%.3f`, `$1`, `$2` must appear unchanged in the translated string.
|
||||
|
||||
3. **Preserve newlines.** `\n` positions in the translation may differ from the English, but must be present where the UI needs line breaks.
|
||||
|
||||
4. **Preserve punctuation intent.** If the English ends with `:`, the translation should too (adjusted for the target language's punctuation conventions).
|
||||
|
||||
5. **Redundant identity entries are noise.** If a string needs no translation (e.g. an API function name), do **not** add `{"Foo()", "Foo()"}` to the table. The fallback mechanism returns the key automatically.
|
||||
|
||||
---
|
||||
|
||||
## Extracting Strings for Translation
|
||||
|
||||
Use the helper script to generate a translation skeleton for a range of lines:
|
||||
|
||||
```bash
|
||||
cd imgui-master # or wherever imgui_demo.cpp lives
|
||||
python3 misc/i18n/tools/extract_strings.py imgui_demo.cpp <start_line> <end_line>
|
||||
```
|
||||
|
||||
Output is ready-to-paste `{"English key", ""},` entries.
|
||||
Paste them into your locale file and fill in the translated values.
|
||||
|
||||
---
|
||||
|
||||
## Integrating into Your Build (Other Examples)
|
||||
|
||||
Only `example_apple_metal` ships with i18n enabled by default.
|
||||
To enable it for any other example:
|
||||
|
||||
1. Add `imgui_i18n.cpp` and your locale `.cpp` files to the build.
|
||||
2. Add `-I<imgui_root>/i18n` to include paths.
|
||||
3. Add `-DIMGUI_DEMO_ENABLE_I18N` to compiler flags.
|
||||
4. Add font loading + language-switch UI to your platform's `main` file
|
||||
(use `examples/example_apple_metal/main.mm` as a reference).
|
||||
|
||||
---
|
||||
|
||||
## API Reference
|
||||
|
||||
```cpp
|
||||
// imgui_i18n.h (available when IMGUI_DEMO_ENABLE_I18N is defined)
|
||||
|
||||
Tr("key") // translate key, return const char*
|
||||
TrF("Draw $1 of $2", {"3","10"}) // translate + substitute placeholders
|
||||
|
||||
imgui_i18n::setLocale("zh_CN"); // switch language (call before NewFrame)
|
||||
imgui_i18n::getLocale(); // returns current locale string ("" = English)
|
||||
imgui_i18n::registerLocale( // called by locale/*.cpp static initializers
|
||||
"locale_id",
|
||||
{ {"English key", "Translation"}, ... }
|
||||
);
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Current Translations
|
||||
|
||||
| Locale | Language | Coverage |
|
||||
|--------|----------|----------|
|
||||
| *(default)* | English | 100% (source) |
|
||||
| `zh_CN` | Simplified Chinese | ~100% of `imgui_demo.cpp` |
|
||||
|
||||
Contributions welcome — see **Adding a New Language** above.
|
||||
61
misc/i18n/imgui_i18n.cpp
Normal file
61
misc/i18n/imgui_i18n.cpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
// i18n/imgui_i18n.cpp
|
||||
#include "imgui_i18n.h"
|
||||
#include <unordered_map>
|
||||
#include <string>
|
||||
|
||||
namespace imgui_i18n {
|
||||
|
||||
// Meyers Singleton: guarantees initialization before first use across translation units, avoiding SIOF.
|
||||
static std::string& locale() {
|
||||
static std::string s;
|
||||
return s;
|
||||
}
|
||||
|
||||
static std::unordered_map<std::string, std::unordered_map<std::string, std::string>>& tables() {
|
||||
static std::unordered_map<std::string, std::unordered_map<std::string, std::string>> s;
|
||||
return s;
|
||||
}
|
||||
|
||||
void setLocale(const char* loc) {
|
||||
locale() = loc ? loc : "";
|
||||
}
|
||||
|
||||
const char* getLocale() {
|
||||
return locale().c_str();
|
||||
}
|
||||
|
||||
const char* translate(const char* key) {
|
||||
if (!key) return "";
|
||||
if (locale().empty()) return key; // English fast path
|
||||
auto it = tables().find(locale());
|
||||
if (it == tables().end()) return key;
|
||||
auto it2 = it->second.find(key);
|
||||
if (it2 == it->second.end()) return key;
|
||||
return it2->second.c_str();
|
||||
}
|
||||
|
||||
std::string fmt(const char* key, std::initializer_list<std::string> args) {
|
||||
std::string result = translate(key);
|
||||
int i = 1;
|
||||
for (const auto& arg : args) {
|
||||
std::string ph = "$" + std::to_string(i++);
|
||||
size_t pos;
|
||||
while ((pos = result.find(ph)) != std::string::npos)
|
||||
result.replace(pos, ph.size(), arg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void registerLocale(
|
||||
const char* loc,
|
||||
std::initializer_list<std::pair<const char*, const char*>> entries)
|
||||
{
|
||||
// All registerLocale() calls must complete before the first translate() call (normally guaranteed
|
||||
// by static initializers). Do not add entries after translate() has been called: unordered_map
|
||||
// rehashing would invalidate the c_str() pointers returned by translate().
|
||||
auto& table = tables()[loc];
|
||||
for (const auto& e : entries)
|
||||
table[e.first] = e.second;
|
||||
}
|
||||
|
||||
} // namespace imgui_i18n
|
||||
47
misc/i18n/imgui_i18n.h
Normal file
47
misc/i18n/imgui_i18n.h
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
// dear imgui - i18n (internationalization) module
|
||||
// Provides runtime language switching for imgui_demo.cpp.
|
||||
//
|
||||
// Usage:
|
||||
// Define IMGUI_DEMO_ENABLE_I18N in your build system to opt in.
|
||||
// Without it, Tr(s) is a no-op and other examples are unaffected.
|
||||
//
|
||||
// See i18n/README.md for details and how to add a new language.
|
||||
#pragma once
|
||||
|
||||
#ifdef IMGUI_DEMO_ENABLE_I18N
|
||||
|
||||
#include <string>
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
// Wrap every user-visible string literal in imgui_demo.cpp with Tr().
|
||||
#define Tr(s) imgui_i18n::translate(s)
|
||||
// Variant with $1/$2/... placeholder substitution.
|
||||
#define TrF(s, ...) imgui_i18n::fmt(s, __VA_ARGS__)
|
||||
|
||||
namespace imgui_i18n {
|
||||
|
||||
// Set active locale: "" or "en" = English (default, zero-overhead fast path).
|
||||
void setLocale(const char* locale);
|
||||
const char* getLocale();
|
||||
|
||||
// Look up key in the active locale table; falls back to key itself if not found.
|
||||
const char* translate(const char* key);
|
||||
|
||||
// Replace $1, $2, ... placeholders with args (in order).
|
||||
std::string fmt(const char* key, std::initializer_list<std::string> args);
|
||||
|
||||
// Register a translation table for a locale (called by locale/*.cpp static initializers).
|
||||
void registerLocale(
|
||||
const char* locale,
|
||||
std::initializer_list<std::pair<const char*, const char*>> entries);
|
||||
|
||||
} // namespace imgui_i18n
|
||||
|
||||
#else // IMGUI_DEMO_ENABLE_I18N not defined
|
||||
|
||||
// Stub: Tr() is a compile-time identity — zero overhead, no dependencies.
|
||||
#define Tr(s) (s)
|
||||
#define TrF(s, ...) (s)
|
||||
|
||||
#endif // IMGUI_DEMO_ENABLE_I18N
|
||||
847
misc/i18n/locale/zh_CN.cpp
Normal file
847
misc/i18n/locale/zh_CN.cpp
Normal file
|
|
@ -0,0 +1,847 @@
|
|||
// i18n/locale/zh_CN.cpp
|
||||
// Simplified Chinese (zh_CN) translation table. Auto-registered before main() via static initializer.
|
||||
#include "imgui_i18n.h"
|
||||
|
||||
namespace {
|
||||
struct ZhCNRegistrar {
|
||||
ZhCNRegistrar() {
|
||||
imgui_i18n::registerLocale("zh_CN", {
|
||||
// === Step 1: Demo Window + MenuBar ===
|
||||
{"Dear ImGui Demo", "Dear ImGui 演示"},
|
||||
{"Configuration", "配置"},
|
||||
{"Window options", "窗口选项"},
|
||||
{"No titlebar", "无标题栏"},
|
||||
{"No scrollbar", "无滚动条"},
|
||||
{"No menu", "无菜单"},
|
||||
{"No move", "禁止移动"},
|
||||
{"No resize", "禁止缩放"},
|
||||
{"No collapse", "禁止折叠"},
|
||||
{"No close", "无关闭按钮"},
|
||||
{"No nav", "无键盘/手柄导航"},
|
||||
{"No background", "无背景"},
|
||||
{"No bring to front", "不置顶"},
|
||||
{"Unsaved document", "未保存标记"},
|
||||
{"Widgets", "控件"},
|
||||
{"Layout & Scrolling", "布局与滚动"},
|
||||
{"Popups & Modal windows", "弹窗与模态框"},
|
||||
{"Tables & Columns", "表格与列"},
|
||||
{"Inputs & Focus", "输入与焦点"},
|
||||
{"Disable All", "全部禁用"},
|
||||
{"Disable (section)", "禁用(区域)"},
|
||||
{"Menu", "菜单"},
|
||||
{"Examples", "示例"},
|
||||
{"Main menu bar", "主菜单栏"},
|
||||
{"Assets Browser", "资产浏览器"},
|
||||
{"Console", "控制台"},
|
||||
{"Custom rendering", "自定义渲染"},
|
||||
{"Documents", "文档管理"},
|
||||
{"Image Viewer", "图片查看器"},
|
||||
{"Log", "日志"},
|
||||
{"Property editor", "属性编辑器"},
|
||||
{"Simple layout", "简单布局"},
|
||||
{"Simple overlay", "简单浮层"},
|
||||
{"Mini apps", "迷你应用"},
|
||||
{"Concepts", "概念演示"},
|
||||
{"Auto-resizing window", "自动调整大小的窗口"},
|
||||
{"Constrained-resizing window", "约束调整大小的窗口"},
|
||||
{"Fullscreen window", "全屏窗口"},
|
||||
{"Long text display", "长文本显示"},
|
||||
{"Manipulating window titles", "操控窗口标题"},
|
||||
{"Tools", "工具"},
|
||||
{"Metrics/Debugger", "指标/调试器"},
|
||||
{"Debug Options", "调试选项"},
|
||||
{"Highlight ID Conflicts", "高亮 ID 冲突"},
|
||||
{"Assert on error recovery", "错误恢复时断言"},
|
||||
{"(see Demo->Configuration for more)", "(详见 Demo->配置)"},
|
||||
{"Debug Log", "调试日志"},
|
||||
{"ID Stack Tool", "ID 栈工具"},
|
||||
{"Item Picker", "元素拾取器"},
|
||||
{"Style Editor", "样式编辑器"},
|
||||
{"About Dear ImGui", "关于 Dear ImGui"},
|
||||
{"Language", "语言"},
|
||||
{"File", "文件"},
|
||||
{"New", "新建"},
|
||||
{"Open", "打开"},
|
||||
{"Open Recent", "最近打开"},
|
||||
{"Save", "保存"},
|
||||
{"Save As..", "另存为.."},
|
||||
{"Export", "导出"},
|
||||
{"Quit", "退出"},
|
||||
{"Options", "选项"},
|
||||
{"Enabled", "已启用"},
|
||||
{"Size", "大小"},
|
||||
{"Color", "颜色"},
|
||||
{"SeparatorText", "分隔文字"},
|
||||
{"Dear ImGui Style Editor", "Dear ImGui 样式编辑器"},
|
||||
// --- Step 1 supplement: Configuration panel ---
|
||||
{"dear imgui says hello! (%s) (%d)", "dear imgui 向你问好!(%s) (%d)"},
|
||||
{"<<PRESS SPACE TO DISABLE>>", "<<按空格键禁用>>"},
|
||||
{"Also see Style->Rendering for rendering options.", "另见 样式->渲染 中的渲染选项。"},
|
||||
{"General", "通用"},
|
||||
{"Keyboard/Gamepad Navigation", "键盘/手柄导航"},
|
||||
{"Windows", "窗口"},
|
||||
{"Error Handling", "错误处理"},
|
||||
{"Debug", "调试"},
|
||||
{"Backend Flags", "后端标志"},
|
||||
{"Style, Fonts", "样式与字体"},
|
||||
{"Capture/Logging", "截图/日志"},
|
||||
{"Copy \"Hello, world!\" to clipboard", "复制 \"Hello, world!\" 到剪贴板"},
|
||||
// === Step 2: WidgetsBasic + Bullets + CollapsingHeaders ===
|
||||
{"Basic", "基础"},
|
||||
{"Selectable", "可选项"},
|
||||
{"Images", "图片"},
|
||||
{"Combos", "下拉框"},
|
||||
{"Drag and Drop", "拖放"},
|
||||
{"Color/Picker Widgets", "颜色/选色控件"},
|
||||
{"Multi-component Widgets", "多组件控件"},
|
||||
{"Plotting", "绘图"},
|
||||
{"Progress Bars", "进度条"},
|
||||
{"Text Input", "文本输入"},
|
||||
{"Drags and Sliders", "拖拽与滑块"},
|
||||
{"Selectables", "可选列表项"},
|
||||
{"Tree Nodes", "树节点"},
|
||||
{"Collapsing Headers", "折叠标题"},
|
||||
{"Tooltips", "提示框"},
|
||||
{"Tabs", "标签页"},
|
||||
{"Text", "文字"},
|
||||
{"List Boxes", "列表框"},
|
||||
{"Vertical Sliders", "垂直滑块"},
|
||||
{"Filtered Text Input", "过滤文本输入"},
|
||||
{"Disable Widgets", "禁用控件"},
|
||||
{"Data Types", "数据类型"},
|
||||
{"Multi-Select", "多选"},
|
||||
{"Bullet Widgets", "项目符号控件"},
|
||||
{"Bullet point 1", "项目符号 1"},
|
||||
{"Bullet point 2\nOn multiple lines", "项目符号 2\n(多行文本)"},
|
||||
{"Button", "按钮"},
|
||||
{"Click me", "点击我"},
|
||||
{"Clicked!", "已点击!"},
|
||||
{"Arrows", "箭头按钮"},
|
||||
{"Toggle disabled", "切换禁用"},
|
||||
{"Checkbox", "复选框"},
|
||||
{"RadioButton", "单选按钮"},
|
||||
{"(Disabled)", "(禁用)"},
|
||||
{"(Enabled)", "(启用)"},
|
||||
{"Hold to repeat:", "长按重复:"},
|
||||
{"Press and hold to repeat", "长按重复"},
|
||||
{"Right-click on buttons too!", "按钮也支持右键!"},
|
||||
{"Hovering over me changes the cursor to an arrow!", "悬停切换为箭头光标!"},
|
||||
{"Hovering over me changes the cursor to a hand!", "悬停切换为手形光标!"},
|
||||
{"Tooltip when hovering:", "悬停提示:"},
|
||||
{"Tooltip always visible:", "始终显示提示:"},
|
||||
{"Hold to repeat (filtered)", "长按重复(过滤)"},
|
||||
{"Another bullet point", "另一个项目符号"},
|
||||
{"Header 1: open by default", "标题 1:默认展开"},
|
||||
{"Header 2: do not show a bullet", "标题 2:无项目符号"},
|
||||
{"(more empty content)", "(更多空内容)"},
|
||||
{"(see Widgets->Selectable for more)", "(详见 控件->可选列表项)"},
|
||||
{"Thanks for clicking me!", "感谢点击!"},
|
||||
{"checkbox", "复选框"},
|
||||
{"radio a", "单选 a"},
|
||||
{"radio b", "单选 b"},
|
||||
{"radio c", "单选 c"},
|
||||
{"Click", "点击"},
|
||||
{"Tooltip", "提示"},
|
||||
{"I am a tooltip", "我是一个提示框"},
|
||||
{"label", "标签"},
|
||||
{"Value", "值"},
|
||||
{"input text", "输入文本"},
|
||||
{"input text (w/ hint)", "输入文本(带提示)"},
|
||||
{"enter text here", "在此输入"},
|
||||
{"input int", "输入整数"},
|
||||
{"input float", "输入浮点数"},
|
||||
{"input double", "输入双精度"},
|
||||
{"input scientific", "科学计数法输入"},
|
||||
{"input float3", "输入 float3"},
|
||||
{"drag int", "拖拽整数"},
|
||||
{"drag int 0..100", "拖拽整数 0..100"},
|
||||
{"drag int wrap 100..200", "拖拽整数环绕 100..200"},
|
||||
{"drag float", "拖拽浮点数"},
|
||||
{"drag small float", "拖拽小浮点数"},
|
||||
{"slider int", "滑块整数"},
|
||||
{"slider float", "滑块浮点数"},
|
||||
{"slider float (log)", "滑块浮点数(对数)"},
|
||||
{"slider angle", "滑块角度"},
|
||||
{"slider enum", "滑块枚举"},
|
||||
{"color 1", "颜色 1"},
|
||||
{"color 2", "颜色 2"},
|
||||
{"combo", "下拉框"},
|
||||
{"listbox", "列表框"},
|
||||
{"Bullets", "项目符号"},
|
||||
{"Tree node", "树节点"},
|
||||
{"Bullet point 3 (two calls)", "项目符号 3(两次调用)"},
|
||||
{"Show 2nd header", "显示第 2 个标题"},
|
||||
{"Header", "标题"},
|
||||
{"Header with a close button", "带关闭按钮的标题"},
|
||||
{"IsItemHovered: %d", "IsItemHovered: %d"},
|
||||
{"Some content %d", "部分内容 %d"},
|
||||
{"More content %d", "更多内容 %d"},
|
||||
{"Inputs", "输入"},
|
||||
{"Drags", "拖拽"},
|
||||
{"Sliders", "滑块"},
|
||||
{"Selectors/Pickers", "选择器/拾色器"},
|
||||
// === Step 3: ComboBoxes + ListBoxes + Tabs ===
|
||||
{"Combo", "下拉框"},
|
||||
{"One-liner variants", "单行变体"},
|
||||
{"Only makes a difference if the popup is larger than the combo", "仅在弹窗比下拉框宽时有效"},
|
||||
{"Highlight hovered item in second listbox", "在第二个列表框中高亮悬停项"},
|
||||
{"Full-width:", "全宽:"},
|
||||
{"This is the Avocado tab!\nblah blah blah blah blah", "这是鳄梨标签页!\nblah blah blah blah blah"},
|
||||
{"This is the Broccoli tab!\nblah blah blah blah blah", "这是西兰花标签页!\nblah blah blah blah blah"},
|
||||
{"This is the Cucumber tab!\nblah blah blah blah blah", "这是黄瓜标签页!\nblah blah blah blah blah"},
|
||||
{"Advanced & Close Button", "高级与关闭按钮"},
|
||||
{"Opened:", "已打开:"},
|
||||
{"This is the %s tab!", "这是 %s 标签页!"},
|
||||
{"I am an odd tab.", "我是一个奇数标签页。"},
|
||||
{"TabItemButton & Leading/Trailing flags", "标签按钮与前导/尾随标志"},
|
||||
{"Show Leading TabItemButton()", "显示前导标签按钮"},
|
||||
{"Show Trailing TabItemButton()", "显示尾随标签按钮"},
|
||||
{"Hello!", "你好!"},
|
||||
// === Step 4: DragsSliders + DataTypes + VerticalSliders ===
|
||||
{"Drag Int", "拖拽整数"},
|
||||
{"Drag Float", "拖拽浮点"},
|
||||
{"Drag small float", "拖拽小浮点"},
|
||||
{"Slider Int", "整数滑块"},
|
||||
{"Slider Float", "浮点滑块"},
|
||||
{"Slider angle", "角度滑块"},
|
||||
{"Reversed", "反向"},
|
||||
{"Clamp On Input", "限制输入范围"},
|
||||
{"Round to format", "按格式取整"},
|
||||
{"Logarithmic", "对数"},
|
||||
{"Whole Numbers", "整数"},
|
||||
{"Without border", "无边框"},
|
||||
{"With border", "有边框"},
|
||||
{"Input", "输入"},
|
||||
{"Sliders (DragXXX, SliderXXX)", "拖拽与滑块(DragXXX, SliderXXX)"},
|
||||
{"Drag/Slider Flags", "拖拽/滑块标志"},
|
||||
{"Underlying float value: %f", "底层浮点值:%f"},
|
||||
{"Cannot drop here!", "无法拖放到此处!"},
|
||||
{"drag me", "拖动我"},
|
||||
{"Clamp integers to 0..50", "将整数限制在 0..50"},
|
||||
{"Sliders (reverse)", "反向滑块"},
|
||||
{"Show step buttons", "显示步进按钮"},
|
||||
{"Misc", "其他"},
|
||||
{"Saturation", "饱和度"},
|
||||
{"As 0..255", "范围 0..255"},
|
||||
// === Step 5: Text + TextFilter + TextInput ===
|
||||
{"Text Display", "文字显示"},
|
||||
{"Colored Text", "彩色文字"},
|
||||
{"Word Wrapping", "自动换行"},
|
||||
{"UTF-8 Text", "UTF-8 文字"},
|
||||
{"Single-line text input", "单行文本输入"},
|
||||
{"Password input", "密码输入"},
|
||||
{"Multi-line text input", "多行文本输入"},
|
||||
{"Completion:", "补全:"},
|
||||
{"History:", "历史:"},
|
||||
{"Info:", "信息:"},
|
||||
{"Lock And Scroll", "锁定并滚动"},
|
||||
{"Read-only", "只读"},
|
||||
{"Resize according to text", "根据文本自动缩放"},
|
||||
{"Filtered Input", "过滤输入"},
|
||||
{"Misc inputs", "其他输入"},
|
||||
{"Upper-case input", "大写输入"},
|
||||
{"Filter with a callback", "回调过滤"},
|
||||
{"No spaces", "无空格"},
|
||||
{"Hexadecimal", "十六进制"},
|
||||
{"Scientific", "科学计数"},
|
||||
{"Custom", "自定义"},
|
||||
{"Password", "密码"},
|
||||
{"In a popup", "在弹窗中"},
|
||||
{"Pressing ENTER will submit", "按 Enter 提交"},
|
||||
{"Multiline", "多行"},
|
||||
{"Editable", "可编辑"},
|
||||
{"Font Size", "字体大小"},
|
||||
// === Step 6: Color/Pickers + Images + Plotting + ProgressBars ===
|
||||
{"Color widget:", "颜色控件:"},
|
||||
{"Color widget HSV with Alpha:", "HSV 带透明度:"},
|
||||
{"Color widget with Float Display:", "浮点显示颜色:"},
|
||||
{"Color button with Custom Picker Popup:", "自定义选色弹窗:"},
|
||||
{"my color", "我的颜色"},
|
||||
{"Color picker", "颜色选取器"},
|
||||
{"Set defaults in code:", "在代码中设置默认值:"},
|
||||
{"Both types:", "两种类型:"},
|
||||
{"HSV encoded colors", "HSV 编码颜色"},
|
||||
{"Color widget with InputHSV:", "InputHSV 颜色控件:"},
|
||||
{"Hover the texture for a zoomed view!", "悬停纹理查看放大视图!"},
|
||||
{"Image()/ImageWithBg() function", "Image()/ImageWithBg() 函数"},
|
||||
{"Interactive Image Viewer", "交互式图片查看器"},
|
||||
{"Textured Buttons", "纹理按钮"},
|
||||
{"And now some textured buttons..", "以下是一些纹理按钮.."},
|
||||
{"Need better plotting and graphing? Consider using ImPlot:", "需要更好的绘图?考虑使用 ImPlot:"},
|
||||
{"Animate", "动画"},
|
||||
{"Frame Times", "帧时间"},
|
||||
{"Histogram", "直方图"},
|
||||
{"Functions", "函数"},
|
||||
{"Sample count", "采样数"},
|
||||
// === Step 7: DragDrop + QueryingStatuses + DisableBlocks ===
|
||||
{"Disable Blocks", "禁用块"},
|
||||
{"Disable entire section above", "禁用上方全部控件"},
|
||||
{"Demonstrate using BeginDisabled()/EndDisabled() across other sections.", "演示跨区域使用 BeginDisabled()/EndDisabled()。"},
|
||||
{"Drag and drop in standard widgets", "在标准控件中拖放"},
|
||||
{"You can drag from the color squares.", "可以从颜色方块拖动。"},
|
||||
{"Drag and drop to copy/swap items", "拖放以复制/交换项目"},
|
||||
{"Copy", "复制"},
|
||||
{"Move", "移动"},
|
||||
{"Swap", "交换"},
|
||||
{"Drag to reorder items (simple)", "拖放重新排序(简单)"},
|
||||
{"Tooltip at target location", "目标位置工具提示"},
|
||||
{"Drag to re-order", "拖放以重新排序"},
|
||||
{"Hold CTRL to copy", "按住 CTRL 复制"},
|
||||
{"Querying Item Status (Edited/Active/Hovered etc.)", "查询控件状态(已编辑/激活/悬停等)"},
|
||||
{"Querying Window Status (Focused/Hovered etc.)", "查询窗口状态(聚焦/悬停等)"},
|
||||
{"Embed everything inside a child window for testing _RootWindow flag.", "将所有内容嵌入子窗口以测试 _RootWindow 标志。"},
|
||||
{"Querying Mouse Status", "查询鼠标状态"},
|
||||
{"Disabled Widgets", "禁用控件"},
|
||||
{"Disable all items", "禁用所有控件"},
|
||||
{"First", "第一"},
|
||||
{"Second", "第二"},
|
||||
{"Third", "第三"},
|
||||
// IsItemXxx()/GetItemXxx() API names are not translated (fallback to English key).
|
||||
{"Mouse Cursors", "鼠标光标"},
|
||||
{"Display all cursors", "显示所有光标"},
|
||||
{"Hovering over them changes the mouse cursor.", "悬停改变光标样式。"},
|
||||
|
||||
// === Step 8: Selectables + MultiSelect + TreeNodes + Tooltips ===
|
||||
{"1. Direct output", "1. 直接输出"},
|
||||
{"2. Checkbox-like behavior", "2. 复选框行为"},
|
||||
{"3. Mixed usage", "3. 混合用法"},
|
||||
{"4. Full-width selectable, with a custom overlay", "4. 全宽可选项(带覆盖层)"},
|
||||
{"5. Rendering more items (150)", "5. 渲染更多项目(150 个)"},
|
||||
{"Multiple items on the same line", "同行多项目"},
|
||||
{"In Tables", "在表格中"},
|
||||
{"Grid", "网格"},
|
||||
{"Alignment", "对齐"},
|
||||
{"Selection: None", "选中:无"},
|
||||
{"(Selection: None)", "(选中:无)"},
|
||||
{"Selection State & Multi-Select", "选中状态与多选"},
|
||||
{"Single-Select", "单选"},
|
||||
{"Multi-Select (manual/simplified, without BeginMultiSelect)", "多选(手动简化版,不使用 BeginMultiSelect)"},
|
||||
{"Supported features:", "支持的功能:"},
|
||||
{"Added features:", "新增功能:"},
|
||||
{"Dynamic list with Delete key support.", "动态列表(支持 Delete 键删除)。"},
|
||||
{"Multi-Select (with clipper)", "多选(带裁剪器)"},
|
||||
{"Multi-Select (with deletion)", "多选(含删除)"},
|
||||
{"Multi-Select (dual list box)", "多选(双列表框)"},
|
||||
{"Multi-Select (in a table)", "多选(在表格中)"},
|
||||
{"Multi-Select (checkboxes)", "多选(复选框)"},
|
||||
{"In a list of checkboxes (not selectable):", "复选框列表(非 Selectable):"},
|
||||
{"Using _NoAutoSelect + _NoAutoClear flags.", "使用 _NoAutoSelect + _NoAutoClear 标志。"},
|
||||
{"Shift+Click to check multiple boxes.", "Shift+点击 勾选多个框。"},
|
||||
{"Shift+Keyboard to copy current value to other boxes.", "Shift+键盘 将当前值复制到其他框。"},
|
||||
{"Multi-Select (multiple scopes)", "多选(多作用域)"},
|
||||
{"Selection scope", "选中作用域"},
|
||||
{"Multi-Select (tiled assets browser)", "多选(平铺资产浏览器)"},
|
||||
{"(also access from 'Examples->Assets Browser' in menu)", "(也可从菜单 'Examples->Assets Browser' 进入)"},
|
||||
{"Multi-Select (trees)", "多选(树)"},
|
||||
{"Selection size: %d", "已选:%d"},
|
||||
{"Multi-Select (advanced)", "多选(高级)"},
|
||||
{"Tree nodes", "树节点项"},
|
||||
{"Enable clipper", "启用裁剪器"},
|
||||
{"Enable deletion", "启用删除"},
|
||||
{"Enable drag & drop", "启用拖放"},
|
||||
{"Show in a table", "显示在表格中"},
|
||||
{"Show color button", "显示颜色按钮"},
|
||||
{"Dragging %d objects", "正在拖动 %d 个对象"},
|
||||
{"Close", "关闭"},
|
||||
{"Wiki page:", "Wiki 页面:"},
|
||||
{"Multi-select and multiple columns", "多选与多列"},
|
||||
{"Multi-select tree", "多选树"},
|
||||
{"Multi-select table", "多选表格"},
|
||||
{"Use CTRL+Click to select multiple items.", "CTRL+点击 选择多项。"},
|
||||
{"Hold SHIFT to select a range.", "SHIFT 选择范围。"},
|
||||
{"Basic Trees", "基础树"},
|
||||
{"Hierarchy Lines", "层级连线"},
|
||||
{"Clipping Large Trees", "裁剪大型树"},
|
||||
{"Selectable Nodes", "可选节点"},
|
||||
{"Advanced", "高级"},
|
||||
{"Parent", "父节点"},
|
||||
{"Child 1", "子节点 1"},
|
||||
{"Child 2", "子节点 2"},
|
||||
{"Button for Child 1", "子节点 1 按钮"},
|
||||
{"Button for Child 2", "子节点 2 按钮"},
|
||||
{"Remaining contents", "剩余内容"},
|
||||
{"blah blah", "内容内容"},
|
||||
{"button", "按钮"},
|
||||
{"This is a drag and drop source", "这是一个拖放源"},
|
||||
{"Blah blah\nBlah Blah", "内容内容\n内容内容"},
|
||||
{"<Node contents here>", "<节点内容>"},
|
||||
{"Align label with current X position", "与当前 X 位置对齐标签"},
|
||||
{"Make Tree Nodes as drag & drop sources", "将树节点作为拖放源"},
|
||||
{"Basic trees", "基础树"},
|
||||
{"Advanced, with Selectable nodes", "高级(带可选节点)"},
|
||||
{"Leaf node", "叶节点"},
|
||||
{"Child node 0", "子节点 0"},
|
||||
{"Child node 1", "子节点 1"},
|
||||
{"Fancy", "高级"},
|
||||
{"Curve", "曲线"},
|
||||
{"Sin(time) = %f", "Sin(时间) = %f"},
|
||||
{"Always On", "始终显示"},
|
||||
{"Off", "关闭"},
|
||||
{"Always On (Simple)", "始终显示(简单)"},
|
||||
{"Always On (Advanced)", "始终显示(高级)"},
|
||||
{"I am following you around.", "我在跟随你。"},
|
||||
{"I am a fancy tooltip", "我是一个高级提示框"},
|
||||
{"flags for a specific tooltip instance.", "针对特定提示框实例的标志。"},
|
||||
{"Manual", "手动"},
|
||||
{"I am a manually emitted tooltip.", "我是手动触发的提示框。"},
|
||||
{"DelayNone", "无延迟"},
|
||||
{"I am a tooltip with no delay.", "我是一个无延迟的提示框。"},
|
||||
{"DelayShort", "短延迟"},
|
||||
{"I am a tooltip with a short delay (%0.2f sec).", "我是一个短延迟提示框(%0.2f 秒)。"},
|
||||
{"DelayLong", "长延迟"},
|
||||
{"I am a tooltip with a long delay (%0.2f sec).", "我是一个长延迟提示框(%0.2f 秒)。"},
|
||||
{"Stationary", "静止触发"},
|
||||
{"I am a tooltip requiring mouse to be stationary before activating.", "我需要鼠标静止后才会显示。"},
|
||||
{"Disabled item", "禁用项"},
|
||||
{"I am a tooltip for a disabled item.", "我是禁用项的提示框。"},
|
||||
{"Always on", "始终显示"},
|
||||
{"Delay", "延迟"},
|
||||
{"Programmatic", "程序化"},
|
||||
{"Variable delay", "可变延迟"},
|
||||
{"Short", "短"},
|
||||
{"Long", "长"},
|
||||
{"Stationary delay", "静止延迟"},
|
||||
{"Scroll to select", "滚动选择"},
|
||||
{"Fixed", "固定"},
|
||||
{"(close)", "(关闭)"},
|
||||
{"(Closed)", "(已关闭)"},
|
||||
// === Step 9: Layout ===
|
||||
{"Child windows", "子窗口"},
|
||||
{"Disable Mouse Wheel", "禁用鼠标滚轮"},
|
||||
{"Disable Menu", "禁用菜单"},
|
||||
{"%04d: scrollable region", "%04d: 可滚动区域"},
|
||||
{"Manual-resize", "手动调整大小"},
|
||||
{"Auto-resize with constraints", "带约束的自动调整大小"},
|
||||
{"Lines Count", "行数"},
|
||||
{"Max Height (in Lines)", "最大高度(行数)"},
|
||||
{"Misc/Advanced", "杂项/高级"},
|
||||
{"Offset X", "X 偏移"},
|
||||
{"Override ChildBg color", "覆盖子窗口背景色"},
|
||||
{"Some test %d", "测试项 %d"},
|
||||
{"Hovered: %d", "悬浮: %d"},
|
||||
{"Rect of child window is: (%.0f,%.0f) (%.0f,%.0f)", "子窗口矩形: (%.0f,%.0f) (%.0f,%.0f)"},
|
||||
{"Widgets Width", "控件宽度"},
|
||||
{"Show indented items", "显示缩进项"},
|
||||
{"SetNextItemWidth/PushItemWidth(100)", "SetNextItemWidth/PushItemWidth(100)"},
|
||||
{"Fixed width.", "固定宽度。"},
|
||||
{"SetNextItemWidth/PushItemWidth(-100)", "SetNextItemWidth/PushItemWidth(-100)"},
|
||||
{"Align to right edge minus 100", "对齐到右边缘减 100"},
|
||||
{"SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)", "SetNextItemWidth/PushItemWidth(GetContentRegionAvail().x * 0.5f)"},
|
||||
{"Half of available width.\n(~ right-cursor_pos)\n(works within a column set)", "可用宽度的一半。\n(~ 右侧光标位置)\n(在列集中有效)"},
|
||||
{"SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)", "SetNextItemWidth/PushItemWidth(-GetContentRegionAvail().x * 0.5f)"},
|
||||
{"Align to right edge minus half", "对齐到右边缘减半"},
|
||||
{"SetNextItemWidth/PushItemWidth(-FLT_MIN)", "SetNextItemWidth/PushItemWidth(-FLT_MIN)"},
|
||||
{"Align to right edge", "对齐到右边缘"},
|
||||
{"Basic Horizontal Layout", "基础水平布局"},
|
||||
{"(Use ImGui::SameLine() to keep adding items to the right of the preceding item)", "(使用 ImGui::SameLine() 在前一个控件右侧继续添加控件)"},
|
||||
{"Two items: Hello", "两个控件: Hello"},
|
||||
{"Sailor", "水手"},
|
||||
{"More spacing: Hello", "更大间距: Hello"},
|
||||
{"Normal buttons", "普通按钮"},
|
||||
{"Banana", "香蕉"},
|
||||
{"Apple", "苹果"},
|
||||
{"Corniflower", "矢车菊"},
|
||||
{"Small buttons", "小按钮"},
|
||||
{"Like this one", "像这个"},
|
||||
{"can fit within a text block.", "可以嵌入文本块中。"},
|
||||
{"Aligned", "对齐"},
|
||||
{"x=150", "x=150"},
|
||||
{"x=300", "x=300"},
|
||||
{"My", "我的"},
|
||||
{"Tailor", "裁缝"},
|
||||
{"Is", "是"},
|
||||
{"Rich", "富有的"},
|
||||
{"Lists:", "列表:"},
|
||||
{"Manual wrapping:", "手动换行:"},
|
||||
{"Groups", "分组"},
|
||||
{"Text Baseline Alignment", "文字基线对齐"},
|
||||
{"Text baseline:", "文字基线:"},
|
||||
{"Multi-line text:", "多行文本:"},
|
||||
{"Misc items:", "杂项控件:"},
|
||||
{"Item %d..", "项目 %d.."},
|
||||
{"Scrolling", "滚动"},
|
||||
{"Decoration", "装饰"},
|
||||
{"Item = %d", "项目 = %d"},
|
||||
{"Track", "跟踪"},
|
||||
{"+%.0f px", "+%.0f px"},
|
||||
{"Scroll Offset", "滚动偏移"},
|
||||
{"X/Y = %.0f px", "X/Y = %.0f px"},
|
||||
{"Scroll To Pos", "滚动到位置"},
|
||||
{"Top", "顶部"},
|
||||
{"25%", "25%"},
|
||||
{"Center", "居中"},
|
||||
{"75%", "75%"},
|
||||
{"Bottom", "底部"},
|
||||
{"Item %d", "项目 %d"},
|
||||
{"%.0f/%.0f", "%.0f/%.0f"},
|
||||
{"Left", "左"},
|
||||
{"Right", "右"},
|
||||
{"%s\n%.0f/%.0f", "%s\n%.0f/%.0f"},
|
||||
{"Lines", "行数"},
|
||||
{"Scroll from code", "代码控制滚动"},
|
||||
{"<<", "<<"},
|
||||
{">>", ">>"},
|
||||
{"Show Horizontal contents size demo window", "显示水平内容尺寸演示窗口"},
|
||||
{"Horizontal contents size demo window", "水平内容尺寸演示窗口"},
|
||||
{"Use 'Metrics->Tools->Show windows rectangles' to visualize rectangles.", "使用 'Metrics->Tools->Show windows rectangles' 可视化矩形。"},
|
||||
{"H-scrollbar", "水平滚动条"},
|
||||
{"Text wrapped", "自动换行文本"},
|
||||
{"Columns", "列"},
|
||||
{"Tab bar", "标签栏"},
|
||||
{"Child", "子窗口"},
|
||||
{"Explicit content size", "显式内容尺寸"},
|
||||
{"Scroll %.1f/%.1f %.1f/%.1f", "滚动 %.1f/%.1f %.1f/%.1f"},
|
||||
{"this is a 300-wide button", "这是一个 300 宽的按钮"},
|
||||
{"this is a tree node", "这是一个树节点"},
|
||||
{"another one of those tree node...", "另一个树节点..."},
|
||||
{"Some tree contents", "树节点内容"},
|
||||
{"CollapsingHeader", "折叠标题"},
|
||||
{"This text should automatically wrap on the edge of the work rectangle.", "这段文字应在工作区边缘自动换行。"},
|
||||
{"Tables:", "表格:"},
|
||||
{"Width %.2f", "宽度 %.2f"},
|
||||
{"Columns:", "列:"},
|
||||
{"Text Clipping", "文字裁剪"},
|
||||
{"(Click and drag to scroll)", "(点击并拖拽以滚动)"},
|
||||
{"Overlap Mode", "重叠模式"},
|
||||
{"Enable AllowOverlap", "启用重叠允许"},
|
||||
{"Button 1", "按钮 1"},
|
||||
{"Button 2", "按钮 2"},
|
||||
{"Some Selectable", "可选项"},
|
||||
// === Step 10: Popups + About + UserGuide ===
|
||||
{"Popups", "弹窗"},
|
||||
{"Select..", "选择.."},
|
||||
{"Right-click here", "在此右键"},
|
||||
{"right-click me!", "右键点我!"},
|
||||
{"right-click on this text", "右键点击此文字"},
|
||||
{"Modal windows", "模态框"},
|
||||
{"Delete?", "确认删除?"},
|
||||
{"This is a modal window", "这是一个模态框"},
|
||||
{"Yes", "是"},
|
||||
{"No", "否"},
|
||||
{"Stacked modals", "嵌套模态框"},
|
||||
{"Open another modal", "打开另一个模态框"},
|
||||
{"Popups in a menu", "菜单中的弹窗"},
|
||||
{"Menus", "菜单"},
|
||||
{"Context menus", "右键菜单"},
|
||||
{"Menu in a popup", "弹窗内菜单"},
|
||||
{"Popups with window restoring focus", "弹窗恢复焦点"},
|
||||
{"Open a popup!", "打开弹窗!"},
|
||||
{"Dear ImGui is an immediate mode GUI library for C++.", "Dear ImGui 是一个 C++ 即时模式 GUI 库。"},
|
||||
{"License:", "许可证:"},
|
||||
{"Build Information:", "构建信息:"},
|
||||
{"User Guide", "用户指南"},
|
||||
{"PROGRAMMER GUIDE", "程序员指南"},
|
||||
{"MOUSE & DRAG AND DROP", "鼠标与拖放"},
|
||||
{"KEYBOARD, GAMEPAD & FOCUS", "键盘、手柄与焦点"},
|
||||
{"Read 'Programmer Guide' in imgui.cpp for notes on how to setup Dear ImGui in your codebase.", "阅读 imgui.cpp 中的《程序员指南》了解集成方法。"},
|
||||
{"Understood!", "明白了!"},
|
||||
{"Oops, button is disabled!", "按钮已被禁用!"},
|
||||
// === Step 11: Tables (first half) ===
|
||||
{"Borders, background", "边框与背景"},
|
||||
{"Resizable, stretch", "可缩放(拉伸)"},
|
||||
{"Resizable, fixed", "可缩放(固定)"},
|
||||
{"Resizable, mixed", "可缩放(混合)"},
|
||||
{"Sizing policies", "尺寸策略"},
|
||||
{"Vertical scrolling, with clipping", "垂直滚动(带裁剪)"},
|
||||
{"Horizontal scrolling", "水平滚动"},
|
||||
{"Columns flags", "列标志"},
|
||||
{"Columns widths", "列宽"},
|
||||
{"Nested tables", "嵌套表格"},
|
||||
{"Row height", "行高"},
|
||||
{"Outer size", "外部尺寸"},
|
||||
{"Reorderable, hideable, with headers", "可重排、可隐藏(带表头)"},
|
||||
{"Padding", "内边距"},
|
||||
{"Disable tree indentation", "禁用树缩进"},
|
||||
{"Expand all", "展开全部"},
|
||||
{"Collapse all", "折叠全部"},
|
||||
{"Display headers", "显示表头"},
|
||||
// === Step 11b: Tables (second half, part 1) ===
|
||||
{"Headers", "表头"},
|
||||
{"Row flags", "行标志"},
|
||||
{"Reordering", "重排"},
|
||||
{"Hiding", "隐藏"},
|
||||
{"Sorting", "排序"},
|
||||
{"Column types", "列类型"},
|
||||
{"Borders", "边框"},
|
||||
{"Full headers", "完整表头"},
|
||||
{"Foot0", "底部0"},
|
||||
{"Foot1", "底部1"},
|
||||
{"Foot2", "底部2"},
|
||||
{"Seat#", "座位号"},
|
||||
{"Age", "年龄"},
|
||||
{"Average", "平均"},
|
||||
{"Sum", "总计"},
|
||||
{"First Name", "名"},
|
||||
{"Last Name", "姓"},
|
||||
{"Bream", "鲷鱼"},
|
||||
{"Haddock", "黑线鳕"},
|
||||
{"Mackerel", "鲭鱼"},
|
||||
{"Pollock", "鳕鱼"},
|
||||
{"Tilefish", "马头鱼"},
|
||||
{"Dragonfruit", "火龙果"},
|
||||
{"Eggplant", "茄子"},
|
||||
{"Fig", "无花果"},
|
||||
{"Guava", "番石榴"},
|
||||
{"Vertical headers", "垂直表头"},
|
||||
{"Custom headers", "自定义表头"},
|
||||
{"Row background color", "行背景色"},
|
||||
// === Step 11b: Tables (second half, part 2) ===
|
||||
{"Background color", "背景色"},
|
||||
{"Tree view", "树形视图"},
|
||||
{"Item width", "条目宽度"},
|
||||
{"Angled headers", "斜角表头"},
|
||||
{"Style settings", "样式设置"},
|
||||
{"Synced instances", "同步实例"},
|
||||
{"Legacy Columns API", "旧版 Columns API"},
|
||||
{"Mixed items", "混合条目"},
|
||||
{"Word-wrapping", "自动换行"},
|
||||
{"Horizontal Scrolling", "水平滚动"},
|
||||
{"Tree", "树形"},
|
||||
{"Name", "名称"},
|
||||
{"Type", "类型"},
|
||||
{"small", "小"},
|
||||
{"half", "半"},
|
||||
{"right-align", "右对齐"},
|
||||
{"Apricot", "杏"},
|
||||
{"Cherry", "樱桃"},
|
||||
{"One", "一"},
|
||||
{"Two", "二"},
|
||||
{"Three", "三"},
|
||||
{"ID", "ID"},
|
||||
{"Action", "操作"},
|
||||
{"Quantity", "数量"},
|
||||
{"Description", "描述"},
|
||||
{"Without border:", "无边框:"},
|
||||
{"With border:", "有边框:"},
|
||||
{"Path", "路径"},
|
||||
{"Hovered", "悬停"},
|
||||
{"horizontal", "水平"},
|
||||
{"vertical", "垂直"},
|
||||
{"Long text that is likely to clip", "很可能被截断的长文本"},
|
||||
{"Hello", "你好"},
|
||||
{"An extra line here.", "这里额外一行。"},
|
||||
{"Category A", "类别 A"},
|
||||
{"Category B", "类别 B"},
|
||||
{"Category C", "类别 C"},
|
||||
{"Blah blah blah", "巴拉巴拉巴拉"},
|
||||
{"Node contents", "节点内容"},
|
||||
{"Tree in column", "列中的树"},
|
||||
{"Even more contents", "更多内容"},
|
||||
{"The quick brown fox jumps over the lazy dog", "快速的棕色狐狸跳过了懒狗"},
|
||||
// === Step 12: Inputs + Style Editor ===
|
||||
{"This is a simplified view. See more detailed input state:\n- in 'Tools->Metrics/Debugger->Inputs'.\n- in 'Tools->Debug Log->IO'.", "这是简化视图。详细输入状态请查看:\n- 'Tools->Metrics/Debugger->Inputs'\n- 'Tools->Debug Log->IO'"},
|
||||
{"Mouse pos: (%g, %g)", "鼠标位置:(%g, %g)"},
|
||||
{"Mouse pos: <INVALID>", "鼠标位置:<无效>"},
|
||||
{"Mouse delta: (%g, %g)", "鼠标增量:(%g, %g)"},
|
||||
{"Mouse down:", "鼠标按下:"},
|
||||
{"Mouse wheel: %.1f", "鼠标滚轮:%.1f"},
|
||||
{"Mouse clicked count:", "鼠标点击次数:"},
|
||||
{"Keys down:", "按下的键:"},
|
||||
{"Keys mods: %s%s%s%s", "修饰键:%s%s%s%s"},
|
||||
{"Chars queue:", "字符队列:"},
|
||||
{"Outputs", "输出"},
|
||||
{"WantCapture override", "捕获覆盖"},
|
||||
{"Hovering the colored canvas will override io.WantCaptureXXX fields.\nNotice how normally (when set to none), the value of io.WantCaptureKeyboard would be false when hovering and true when clicking.", "悬停在彩色画布上将覆盖 io.WantCaptureXXX 字段。\n注意通常情况下(设为 none 时),悬停时 io.WantCaptureKeyboard 为 false,点击时为 true。"},
|
||||
{"None", "无"},
|
||||
{"Set to false", "设为 false"},
|
||||
{"Set to true", "设为 true"},
|
||||
{"SetNextFrameWantCaptureMouse() on hover", "悬停时调用 SetNextFrameWantCaptureMouse()"},
|
||||
{"SetNextFrameWantCaptureKeyboard() on hover", "悬停时调用 SetNextFrameWantCaptureKeyboard()"},
|
||||
{"Shortcuts", "快捷键"},
|
||||
{"Using SetNextItemShortcut()", "使用 SetNextItemShortcut()"},
|
||||
{"Using Shortcut()", "使用 Shortcut()"},
|
||||
{"Factor", "系数"},
|
||||
{"Press Ctrl+A and see who receives it!", "按 Ctrl+A 查看谁接收到了!"},
|
||||
{"Current mouse cursor = %d: %s", "当前鼠标光标 = %d: %s"},
|
||||
{"Hover to see mouse cursors:", "悬停查看鼠标光标:"},
|
||||
{"Tabbing", "Tab 键导航"},
|
||||
{"Use Tab/Shift+Tab to cycle through keyboard editable fields.", "使用 Tab/Shift+Tab 在可编辑字段间切换。"},
|
||||
{"Focus from code", "代码设置焦点"},
|
||||
{"Focus on 1", "聚焦到 1"},
|
||||
{"Focus on 2", "聚焦到 2"},
|
||||
{"Focus on 3", "聚焦到 3"},
|
||||
{"Focus on X", "聚焦到 X"},
|
||||
{"Focus on Y", "聚焦到 Y"},
|
||||
{"Focus on Z", "聚焦到 Z"},
|
||||
{"Dragging", "拖拽"},
|
||||
{"GetMouseDragDelta(0):", "GetMouseDragDelta(0):"},
|
||||
// Style Editor
|
||||
{"For instructions, see:", "使用说明请查看:"},
|
||||
{"Save Ref", "保存参考"},
|
||||
{"Revert Ref", "还原参考"},
|
||||
{"Details", "详细设置"},
|
||||
{"Sizes", "尺寸"},
|
||||
{"Colors", "颜色"},
|
||||
{"Fonts", "字体"},
|
||||
{"Rendering", "渲染"},
|
||||
{"Only Modified Colors", "仅显示修改的颜色"},
|
||||
{"Filter colors", "过滤颜色"},
|
||||
{"Opaque", "不透明"},
|
||||
{"Alpha", "Alpha"},
|
||||
{"Both", "两者"},
|
||||
{"Revert", "还原"},
|
||||
{"Anti-aliased lines", "抗锯齿线条"},
|
||||
{"Anti-aliased lines use texture", "抗锯齿线条使用纹理"},
|
||||
{"Anti-aliased fill", "抗锯齿填充"},
|
||||
{"Curve Tessellation Tolerance", "曲线细分容差"},
|
||||
{"Circle Tessellation Max Error", "圆形细分最大误差"},
|
||||
// === Step 13: Example Apps ===
|
||||
{"Example: Main Menu Bar", "示例:主菜单栏"},
|
||||
{"Edit", "编辑"},
|
||||
{"Undo", "撤销"},
|
||||
{"Redo", "重做"},
|
||||
{"Cut", "剪切"},
|
||||
{"Paste", "粘贴"},
|
||||
{"Example: Console", "示例:控制台"},
|
||||
{"Command:", "命令:"},
|
||||
{"Clear", "清空"},
|
||||
{"Scroll to bottom", "滚动到底部"},
|
||||
{"Auto-scroll", "自动滚动"},
|
||||
{"Enter 'HELP' for help.", "输入 'HELP' 获取帮助。"},
|
||||
{"Example: Log", "示例:日志"},
|
||||
{"Enable scrolling", "启用自动滚动"},
|
||||
{"Add Dummy Text", "添加示例文字"},
|
||||
{"Add Dummy Error", "添加示例错误"},
|
||||
{"Example: Simple Layout", "示例:简单布局"},
|
||||
{"Example: Property editor", "示例:属性编辑器"},
|
||||
{"Example: Long text display", "示例:长文本显示"},
|
||||
{"Example: Auto-resizing window", "示例:自动缩放窗口"},
|
||||
{"Example: Constrained-resizing window", "示例:约束缩放窗口"},
|
||||
{"Example: Simple overlay", "示例:简单浮层"},
|
||||
{"n/a", "不可用"},
|
||||
{"Example: Fullscreen window", "示例:全屏窗口"},
|
||||
{"Example: Manipulating window titles", "示例:操控窗口标题"},
|
||||
{"Example: Custom rendering", "示例:自定义渲染"},
|
||||
{"Example: Documents", "示例:文档管理"},
|
||||
{"(Untitled)", "(未命名)"},
|
||||
{"Erase", "擦除"},
|
||||
{"Stroke", "描边"},
|
||||
{"Primitives", "图元"},
|
||||
{"BG/FG draw lists", "前/后景绘制列表"},
|
||||
{"Mesh", "网格"},
|
||||
{"Textures", "纹理"},
|
||||
{"Example: Assets Browser", "示例:资产浏览器"},
|
||||
{"HELP", "帮助"},
|
||||
{"HISTORY", "历史"},
|
||||
{"CLEAR", "清空"},
|
||||
{"Close Me", "关闭"},
|
||||
// Additional strings from Step 13
|
||||
{"Use work area instead of main area", "使用工作区而非主区域"},
|
||||
{"Close this window", "关闭此窗口"},
|
||||
{"This window has a changing title.", "此窗口具有动态标题。"},
|
||||
{"Simple overlay\n(right-click to change position)", "简单浮层\n(右键更改位置)"},
|
||||
{"Mouse Position: <invalid>", "鼠标位置:<无效>"},
|
||||
{"(Hold Shift to display a dummy viewport)", "(按住 Shift 显示虚拟视口)"},
|
||||
{"Auto-resize", "自动缩放"},
|
||||
{"Constraint", "约束"},
|
||||
{"Use Clipper", "使用裁剪器"},
|
||||
{"Printing unusually long amount of text.", "正在打印超长文本。"},
|
||||
{"Test type", "测试类型"},
|
||||
{"Gradients", "渐变"},
|
||||
{"All primitives", "所有图元"},
|
||||
{"Draw in Background draw list", "在背景绘制列表中绘制"},
|
||||
{"Draw in Foreground draw list", "在前景绘制列表中绘制"},
|
||||
{"Blue shape is drawn first: appears in back", "蓝色形状先绘制:显示在后面"},
|
||||
{"Red shape is drawn after: appears in front", "红色形状后绘制:显示在前面"},
|
||||
{"Blue shape is drawn first, into channel 1: appears in front", "蓝色形状先绘制到通道1:显示在前面"},
|
||||
{"Red shape is drawn after, into channel 0: appears in back", "红色形状后绘制到通道0:显示在后面"},
|
||||
{"After reordering, contents of channel 0 appears below channel 1.", "重排后,通道0的内容显示在通道1下方。"},
|
||||
{"Close All Documents", "关闭所有文档"},
|
||||
{"Rename..", "重命名.."},
|
||||
{"Modify", "修改"},
|
||||
{"Save change to the following items?", "将更改保存到以下项目?"},
|
||||
{"Cancel", "取消"},
|
||||
{"Add 10000 items", "添加10000个项目"},
|
||||
{"Clear items", "清除项目"},
|
||||
{"Delete", "删除"},
|
||||
{"Contents", "内容"},
|
||||
{"Selection Behavior", "选择行为"},
|
||||
{"Layout", "布局"},
|
||||
{"Show Type Overlay", "显示类型覆盖"},
|
||||
{"Allow Sorting", "允许排序"},
|
||||
{"Allow box-selection", "允许框选"},
|
||||
{"Allow box-selection from selected items", "允许从已选项目框选"},
|
||||
{"Allow dragging unselected item", "允许拖拽未选项目"},
|
||||
{"Icon Size", "图标大小"},
|
||||
{"Icon Spacing", "图标间距"},
|
||||
{"Icon Hit Spacing", "图标命中间距"},
|
||||
{"Stretch Spacing", "拉伸间距"},
|
||||
{"Use ScrollX", "启用水平滚动"},
|
||||
{"%d assets", "%d 个资产"},
|
||||
{"Selection: %d items", "已选:%d 个项目"},
|
||||
{"Help", "帮助"},
|
||||
// === main.mm window ===
|
||||
// "Hello, world!" and "This is some useful text." are intentionally kept in English
|
||||
// as they are universally recognized programming example strings.
|
||||
{"Demo Window", "演示窗口"},
|
||||
{"Another Window", "另一个窗口"},
|
||||
// "float" is kept as-is: it labels a SliderFloat() demonstrating the float type.
|
||||
{"clear color", "背景颜色"},
|
||||
{"Application average %.3f ms/frame (%.1f FPS)", "平均 %.3f 毫秒/帧(%.1f FPS)"},
|
||||
{"Hello from another window!", "来自另一个窗口的问候!"},
|
||||
{"Close Me", "关闭"},
|
||||
// === Help collapsing section ===
|
||||
{"ABOUT THIS DEMO:", "关于本演示:"},
|
||||
{"Sections below are demonstrating many aspects of the library.", "下方各章节展示了库的众多特性。"},
|
||||
{"The \"Examples\" menu above leads to more demo contents.", "上方「示例」菜单包含更多演示内容。"},
|
||||
{"The \"Tools\" menu above gives access to: About Box, Style Editor,\nand Metrics/Debugger (general purpose Dear ImGui debugging tool).", "上方「工具」菜单可访问:关于弹窗、样式编辑器\n以及指标/调试器(通用 Dear ImGui 调试工具)。"},
|
||||
{"Web demo (w/ source code browser): ", "在线演示(含源码浏览器):"},
|
||||
{"PROGRAMMER GUIDE:", "程序员指南:"},
|
||||
{"See the ShowDemoWindow() code in imgui_demo.cpp. <- you are here!", "参阅 imgui_demo.cpp 中的 ShowDemoWindow() 代码。← 你在这里!"},
|
||||
{"See comments in imgui.cpp.", "参阅 imgui.cpp 中的注释。"},
|
||||
{"See example applications in the examples/ folder.", "参阅 examples/ 目录下的示例程序。"},
|
||||
{"Read the FAQ at ", "阅读 FAQ:"},
|
||||
{"Set 'io.ConfigFlags |= NavEnableKeyboard' for keyboard controls.", "设置 'io.ConfigFlags |= NavEnableKeyboard' 以启用键盘控制。"},
|
||||
{"Set 'io.ConfigFlags |= NavEnableGamepad' for gamepad controls.", "设置 'io.ConfigFlags |= NavEnableGamepad' 以启用手柄控制。"},
|
||||
{"USER GUIDE:", "用户指南:"},
|
||||
// === User Guide (ShowUserGuide) ===
|
||||
{"Double-click on title bar to collapse window.", "双击标题栏折叠窗口。"},
|
||||
{"Click and drag on lower corner or border to resize window.\n(double-click to auto fit window to its contents)", "拖拽右下角或边框调整窗口大小。\n(双击自动适应内容)"},
|
||||
{"Ctrl+Click on a slider or drag box to input value as text.", "Ctrl+点击滑块或拖拽框,可直接输入数值。"},
|
||||
{"Tab/Shift+Tab to cycle through keyboard editable fields.", "Tab/Shift+Tab 在可编辑字段间切换。"},
|
||||
{"Ctrl+Tab/Ctrl+Shift+Tab to focus windows.", "Ctrl+Tab/Ctrl+Shift+Tab 切换窗口焦点。"},
|
||||
{"Ctrl+Mouse Wheel to zoom window contents.", "Ctrl+滚轮缩放窗口内容。"},
|
||||
{"While inputting text:", "输入文字时:"},
|
||||
{"Ctrl+Left/Right to word jump.", "Ctrl+左/右方向键按单词跳转。"},
|
||||
{"Ctrl+A or double-click to select all.", "Ctrl+A 或双击全选。"},
|
||||
{"Ctrl+X/C/V to use clipboard cut/copy/paste.", "Ctrl+X/C/V 剪切/复制/粘贴。"},
|
||||
{"Ctrl+Z to undo, Ctrl+Y/Ctrl+Shift+Z to redo.", "Ctrl+Z 撤销,Ctrl+Y/Ctrl+Shift+Z 重做。"},
|
||||
{"Escape to revert.", "Escape 还原。"},
|
||||
{"With Keyboard controls enabled:", "启用键盘控制后:"},
|
||||
{"Arrow keys or Home/End/PageUp/PageDown to navigate.", "方向键或 Home/End/PageUp/PageDown 导航。"},
|
||||
{"Space to activate a widget.", "空格键激活控件。"},
|
||||
{"Return to input text into a widget.", "Enter 键向控件输入文字。"},
|
||||
{"Escape to deactivate a widget, close popup,\nexit a child window or the menu layer, clear focus.", "Escape 键取消激活控件、关闭弹窗、\n退出子窗口或菜单层、清除焦点。"},
|
||||
{"Alt to jump to the menu layer of a window.", "Alt 键跳转到窗口菜单层。"},
|
||||
{"Menu or Shift+F10 to open a context menu.", "Menu 或 Shift+F10 打开右键菜单。"},
|
||||
{"With Gamepad controls enabled:", "启用手柄控制后:"},
|
||||
{"D-Pad: Navigate / Tweak / Resize (in Windowing mode).", "方向键:导航/调整/缩放(窗口模式)。"},
|
||||
{"%s Face button: Activate / Open / Toggle. Hold: activate with text input.", "%s 键:激活/打开/切换。长按:激活并输入文字。"},
|
||||
{"%s Face button: Cancel / Close / Exit.", "%s 键:取消/关闭/退出。"},
|
||||
{"West Face button: Toggle Menu. Hold for Windowing mode (Focus/Move/Resize windows).", "West 键:切换菜单。长按进入窗口模式(聚焦/移动/缩放)。"},
|
||||
{"North Face button: Open Context Menu.", "North 键:打开右键菜单。"},
|
||||
{"L1/R1: Tweak Slower/Faster, Focus Previous/Next (in Windowing Mode).", "L1/R1:慢速/快速调整,切换焦点(窗口模式)。"},
|
||||
// === Configuration panel HelpMarker tooltips ===
|
||||
{"Enable keyboard controls.", "启用键盘控制。"},
|
||||
{"Enable gamepad controls. Require backend to set io.BackendFlags |= ImGuiBackendFlags_HasGamepad.\n\nRead instructions in imgui.cpp for details.", "启用手柄控制。需要后端设置 io.BackendFlags |= ImGuiBackendFlags_HasGamepad。\n\n详情请阅读 imgui.cpp 中的说明。"},
|
||||
{"Instruct dear imgui to disable mouse inputs and interactions.", "禁止 Dear ImGui 处理鼠标输入和交互。"},
|
||||
{"Instruct backend to not alter mouse cursor shape and visibility.", "禁止后端修改鼠标光标形状和可见性。"},
|
||||
{"Instruct dear imgui to disable keyboard inputs and interactions.", "禁止 Dear ImGui 处理键盘输入和交互。"},
|
||||
{"Enable input queue trickling: some types of events submitted during the same frame (e.g. button down + up) will be spread over multiple frames, improving interactions with low framerates.", "启用输入队列滴流:同一帧内提交的某些事件(如按下+抬起)将分散到多帧处理,改善低帧率下的交互体验。"},
|
||||
{"Instruct Dear ImGui to render a mouse cursor itself. Note that a mouse cursor rendered via your application GPU rendering path will feel more laggy than hardware cursor, but will be more in sync with your other visuals.\n\nSome desktop applications may use both kinds of cursors (e.g. enable software cursor only when resizing/dragging something).", "让 Dear ImGui 自行渲染鼠标光标。通过 GPU 渲染的软件光标会比硬件光标略有延迟,但与其他画面更同步。\n\n部分桌面应用会同时使用两种光标(如仅在拖拽/缩放时启用软件光标)。"},
|
||||
{"Directional/tabbing navigation teleports the mouse cursor. May be useful on TV/console systems where moving a virtual mouse is difficult", "方向键/Tab 导航会瞬移鼠标光标。在难以移动虚拟鼠标的电视/主机系统上很有用。"},
|
||||
{"Pressing Escape clears focused item.", "按 Escape 键清除焦点控件。"},
|
||||
{"Pressing Escape clears focused window.", "按 Escape 键清除焦点窗口。"},
|
||||
{"Using directional navigation key makes the cursor visible. Mouse click hides the cursor.", "使用方向导航键时显示光标,鼠标点击时隐藏光标。"},
|
||||
{"Navigation cursor is always visible.", "导航光标始终可见。"},
|
||||
{"Enable resizing of windows from their edges and from the lower-left corner.\nThis requires ImGuiBackendFlags_HasMouseCursors for better mouse cursor feedback.", "允许从窗口边缘和左下角调整大小。\n需要 ImGuiBackendFlags_HasMouseCursors 以获得更好的光标反馈。"},
|
||||
{"*EXPERIMENTAL* Ctrl+C copy the contents of focused window into the clipboard.\n\nExperimental because:\n- (1) has known issues with nested Begin/End pairs.\n- (2) text output quality varies.\n- (3) text output is in submission order rather than spatial order.", "*实验性* Ctrl+C 将焦点窗口内容复制到剪贴板。\n\n实验性原因:\n- (1) 嵌套 Begin/End 有已知问题。\n- (2) 文字输出质量不稳定。\n- (3) 输出按提交顺序而非空间顺序排列。"},
|
||||
{"Enable scrolling page by page when clicking outside the scrollbar grab.\nWhen disabled, always scroll to clicked location.\nWhen enabled, Shift+Click scrolls to clicked location.", "点击滚动条轨道时逐页滚动。\n禁用时:始终滚动到点击位置。\n启用时:Shift+点击滚动到点击位置。"},
|
||||
{"Enable blinking cursor (optional as some users consider it to be distracting).", "启用闪烁光标(部分用户认为会分散注意力,可选)。"},
|
||||
{"Pressing Enter will reactivate item and select all text (single-line only).", "按 Enter 键重新激活控件并全选文字(仅单行)。"},
|
||||
{"Enable turning DragXXX widgets into text input with a simple mouse click-release (without moving).", "点击 DragXXX 控件后不移动即可切换为文本输入模式。"},
|
||||
{"Swap Cmd<>Ctrl keys, enable various MacOS style behaviors.", "交换 Cmd<>Ctrl 键,启用各种 macOS 风格行为。"},
|
||||
});
|
||||
}
|
||||
} s_zh_cn;
|
||||
} // namespace
|
||||
25
misc/i18n/tools/extract_strings.py
Normal file
25
misc/i18n/tools/extract_strings.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/env python3
|
||||
"""
|
||||
用法:python3 extract_strings.py imgui_demo.cpp 302 737
|
||||
输出 zh_CN.cpp 条目骨架(key=英文,value 留空供人工翻译)
|
||||
"""
|
||||
import sys, re
|
||||
|
||||
def extract(path, start, end):
|
||||
with open(path) as f:
|
||||
lines = f.readlines()
|
||||
chunk = ''.join(lines[start-1:end-1])
|
||||
strings = re.findall(r'"([^"\n]{2,80})"', chunk)
|
||||
seen = set()
|
||||
results = []
|
||||
skip = re.compile(r'^(##|###|%[0-9.]*[dfsx]$|[0-9.]+$)')
|
||||
for s in strings:
|
||||
if s in seen or skip.match(s): continue
|
||||
seen.add(s)
|
||||
results.append(s)
|
||||
for s in results:
|
||||
escaped = s.replace('\\', '\\\\').replace('"', '\\"')
|
||||
print(f' {{"{escaped}", ""}},')
|
||||
|
||||
if __name__ == '__main__':
|
||||
extract(sys.argv[1], int(sys.argv[2]), int(sys.argv[3]))
|
||||
Loading…
Add table
Add a link
Reference in a new issue