mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-25 18:27:02 -06:00
Strings in code stay English and are the lookup keys; `crates/ui-egui/src/i18n` maps them to display text at render time from one `*.tsv` catalog per language (`LANGUAGES` registry, `tl!`/`t`/`tr`/`tr_ctx`/`tr_id`/`tn`/`fmt`). Command ids, menu paths, `ui.menu.list`, the control channel, the CLI, MCP, status messages and undo labels never see translated text, so agents, scripts and the existing tests are unaffected (under `cargo test` the UI is always English). Wired: in-window menus and the macOS native menu (rebuilt on a language change), dynamic labels (Undo X, Reset X, Last Effect: X as templates), the command palette (matches English and translated text), dock tabs, panel tooltips, the toolbar (category names now cut by characters, not bytes), the dialog frame, the shared widgets, the Preferences dialog, the shortcut editor, the hint and status bars, the Home screen, and the literals of every panel and dialog. Preference `interfaceLanguage` (User Interface › Language): `auto` or a code. `auto` follows `VECTORCRAFT_LOCALE`, `LC_ALL`/`LC_MESSAGES`/`LANG`/`LANGUAGE`, the macOS preferred languages and, on Windows (which sets no `LANG`), the user locale from `HKCU\Control Panel\International`. `zh-TW`/`zh-HK`/`zh-MO`/ `zh-Hant-*` resolve to `zh-hant`; Simplified locales stay English until a `zh-hans` catalog exists. `zh-hant.tsv` (~2,850 rows) is clean-room, in the vocabulary used in Taiwan; terms shared with PhotoCraft reuse its wording, vector terms use everyday vector-drawing vocabulary. Tests: catalog well-formedness (placeholders, ellipses, command ids, no Simplified characters), locale resolution, and two coverage tests that fail when a menu string, panel/tool/preference label, dialog button, hint-bar fragment or `tl!` literal has no row in a language marked `complete_menus`. `VECTORCRAFT_I18N_DUMP=file cargo test -p vectorcraft-ui-egui dump_source_strings` lists the strings for translators. Also: two clippy findings under rustc 1.97 fixed in passing. Integrated with main (squashed onto it, 42 commits on): the Czech interface (#213) moves from its Rust table to `i18n/cs.tsv` on the registry (all 556 rows, Czech plural rule, its menu-coverage and glyph tests kept); Find Font's resolution notes and the canvas context menu's labels are translated and covered by the catalog tests (`menus::CONTEXT_LABELS`); the glyph test checks CJK text only when the craft-fonts build input is embedded (#220 moved the Japanese fonts out of this repository); a language saved by an older version carries over to `interfaceLanguage`; Windows' locale lookup runs reg.exe by its full path. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
2.0 KiB
Rust
53 lines
2.0 KiB
Rust
//! The options of PSD (colour model, a flat image or layers, Maximum Editability, hidden layers,
|
|
//! profile), after the raster export rows it shares with PNG Options ([`super::png_options`]): the
|
|
//! `psdOptions` dialog.
|
|
|
|
use serde_json::{Map, Value, json};
|
|
use vectorcraft_render::encode::jpeg::ColorModel;
|
|
use vectorcraft_render::encode::psd::PsdOptions;
|
|
|
|
use super::form;
|
|
use super::png_options::choice;
|
|
use crate::state::Dialog;
|
|
|
|
/// The options PSD starts with (`cmyk`: a CMYK document exports CMYK).
|
|
pub(super) fn defaults(cmyk: bool, o: &mut Map<String, Value>) {
|
|
let p = PsdOptions::default();
|
|
let model = if cmyk { ColorModel::Cmyk } else { p.color_model };
|
|
o.extend([
|
|
("colorModel".into(), json!(model.id())),
|
|
("layers".into(), json!(p.layers)),
|
|
("maxEditability".into(), json!(p.max_editability)),
|
|
("hiddenLayers".into(), json!(p.hidden_layers)),
|
|
("embedIcc".into(), json!(p.embed_icc)),
|
|
]);
|
|
}
|
|
|
|
/// The grid rows of PSD's own options.
|
|
pub(super) fn rows(ui: &mut egui::Ui, d: &mut Dialog, label: &dyn Fn(&mut egui::Ui, &str) -> egui::Response) {
|
|
label(ui, tl!("Color Model:"));
|
|
choice(ui, d, "colorModel", &ColorModel::ALL.map(ColorModel::id), &ColorModel::ALL.map(ColorModel::label));
|
|
ui.end_row();
|
|
|
|
label(ui, tl!("Options:"));
|
|
ui.vertical(|ui| {
|
|
let mut layers = d.bool("layers");
|
|
if ui.radio_value(&mut layers, false, tl!("Flat Image")).changed() | ui.radio_value(&mut layers, true, tl!("Write Layers")).changed() {
|
|
d.fields.insert("layers".into(), json!(layers));
|
|
}
|
|
ui.add_enabled_ui(layers, |ui| {
|
|
for (key, text) in [("maxEditability", tl!("Maximum Editability")), ("hiddenLayers", tl!("Include Hidden Layers"))] {
|
|
ui.horizontal(|ui| {
|
|
ui.add_space(22.0);
|
|
form::check(ui, d, key, text);
|
|
});
|
|
}
|
|
});
|
|
});
|
|
ui.end_row();
|
|
|
|
ui.label("");
|
|
form::check(ui, d, "embedIcc", tl!("Embed ICC Profile"));
|
|
ui.end_row();
|
|
}
|