Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.
C++ 3d3d-sculptingcppdear-imguidigital-sculptingfbxgame-developmentgaussian-splattinggltfimage-to-3dmcpopenglopenusdsculptingtext-to-3dunreal-engine
Brush palette in Spanish and Chinese: brush settings actions (pen pressure, Save/Reset Brush Settings) translated, picker sections, Stamp rotation; shorter clipped labels
islandmedc0fb87b59c28
diff --git a/assets/fonts/NotoSansTC-UI.otf b/assets/fonts/NotoSansTC-UI.otfindex c0206189..76014714 100644Binary files a/assets/fonts/NotoSansTC-UI.otf and b/assets/fonts/NotoSansTC-UI.otf differdiff --git a/src/app/App.cpp b/src/app/App.cppindex 67dfa77a..67a4bca2 100644--- a/src/app/App.cpp+++ b/src/app/App.cpp@@ -3333,7 +3333,7 @@ void App::drawBrushLab() {chatLog_.clear();}ImGui::SameLine();- if (ImGui::SmallButton("Paste brush")) pasteBrush();+ if (ImGui::SmallButton(tr("Paste brush"))) pasteBrush();if (ImGui::IsItemHovered(ImGuiHoveredFlags_DelayNormal))ImGui::SetTooltip("Install a brush someone shared: a brush code (sfbrush1:...) or .sfbrush text on the ""clipboard (Ctrl+V in the viewport)");diff --git a/src/app/BrushSettingsUi.cpp b/src/app/BrushSettingsUi.cppindex 4e5ffd75..0a9b0fec 100644--- a/src/app/BrushSettingsUi.cpp+++ b/src/app/BrushSettingsUi.cpp@@ -5,6 +5,7 @@// strokes, so every way of picking a brush (shelf, pickers, keys, the Library, scripts, Ctrl-held brushes) behaves// the same without each of them knowing about it.#include "app/App.h"+#include "app/I18n.h"#include "app/Ui.h"#include "core/BrushLibrary.h"@@ -166,11 +167,11 @@ void App::setPenPressure(bool size, PenPressure p) {void App::drawPenPressureSwitches(const char* id) {ImGui::PushID(id);- ImGui::TextDisabled("Pen pressure: %s", activeRecipe() ? activeRecipe()->name.c_str() : brushLabel(brush_));- const float labelW = ImGui::CalcTextSize("Strength").x + ImGui::GetFontSize(); // (a clear gap before the segments)+ ImGui::TextDisabled(tr("Pen pressure: %s"), activeRecipe() ? activeRecipe()->name.c_str() : brushLabel(brush_));+ const float labelW = std::max(ImGui::CalcTextSize(tr("Strength")).x, ImGui::CalcTextSize(tr("Size")).x) + ImGui::GetFontSize(); // (a clear gap before the segments)for (const bool size : {true, false}) {ImGui::AlignTextToFramePadding();- ImGui::TextUnformatted(size ? "Size" : "Strength");+ ImGui::TextUnformatted(tr(size ? "Size" : "Strength"));ImGui::SameLine(labelW);if (size) ui::Segmented(*this, {"brush.pen_size_global", "brush.pen_size_on", "brush.pen_size_off"});else ui::Segmented(*this, {"brush.pen_strength_global", "brush.pen_strength_on", "brush.pen_strength_off"});diff --git a/src/app/I18n.cpp b/src/app/I18n.cppindex 02eccd3e..c71a0801 100644--- a/src/app/I18n.cpp+++ b/src/app/I18n.cpp@@ -182,8 +182,19 @@ std::string tr(const std::string& english) {return tr(english.c_str());}+// "brush.*" actions that are settings, not brushes: their labels are words like any other (tools/i18n/coverage.py+// reads this list too).+constexpr std::string_view kBrushSettingActions[] = {+ "brush.pen_", "brush.size_", "brush.scale_size", "brush.share_size", "brush.world_size",+ "brush.save_settings", "brush.reset_settings", "brush.paste", "brush.recipe", "brush.capture_view",+ "brush.asset_activate"};+const char* trAction(std::string_view actionId, const std::string& label) {- if (actionId.substr(0, 6) == "brush.") return label.c_str();+ if (actionId.substr(0, 6) == "brush.") {+ bool setting = false;+ for (const std::string_view prefix : kBrushSettingActions) setting = setting || actionId.substr(0, prefix.size()) == prefix;+ if (!setting) return label.c_str(); // a brush: brushes keep their names+ }return tr(label.c_str());}diff --git a/src/app/I18n.h b/src/app/I18n.hindex 63f9f249..77f47d58 100644--- a/src/app/I18n.h+++ b/src/app/I18n.h@@ -40,7 +40,8 @@ bool languageNeedsCjkFont(Language language);// entry, or a string kept for the life of the program: safe to keep across frames.const char* tr(const char* english);std::string tr(const std::string& english);-// An action's label: brushes keep their names (Clay Block, Move, Smooth...), everything else is translated.+// An action's label: brushes keep their names (Clay Block, Move, Smooth...), everything else is translated (brush+// settings such as brush.pen_size_on too).const char* trAction(std::string_view actionId, const std::string& label);// A palette path with each step translated: "Tool > Geometry" -> "Herramienta > Geometría".std::string trPath(std::string_view path);diff --git a/src/app/I18nSpanish.cpp b/src/app/I18nSpanish.cppindex 7ac1d06f..3d72bd41 100644--- a/src/app/I18nSpanish.cpp+++ b/src/app/I18nSpanish.cpp@@ -215,7 +215,7 @@ constexpr Entry kSpanish[] = {{"Invert (Alt)", "Invertir (Alt)"},{"Invert", "Invertir"},{"Smooth keeps volume", "Smooth conserva el volumen"},- {"Smooth face group borders only", "Smooth solo en los bordes de grupos de caras"},+ {"Smooth face group borders only", "Smooth solo en bordes de grupos"},{"Symmetry", "Simetría"},{"Symmetry X", "Simetría X"},{"Local", "Local"},@@ -751,7 +751,7 @@ constexpr Entry kSpanish[] = {// --- Pickers and brushes ---{"Brush picker", "Selector de pinceles"},{"Alpha picker", "Selector de alphas"},- {"Community brushes", "Pinceles de la comunidad"},+ {"Community brushes", "Comunidad"},{"Save to Library", "Guardar en la biblioteca"},{"Strength", "Fuerza"},{"Falloff", "Atenuación"},@@ -3501,6 +3501,22 @@ constexpr Entry kSpanish[] = {{"Texel Density", "Densidad de téxeles"},{"Trim Sheet", "Trim sheet"},{"Unwrap Selected", "Desenvolver selección"},+ // --- Brush palette (tools/i18n/coverage.py) ---+ {"Filter brushes", "Filtrar pinceles"},+ {"Alphas", "Alphas"},+ {"Built-in", "Incluidos"},+ {"Custom", "Propios"},+ {"Custom brushes", "Pinceles propios"},+ {"Larger brush by 1 px", "Pincel 1 px más grande"},+ {"Smaller brush by 1 px", "Pincel 1 px más pequeño"},+ {"On", "Activado"},+ {"Use global", "Usar global"},+ {"Reset Brush to Default", "Restablecer pincel"},+ {"Save Brush Settings", "Guardar ajustes del pincel"},+ {"Sort: Recent", "Ordenar: Recientes"},+ {"Stamp rotation", "Rotación del sello"},+ {"Vector displacement", "Desplazamiento vectorial"},+ {"World Size", "Tamaño en el mundo"},};} // namespacediff --git a/src/app/I18nTraditionalChinese.cpp b/src/app/I18nTraditionalChinese.cppindex dc4b5d2a..5ddf9099 100644--- a/src/app/I18nTraditionalChinese.cpp+++ b/src/app/I18nTraditionalChinese.cpp@@ -3033,6 +3033,22 @@ constexpr Entry kTraditionalChinese[] = {{"Texel Density", "紋素密度"},{"Trim Sheet", "裝飾貼圖"},{"Unwrap Selected", "展開所選"},+ // --- Brush palette (tools/i18n/coverage.py) ---+ {"Filter brushes", "篩選筆刷"},+ {"Alphas", "Alpha"},+ {"Built-in", "內建"},+ {"Custom", "自訂"},+ {"Custom brushes", "自訂筆刷"},+ {"Larger brush by 1 px", "筆刷放大 1 px"},+ {"Smaller brush by 1 px", "筆刷縮小 1 px"},+ {"On", "開啟"},+ {"Use global", "使用全域"},+ {"Reset Brush to Default", "重設筆刷為預設"},+ {"Save Brush Settings", "儲存筆刷設定"},+ {"Sort: Recent", "排序:最近"},+ {"Stamp rotation", "印章旋轉"},+ {"Vector displacement", "向量位移"},+ {"World Size", "世界尺寸"},};} // namespacediff --git a/src/app/PanelBrushLibrary.cpp b/src/app/PanelBrushLibrary.cppindex f270522d..0266a0ec 100644--- a/src/app/PanelBrushLibrary.cpp+++ b/src/app/PanelBrushLibrary.cpp@@ -6,6 +6,7 @@// (copy code, save, rename, delete, reveal), pasting brushes from the// clipboard, and saving Brush Lab edits to the user library automatically.#include "app/App.h"+#include "app/I18n.h"#include "app/Pickers.h"#include "core/BrushLibrary.h"@@ -210,7 +211,7 @@ void App::revealBrushFile(int index) {}void App::drawCustomBrushes() {- ImGui::SeparatorText("Custom brushes");+ ImGui::SeparatorText(tr("Custom brushes"));enum class Action { None, Copy, Save, Rename, Delete, Reveal } action = Action::None;int actionIndex = -1;if (ImGui::BeginListBox("##custom", ImVec2(-1, ImGui::GetTextLineHeightWithSpacing() * 5.5f))) {diff --git a/src/app/PanelBrushes.cpp b/src/app/PanelBrushes.cppindex a8308576..bc12f5d9 100644--- a/src/app/PanelBrushes.cpp+++ b/src/app/PanelBrushes.cpp@@ -5,6 +5,7 @@// stroke handling of the SnakeHook brush and the DragRect stroke.#include "app/Theme.h"#include "app/App.h"+#include "app/I18n.h"#include "app/Ui.h"#include <iterator>@@ -76,7 +77,7 @@ void App::drawAlphaOptions(bool vdm) {AlphaOptions& o = alphaOptions_;const char* where = vdm ? "Brush > Vector Displacement" : "Alpha";if (vdm) {- ImGui::SeparatorText("Stamp rotation");+ ImGui::SeparatorText(tr("Stamp rotation"));ui::Checkbox("Follow stroke direction##vdm.follow_stroke", &o.followStroke);ui::HelpText("Follow stroke direction", nullptr,"The stamp turns with you: with Drag Stamp its top points the way you drag; in a dots stroke it "diff --git a/src/app/Pickers.cpp b/src/app/Pickers.cppindex ba43e051..00a3408d 100644--- a/src/app/Pickers.cpp+++ b/src/app/Pickers.cpp@@ -7,6 +7,7 @@#include "app/Pickers.h"#include "app/App.h"+#include "app/I18n.h"#include "app/UiServe.h"#include "app/AssetLibrary.h"#include "app/Ui.h"@@ -160,7 +161,7 @@ int columnsFor(float tile, GridMode mode) {void sectionHeader(const char* text) {ImGui::Dummy(ImVec2(0, 2));ImGui::PushStyleColor(ImGuiCol_Text, ImGui::GetStyleColorVec4(ImGuiCol_TextDisabled));- ImGui::SeparatorText(text);+ ImGui::SeparatorText(tr(text));ImGui::PopStyleColor();}@@ -326,7 +327,7 @@ bool AssetTile(const char* id, ImTextureID texture, const char* glyph, const stdfloat SortMenuWidth() { // the widest Sort button and the gap before itconst ImGuiStyle& st = ImGui::GetStyle();- return ImGui::CalcTextSize("Sort: Recent").x + st.FramePadding.x * 2.0f + st.ItemSpacing.x + 2.0f;+ return ImGui::CalcTextSize(tr("Sort: Recent")).x + st.FramePadding.x * 2.0f + st.ItemSpacing.x + 2.0f;}int brushRecentRank(const std::string& id) { return recentRank(st().recent, id); }@@ -340,7 +341,7 @@ int builtinBrushPackRank(const std::string& pack) {bool SortMenu(const char* id, std::string& pref, bool packs) {const ListSort cur = listSortFromId(pref);char label[64];- std::snprintf(label, sizeof label, "Sort: %s##%s", listSortLabel(cur), id);+ std::snprintf(label, sizeof label, tr("Sort: %s##%s"), tr(listSortLabel(cur)), id);if (ImGui::SmallButton(label)) ImGui::OpenPopup(id);ui::HelpText("Sort", nullptr,packs ? "The order of this list: A-Z (the default), the most recently used first, or grouped by pack."@@ -624,7 +625,7 @@ void drawBrushGrid(App& app, GridMode mode) {if (!popup) {ImGui::SetNextItemWidth(-SortMenuWidth());- ImGui::InputTextWithHint("##brushfilter", ICON_LC_SEARCH " Filter brushes", paletteFilter,+ ImGui::InputTextWithHint("##brushfilter", tr(ICON_LC_SEARCH " Filter brushes"), paletteFilter,sizeof paletteFilter);ImGui::SameLine();SortMenu("brushsort", app.uiPrefs_.brushSort);diff --git a/tests/test_i18n.cpp b/tests/test_i18n.cppindex a9ae82c1..d62a19d8 100644--- a/tests/test_i18n.cpp+++ b/tests/test_i18n.cpp@@ -125,6 +125,8 @@ TEST(i18n_spanish_lookup_and_fallback) {// Brush names are never translated, even where the word has an entry ("Move" the tool is "Mover").const std::string move = "Move";CHECK(std::string(trAction("brush.move", move)) == "Move");+ const std::string on = "On"; // a brush setting, not a brush: translated+ CHECK(std::string(trAction("brush.pen_size_on", on)) == "\u958b\u555f");CHECK(std::string(trAction("tool.move", move)) == "Mover");CHECK(trPath("Tool > Geometry") == "Herramienta > Geometría");CHECK(trPath("Tool > Frobnicate") == "Herramienta > Frobnicate");@@ -240,5 +242,7 @@ TEST(i18n_chinese_lookup_keeps_ids_and_brush_names) {CHECK(std::string(tr("Frobnicate")) == "Frobnicate"); // no entry: Englishconst std::string move = "Move";CHECK(std::string(trAction("brush.move", move)) == "Move");+ const std::string on = "On"; // a brush setting, not a brush: translated+ CHECK(std::string(trAction("brush.pen_size_on", on)) == "\u958b\u555f");CHECK(trPath("Tool > Geometry") == "\u5de5\u5177 > \u5e7e\u4f55");}diff --git a/tests/ui/language_panels.sfui b/tests/ui/language_panels.sfuiindex a908c255..826a8de6 100644--- a/tests/ui/language_panels.sfui+++ b/tests/ui/language_panels.sfui@@ -76,7 +76,6 @@ expect_text "紋素密度"shot zh-uv-editorkey alt+uclick "筆刷##palette.brush"-click "向量位移##brush.vdm"click "Horn##vdm0"expect "跟隨筆畫方向##vdm.follow_stroke"expect_text "角度抖動"diff --git a/tools/i18n/coverage.py b/tools/i18n/coverage.pyindex 7ab5d452..00031b77 100644--- a/tools/i18n/coverage.py+++ b/tools/i18n/coverage.py@@ -50,6 +50,7 @@ DYNAMIC = {"PanelUvEditor.cpp mode, colour and image labels": ["Vertex", "Edge", "Face", "Island", "Islands", "Stretch","Density", "Plain", "No Image", "Checker", "Texture"],"PanelUvEditor.cpp sections": ["Unwrap", "Pack", "Texel Density", "Trim Sheet", "Edit", "Display"],+ "Pickers.cpp sections and core/ListSort.h listSortLabel": ["Built-in", "Custom", "Recent", "Pack"],"core/RadialMenu.cpp radialButtonLabel": ["None", "Middle mouse button", "Mouse back button", "Mouse forward button","Pen lower button", "Pen upper button", "Pen third button","Right mouse button"],@@ -160,6 +161,15 @@ def literal(arg):return None+def choices(arg):+ """The argument's strings: a plain literal, or each side of a ternary of literals (c ? "On" : "Off")."""+ if literal(arg) is not None:+ return [literal(arg)]+ if "?" in [t[1] for t in arg] and "+" not in [t[1] for t in arg]:+ return literals_in(arg)+ return []++def literals_in(arg):"""Every literal in an argument: both sides of a ternary, a nested {...} list."""return [t[1] for t in arg if t[0] == "str"]@@ -245,6 +255,18 @@ def wrappers(files):return toks, calls+def brush_settings():+ """I18n.cpp's kBrushSettingActions: "brush.*" ids that are settings, so trAction translates their labels."""+ text = (SRC / "I18n.cpp").read_text(encoding="utf-8")+ block = text[text.index("kBrushSettingActions[]"):]+ return tuple(re.findall(r'"([^"]+)"', block[:block.index("};")]))+++def keeps_name(action_id):+ """trAction's rule: a brush keeps its name."""+ return action_id.startswith("brush.") and not action_id.startswith(brush_settings())++def scan_file(path, found, toks, calls):name = path.name@@ -257,7 +279,7 @@ def scan_file(path, found, toks, calls):def add_action(args, line): # an Action's fields in order: id, label, icon, description, palette, ...if len(args) >= 5:- if not (literal(args[0]) or "").startswith("brush."):+ if not keeps_name(literal(args[0]) or ""):add(literal(args[1]), line)add(literal(args[3]), line)add(literal(args[4]), line, "path")@@ -298,9 +320,10 @@ def scan_file(path, found, toks, calls):aid = literal(args[f["id"]]) if 0 <= f["id"] < len(args) else Nonefor field in ACTION_FIELDS:if field in f and f[field] < len(args):- if field == "label" and aid and aid.startswith("brush."):+ if field == "label" and aid and keeps_name(aid):continue- add(literal(args[f[field]]), line, "path" if field == "palette" else "label")+ for text in choices(args[f[field]]):+ add(text, line, "path" if field == "palette" else "label")# actions_.add({"id", "Label", icon, "description", "palette", ...})if k == "id" and v == "add" and prev == "." and nxt == "(" and i + 2 < len(toks) and toks[i + 2][1] == "{" \and toks[i - 2][1] in ("actions_", "reg"):@@ -318,7 +341,7 @@ def scan_file(path, found, toks, calls):if toks[b][1] == "id" and toks[b - 1][1] == "." and toks[b - 2][1] == obj and toks[b + 1][1] == "=":idv = literal([toks[b + 2]]) if toks[b + 3][1] == ";" else Nonebreak- if not (idv and idv.startswith("brush.")) and obj != "g_help":+ if not (idv and keeps_name(idv)) and obj != "g_help":add(literal(val), line, "path" if v == "palette" else "label")if k == "id" and v in TABLES and nxt == "[":j = i