Add Tamil (ta) to the interface languages

ta.tsv has 1,507 rows: 1,505 labels and the two count templates (one|other).
It covers every key of the existing catalogs the code still uses and the five
marked strings no catalog has yet, so `cargo xtask i18n` reports nothing
missing for ta. 1,289 rows come from the Tamil CADCraft and shared catalogs
in storytold/craft-i18n, reviewed there by native speakers; the other 218 are
AI-assisted and not yet native-reviewed.

egui's bundled faces have no Tamil letters, so Tamil follows the Arabic path:
an installed Tamil font whose first face has every letter the catalog uses
(theme::tamil_font), or a craft-fonts Taml face, loaded in the Tamil
interface only; the web build keeps Taml faces. Without either the choice is
kept, the interface stays English and the language command says why, and the
picker reads "Tamil" wherever Tamil can't be drawn.

The Properties header's All | My control sized each half 35 px, so a Tamil
"All" ran into "My"; each half now fits its label, and English is unchanged.
This commit is contained in:
NewsBaba committed 2026-11-13 00:05:55 +05:30
1 parent ca87680fb0
commit aa3d4635df
13 files changed
+1774 -31

No files matched your search

+1
View File
@@ -79,3 +79,4 @@ Generated-in-code assets are original and have no file to list:
| `crates/ui-egui/src/i18n/el.tsv` | @Camthalion77 with ChatGPT (AI-assisted) | Original Greek translations of CADCraft English strings | MIT OR Apache-2.0 (`LICENSE-MIT`, `LICENSE-APACHE`) | No proprietary localization resources copied; independent native proofreading pending |
| `crates/ui-egui/src/i18n/vi.tsv` | @2ez4gcx with Claude Code (AI-assisted) | Original Vietnamese translations of CADCraft English strings | MIT OR Apache-2.0 (`LICENSE-MIT`, `LICENSE-APACHE`) | No proprietary localization resources copied; terminology chosen with a native speaker, full proofreading pending |
| `crates/ui-egui/src/i18n/ka.tsv` | Davit Matchakhelidze (@devius), native speaker, with Claude Code | Original Georgian translations of CADCraft English strings | MIT OR Apache-2.0 (`LICENSE-MIT`, `LICENSE-APACHE`) | No proprietary localization resources copied; written from the English strings, no other catalog used as a source; terminology and doubtful strings decided by a native Georgian speaker; no font assets added (the Georgian face comes from craft-fonts) |
| `crates/ui-egui/src/i18n/ta.tsv` | @newsbaba24x7 (AI-assisted) | Original Tamil translations of CADCraft English strings, shared with storytold/craft-i18n `locales/ta/` | MIT OR Apache-2.0 (`LICENSE-MIT`, `LICENSE-APACHE`) | No proprietary localization resources copied; written from the English strings; the 1,289 rows from craft-i18n reviewed there for language and terminology by native speakers, the 218 newer ones not yet reviewed; no font assets added (Tamil comes from an installed font or the craft-fonts face) |
+1 -1
View File
@@ -118,7 +118,7 @@ numbers):
| Layouts & plotting | Paper-space layouts, viewports (scale, lock, per-viewport layer freeze), MSPACE/PSPACE through viewports, page setups, PLOT and EXPORTPDF |
| Parametric | Geometric and dimensional constraints, AUTOCONSTRAIN, PARAMETERS with expressions, conflict detection; constraints re-solve after every edit |
| Grips | Hot grips with Space to cycle Stretch, Move, Rotate, Scale and Mirror |
| Interface languages | English, Ukrainian (Українська), Brazilian Portuguese (Português (Brasil)), German (Deutsch), Spanish (Español), Czech (Čeština), Russian (Русский), French (Français), Simplified Chinese (简体中文, with an installed CJK font), Italian (Italiano), Korean (한국어, with an installed Hangul font), Swedish (Svenska), Arabic (العربية, with an installed Arabic font), Hungarian (Magyar), Turkish (Türkçe), Greek (Ελληνικά), Bosnian (Bosanski) and Georgian (ქართული), live switching and a remembered Auto/system-language choice; [details](docs/localization.md) |
| Interface languages | English, Ukrainian (Українська), Brazilian Portuguese (Português (Brasil)), German (Deutsch), Spanish (Español), Czech (Čeština), Russian (Русский), French (Français), Simplified Chinese (简体中文, with an installed CJK font), Italian (Italiano), Korean (한국어, with an installed Hangul font), Swedish (Svenska), Arabic (العربية, with an installed Arabic font), Hungarian (Magyar), Turkish (Türkçe), Greek (Ελληνικά), Bosnian (Bosanski), Georgian (ქართული) and Tamil (தமிழ், with an installed Tamil font), live switching and a remembered Auto/system-language choice; [details](docs/localization.md) |
| Automation | MCP server, JSON control channel, `cadcraft-cli` (info, convert, run, commands, mcp) |
## Quick start
+6 -5
View File
@@ -3,10 +3,10 @@
//! empty, `CRAFT_FONTS` is empty and the build is unchanged. It only reads the local checkout
//! (no network). A bad checkout is a warning, or an error with `CRAFT_FONTS_REQUIRED=1`.
//!
//! On wasm32 it embeds only BIZ UDPGothic Regular, the `Arab` and `Geor` faces and the `Thai`
//! Regular faces (about 6.1 MB), to keep the web build within hosting limits (Cloudflare Pages:
//! 25 MiB per file). The web build has no system fonts, so these are its only fallback for
//! Japanese, Arabic-script, Georgian and Thai text.
//! On wasm32 it embeds only BIZ UDPGothic Regular, the `Arab`, `Geor` and `Taml` faces and the
//! `Thai` Regular faces (about 6.4 MB), to keep the web build within hosting limits (Cloudflare
//! Pages: 25 MiB per file). The web build has no system fonts, so these are its only fallback for
//! Japanese, Arabic-script, Georgian, Tamil and Thai text.
use std::fmt::Write as _;
use std::path::PathBuf;
@@ -59,7 +59,8 @@ fn craft_fonts(dir: &std::path::Path) -> Result<String, String> {
continue;
}
let has = |script: &str| scripts.split(',').any(|s| s.trim() == script);
let web_face = (*family == "BIZ UDPGothic" && *style == "Regular") || has("Arab") || has("Geor") || (has("Thai") && *style == "Regular");
let web_face =
(*family == "BIZ UDPGothic" && *style == "Regular") || has("Arab") || has("Geor") || has("Taml") || (has("Thai") && *style == "Regular");
if wasm && !web_face {
continue;
}
+3 -2
View File
@@ -1,8 +1,8 @@
//! Fonts from the optional craft-fonts build input (<https://github.com/storytold/craft-fonts>).
//!
//! Built with `CRAFT_FONTS_DIR=<craft-fonts checkout>`, `build.rs` embeds the fonts listed in its
//! `fonts/manifest.txt` (web builds: only BIZ UDPGothic Regular, the Arabic and Georgian faces and
//! the Thai Regular faces). Without it [`CRAFT_FONTS`] is empty and nothing changes. The font table ([`crate::ttf`])
//! `fonts/manifest.txt` (web builds: only BIZ UDPGothic Regular, the Arabic, Georgian and Tamil
//! faces and the Thai Regular faces). Without it [`CRAFT_FONTS`] is empty and nothing changes. The font table ([`crate::ttf`])
//! lists the embedded fonts with the installed ones, under [`CraftFont::stem`]. A text style
//! can name one (`BIZ UDPGothic`), and they are fallbacks for characters a text's font lacks.
//! They are copied out of the binary only when first used.
@@ -86,6 +86,7 @@ mod tests {
Some("Thai") => '\u{0E01}',
Some("Hang" | "Kore") => '가',
Some("Geor") => 'ა',
Some("Taml") => 'த',
_ => 'A',
};
assert!(face.is_some_and(|x| x.has_glyph(sample)), "{} lacks {sample}", f.family);
+25 -5
View File
@@ -51,10 +51,12 @@ pub enum Preference {
Bosnian,
#[serde(rename = "vi")]
Vietnamese,
#[serde(rename = "ta")]
Tamil,
}
impl Preference {
pub const ALL: [Self; 20] = [
pub const ALL: [Self; 21] = [
Self::Auto,
Self::English,
Self::Greek,
@@ -75,14 +77,15 @@ impl Preference {
Self::Georgian,
Self::Bosnian,
Self::Vietnamese,
Self::Tamil,
];
/// Every preference in the order the Interface Language dialog lists them: Auto, then English
/// (the source language), then the rest by the language's own name with accents folded, so
/// Čeština sits under C and Magyar under M. Names in other scripts follow the Latin ones in
/// code point order: Greek, Cyrillic, Arabic, then the CJK languages. The order follows the
/// registry's native name even where the dialog shows an English label instead (Korean
/// without a Hangul face), so the list does not reorder when a font appears.
/// code point order: Greek, Cyrillic, Arabic, Tamil, Georgian, then the CJK languages. The
/// order follows the registry's native name even where the dialog shows an English label
/// instead (Korean without a Hangul face), so the list does not reorder when a font appears.
pub fn for_picker() -> Vec<Self> {
let mut rest: Vec<Self> = Self::ALL.into_iter().filter(|p| !matches!(p, Self::Auto | Self::English)).collect();
rest.sort_by_cached_key(|p| name_sort_key(p.native_name()));
@@ -125,6 +128,7 @@ impl Preference {
Self::Georgian => "ka",
Self::Bosnian => "bs",
Self::Vietnamese => "vi",
Self::Tamil => "ta",
}
}
@@ -171,6 +175,15 @@ impl Preference {
"Vietnamese"
}
}
// Its letters need a Tamil font, loaded only in the Tamil interface
// ([`crate::theme::shows_tamil`]); elsewhere the picker reads the English name.
Self::Tamil => {
if crate::theme::shows_tamil(CURRENT.with(Cell::get)) {
"தமிழ்"
} else {
"Tamil"
}
}
}
}
@@ -204,6 +217,7 @@ impl Preference {
Self::Georgian => "ka",
Self::Bosnian => "bs",
Self::Vietnamese => "vi",
Self::Tamil => "ta",
Self::Auto => locales.iter().find_map(|s| locale_language(s)).unwrap_or("en"),
}
}
@@ -220,7 +234,7 @@ pub struct Language {
catalog: OnceLock<Catalog<'static>>,
}
pub static LANGUAGES: [Language; 19] = [
pub static LANGUAGES: [Language; 20] = [
Language { code: "en", name: "English", source: "", plural: plural_en, plural_forms: 2, catalog: OnceLock::new() },
// Greek: one for exactly 1; other for zero and all other integer counts.
Language {
@@ -279,6 +293,11 @@ pub static LANGUAGES: [Language; 19] = [
Language {
code: "vi", name: "Tiếng Việt", source: include_str!("i18n/vi.tsv"), plural: plural_ko, plural_forms: 1, catalog: OnceLock::new()
},
// தமிழ் (Tamil) plurals follow the English rule: one (1), other. Its letters come from an
// installed Tamil font or the craft-fonts `Taml` face (`theme::can_show`).
Language {
code: "ta", name: "தமிழ்", source: include_str!("i18n/ta.tsv"), plural: plural_en, plural_forms: 2, catalog: OnceLock::new()
},
];
/// BCP 47 and POSIX locale tags, including `uk-UA`, `uk_UA.UTF-8` and `pt_BR.UTF-8`.
@@ -485,6 +504,7 @@ mod picker_order_tests {
assert!(pos(Preference::Bosnian) < pos(Preference::Czech), "Bosanski sorts under B");
assert!(pos(Preference::Swedish) < pos(Preference::Vietnamese), "Tiếng Việt sorts under T");
assert!(pos(Preference::Vietnamese) < pos(Preference::Turkish), "Tiếng comes before Türkçe");
assert!(pos(Preference::Arabic) < pos(Preference::Tamil) && pos(Preference::Tamil) < pos(Preference::Georgian), "தமிழ் sorts by code point");
assert_eq!(name_sort_key("Türkçe"), "turkce");
}
}
File diff suppressed because it is too large. Load diff
+34 -2
View File
@@ -218,6 +218,7 @@ fn assert_additional_locale_aliases() {
("vi", &["vi", "vi-VN", "vi_VN.UTF-8", "VI-vn", " vi-VN "]),
("el", &["el", "el-GR", "el_GR.UTF-8", "EL-cy"]),
("ka", &["ka", "ka-GE", "ka_GE.UTF-8", "KA-ge", " ka-GE "]),
("ta", &["ta", "ta-IN", "ta_IN.UTF-8", "TA-in", " ta-LK ", "ta-SG", "ta_MY.UTF-8"]),
("zh", &["zh", "zh-CN"]),
] {
for tag in tags {
@@ -230,7 +231,8 @@ fn assert_unrecognized_locale_tags() {
// Look-alike codes, three-letter codes and endonyms pick nothing: `se` is Northern Sami.
let look_alikes = ["ua", "ukulele", "pl-PL", "", "garbage", "💙", "ptolemy", "cz", "csharp", "csomething", "italic"];
let others = ["kr", "korean", "kotlin", "se", "swe", "svenska", "hun", "magyar", "tur", "türkçe", "elvish", "kat", "geo", "kab", "kartuli"];
for tag in look_alikes.into_iter().chain(others) {
let tamil = ["tam", "tamil", "தமிழ்"];
for tag in look_alikes.into_iter().chain(others).chain(tamil) {
assert_eq!(locale_language(tag), None, "{tag}");
}
}
@@ -497,7 +499,7 @@ fn dialogs_render_in_every_language_and_keep_their_source_ids() {
#[test]
fn interface_fonts_cover_every_letter_in_each_catalog() {
for language in translated() {
let extra_font = ["ko", "zh", "ar", "vi", "ka"].contains(&language.code);
let extra_font = ["ko", "zh", "ar", "vi", "ka", "ta"].contains(&language.code);
if extra_font && !crate::theme::can_show(language.code) {
continue;
}
@@ -650,6 +652,36 @@ fn bosnian_counts_take_one_few_other() {
assert_eq!(Preference::Bosnian.native_name(), "Bosanski");
}
/// Tamil counts take the English forms (one, other). Tamil shows only with a font that has its
/// letters, an installed Tamil font or the craft-fonts Tamil face, and only the Tamil interface
/// loads one, so the picker writes தமிழ் there and Tamil in every other. Without a font the
/// interface stays English and choosing Tamil says why.
#[test]
fn tamil_takes_two_forms_and_needs_a_tamil_font() {
assert_eq!(Preference::parse("ta"), Some(Preference::Tamil));
assert_eq!(Preference::Tamil.native_name(), "தமிழ்");
let ta = LANGUAGES.iter().find(|l| l.code == "ta").unwrap();
assert_eq!(ta.plural_forms, 2);
with_language("ta", || {
assert_eq!(count(1, "{n} commit", "{n} commits"), "1 கமிட்");
assert_eq!(count(5, "{n} commit", "{n} commits"), "5 கமிட்கள்");
assert_eq!(t("Layers"), "அடுக்குகள்");
});
assert_eq!(with_language("en", || Preference::Tamil.name()), "Tamil");
let mut app = CadApp::new(Session::new(), Services::default());
let r = app.run("ui.language", json!({"lang": "ta"})).unwrap();
let shown = crate::theme::can_show("ta");
assert_eq!(r["interfaceLanguage"], "ta");
assert_eq!(r["shown"], if shown { "ta" } else { "en" });
assert_eq!(app.ui.interface_language, Preference::Tamil);
if shown {
assert_eq!(with_language("ta", || Preference::Tamil.name()), "தமிழ்");
} else {
assert!(app.status.as_ref().is_some_and(|(s, _)| s.contains("No Tamil font")));
assert_eq!(with_language("ta", || Preference::Tamil.name()), "Tamil");
}
}
/// Vietnamese has one form for every count, and shows only with an interface font that has its
/// tone-marked letters; without one it stays English and says why.
#[test]
+1
View File
@@ -341,6 +341,7 @@ fn run_language_command(app: &mut CadApp, id: &str, params: &Value) -> Option<Re
}
"ar" => "No Arabic font is installed, so the interface stays in English. Install one (Noto Sans Arabic, for example) to use Arabic.",
"ka" => "This build has no Georgian font, so the interface stays in English. Build with craft-fonts (its Geor face) to use Georgian.",
"ta" => "No Tamil font is installed, so the interface stays in English. Install one (Noto Sans Tamil or Lohit Tamil, for example) to use Tamil.",
_ => "No Chinese font is installed, so the interface stays in English. Install one (Noto Sans CJK, for example) to use Chinese.",
});
}
+1 -1
View File
@@ -10,7 +10,7 @@
//! |---|---|
//! | `theme` | `"system"`, `"light"` or `"dark"` |
//! | `animations` | `"system"`, `"on"` or `"off"`: dialog and menu fades and smoothed scrolling |
//! | `interfaceLanguage` | `"auto"`, `"en"`, `"uk"`, `"pt-BR"`, `"de"`, `"es"`, `"cs"`, `"ru"`, `"fr"`, `"zh"`, `"it"`, `"ko"`, `"sv"`, `"ar"`, `"hu"`, `"tr"`, `"bs"`, `"vi"`, `"el"` or `"ka"` |
//! | `interfaceLanguage` | `"auto"`, `"en"`, `"uk"`, `"pt-BR"`, `"de"`, `"es"`, `"cs"`, `"ru"`, `"fr"`, `"zh"`, `"it"`, `"ko"`, `"sv"`, `"ar"`, `"hu"`, `"tr"`, `"bs"`, `"vi"`, `"el"`, `"ka"` or `"ta"` |
//! | `saveFormat` | `"dxf"` or `"dwg"`: the format Save As suggests for new drawings |
//! | `saveVersion` | `"2000"` … `"2018"`: the version drawings with no file yet are saved in |
//! | `SAVETIME` | minutes between automatic saves, 0–600 (0: off) |
+27 -6
View File
@@ -630,19 +630,28 @@ fn read_only(ui: &mut egui::Ui, text: &str) {
value_box(ui, crate::i18n::t(text), false, false).on_hover_text(crate::tl!("Read-only"));
}
/// The All and My halves of the Properties header's segmented control, which ends at `right`:
/// 35 px each, wider where a label needs it (a Tamil "All" does), so labels never overlap.
fn segment_halves(right: f32, top: f32, all_width: f32, my_width: f32) -> (Rect, Rect) {
let fit = |text: f32| (text + 12.0).max(35.0);
let my = Rect::from_min_size(pos2(right - fit(my_width), top), vec2(fit(my_width), 18.0));
let all = Rect::from_min_size(pos2(my.left() - fit(all_width), top), vec2(fit(all_width), 18.0));
(all, my)
}
/// The Properties header: All/My, the selection-type filter and the PICKADD / Select Objects /
/// Quick Select buttons.
fn properties_header(app: &mut CadApp, ui: &mut egui::Ui) {
let t = Tokens::get();
let hr = section_header(ui, "Properties");
// All | My segmented control ("My" property sets don't exist yet).
let seg = Rect::from_min_size(pos2(hr.right() - 120.0, hr.top() + 4.0), vec2(70.0, 18.0));
ui.painter().rect_filled(seg, 3.0, t.chrome_dark);
let half = Rect::from_min_size(seg.min, vec2(35.0, 18.0));
let my = half.translate(vec2(35.0, 0.0));
let (all_label, my_label) = (crate::tl!("All"), crate::tl!("My"));
let width = |text: &str| ui.painter().layout_no_wrap(text.to_owned(), crate::theme::small(), t.text).size().x;
let (half, my) = segment_halves(hr.right() - 50.0, hr.top() + 4.0, width(all_label), width(my_label));
ui.painter().rect_filled(half.union(my), 3.0, t.chrome_dark);
ui.painter().rect_filled(if app.ui.properties_all { half } else { my }, 3.0, t.control);
ui.painter().text(half.center(), egui::Align2::CENTER_CENTER, crate::tl!("All"), crate::theme::small(), t.text);
ui.painter().text(my.center(), egui::Align2::CENTER_CENTER, crate::tl!("My"), crate::theme::small(), t.text_faint);
ui.painter().text(half.center(), egui::Align2::CENTER_CENTER, all_label, crate::theme::small(), t.text);
ui.painter().text(my.center(), egui::Align2::CENTER_CENTER, my_label, crate::theme::small(), t.text_faint);
ui.interact(my, ui.scope_id().with("prop_my"), Sense::hover()).on_hover_text(crate::tl!("My properties: not available yet"));
let sel = app.session.selection();
let pickadd = app.session.settings.pickadd;
@@ -1507,6 +1516,18 @@ mod tests {
use egui::{Color32, Shape};
use egui_kittest::kittest::Queryable;
/// English keeps the 35 px halves where they were (right − 120 to right − 50); a longer label
/// widens its own half, leftwards, so All and My never overlap.
#[test]
fn all_my_halves_fit_their_labels() {
let (all, my) = segment_halves(200.0, 10.0, 14.0, 13.0);
assert_eq!(all, Rect::from_min_size(pos2(130.0, 10.0), vec2(35.0, 18.0)));
assert_eq!(my, Rect::from_min_size(pos2(165.0, 10.0), vec2(35.0, 18.0)));
let (all, my) = segment_halves(200.0, 10.0, 58.0, 30.0);
assert!(all.width() >= 58.0 + 12.0 && my.width() >= 30.0 + 12.0, "{all:?} {my:?}");
assert!(all.right() <= my.left() && my.right() == 200.0, "{all:?} {my:?}");
}
#[test]
fn shown_part_takes_off_only_the_number_tag() {
assert_eq!(shown_part(&exact("5.00".into(), 5.0)), "5.00");
+123 -4
View File
@@ -314,8 +314,9 @@ pub fn mono() -> FontId {
/// language: file, layout and layer names can be Japanese or Chinese whatever the interface
/// shows (#513). In a Chinese interface (`language` "zh…") the Chinese font comes first, else a
/// Japanese one, so names take their own glyph forms; in an Arabic interface an installed
/// Arabic font follows. The embedded Georgian face loads in every language, so the language
/// picker can show ქართული. A font embedded from craft-fonts comes
/// Arabic font follows, and in a Tamil one an installed Tamil font ([`tamil_font`]). The
/// embedded Georgian face loads in every language, so the language picker can show ქართული. A
/// font embedded from craft-fonts comes
/// last, for systems without any (and the web build, which has no system fonts). A Korean
/// interface adds a Hangul font only when the CJK font found doesn't cover Hangul
/// ([`korean_font`]).
@@ -365,6 +366,12 @@ pub fn install_fonts(ctx: &egui::Context, language: &str) {
{
added.push(("system-arabic".into(), std::sync::Arc::new(egui::FontData::from_owned(bytes))));
}
// தமிழ்: likewise an installed Tamil face, for the Tamil interface.
if language == "ta"
&& let Some(bytes) = tamil_font().and_then(|p| read_capped(p, MAX_UI_FONT_BYTES))
{
added.push(("system-tamil".into(), std::sync::Arc::new(egui::FontData::from_owned(bytes))));
}
}
let embedded: Vec<_> = cadcraft_fonts::CRAFT_FONTS.iter().collect();
added.extend(
@@ -484,7 +491,8 @@ pub fn shows_vietnamese(language: &str) -> bool {
/// Chinese interface takes the face with its own glyphs ahead of a Japanese one — a Japanese face
/// shares most ideographs but lacks the simplified-only ones (图 园 测), which would be tofu.
/// The Georgian face follows in every language (egui's bundled faces carry no Georgian glyphs, and
/// the picker names the language ქართული); العربية adds its Arabic face after those.
/// the picker names the language ქართული); العربية adds its Arabic face after those, and தமிழ்
/// its Tamil face.
fn embedded_ui_faces<'a>(faces: &[&'a cadcraft_fonts::CraftFont], language: &str) -> Vec<&'a cadcraft_fonts::CraftFont> {
let cjk = |f: &&cadcraft_fonts::CraftFont| f.style == "Regular" && f.scripts.iter().any(|s| matches!(*s, "Jpan" | "Hans" | "Hant"));
let mut out: Vec<_> = faces.iter().copied().filter(cjk).collect();
@@ -496,6 +504,9 @@ fn embedded_ui_faces<'a>(faces: &[&'a cadcraft_fonts::CraftFont], language: &str
if language == "ar" {
out.extend(faces.iter().copied().filter(|f| f.style == "Regular" && f.scripts.contains(&"Arab")));
}
if language == "ta" {
out.extend(faces.iter().copied().filter(|f| f.style == "Regular" && f.scripts.contains(&"Taml")));
}
out
}
@@ -592,6 +603,83 @@ pub fn arabic_font() -> Option<&'static std::path::Path> {
None
}
/// The Tamil letters the Tamil interface shows: its catalog and its own name.
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
fn tamil_letters() -> &'static std::collections::BTreeSet<char> {
static LETTERS: std::sync::OnceLock<std::collections::BTreeSet<char>> = std::sync::OnceLock::new();
LETTERS.get_or_init(|| {
include_str!("i18n/ta.tsv")
.lines()
.filter(|line| !line.starts_with('#'))
.filter_map(|line| line.split('\t').nth(2))
.flat_map(str::chars)
.chain("தமிழ்".chars())
.filter(|c| ('\u{0b80}'..='\u{0bff}').contains(c))
.collect()
})
}
/// Whether `face` has every Tamil letter the Tamil interface shows (rejects malformed fonts and
/// faces without Tamil).
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
fn covers_tamil(face: &cadcraft_fonts::ttf::Face) -> bool {
tamil_letters().iter().all(|c| face.has_glyph(*c))
}
/// An installed font with the Tamil letters, for the தமிழ் interface; fonts are never bundled
/// (only looked for where the OS or common packages put them). The file's first face, the one
/// egui uses, must have every Tamil letter the interface shows. Checked once.
pub fn tamil_font() -> Option<&'static std::path::Path> {
#[cfg(not(target_arch = "wasm32"))]
{
static FOUND: std::sync::OnceLock<Option<std::path::PathBuf>> = std::sync::OnceLock::new();
FOUND
.get_or_init(|| {
let candidates: &[&str] = if cfg!(target_os = "macos") {
&[
"/System/Library/Fonts/Supplemental/Tamil Sangam MN.ttc",
"/System/Library/Fonts/Tamil Sangam MN.ttc",
"/System/Library/Fonts/Supplemental/Tamil MN.ttc",
"/System/Library/Fonts/Supplemental/InaiMathi-MN.ttc",
]
} else if cfg!(windows) {
&[
"C:\\Windows\\Fonts\\Nirmala.ttc",
"C:\\Windows\\Fonts\\Nirmala.ttf",
"C:\\Windows\\Fonts\\latha.ttf",
"C:\\Windows\\Fonts\\vijaya.ttf",
]
} else {
&[
"/usr/share/fonts/truetype/noto/NotoSansTamil-Regular.ttf",
"/usr/share/fonts/noto/NotoSansTamil-Regular.ttf",
"/usr/share/fonts/google-noto/NotoSansTamil-Regular.ttf",
"/usr/share/fonts/google-noto-vf/NotoSansTamil[wght].ttf",
"/usr/share/fonts/truetype/noto/NotoSansTamilUI-Regular.ttf",
"/usr/share/fonts/truetype/lohit-tamil/Lohit-Tamil.ttf",
"/usr/share/fonts/lohit-tamil/Lohit-Tamil.ttf",
"/usr/share/fonts/truetype/samyak-fonts/Samyak-Tamil.ttf",
]
};
let covers = |p: &std::path::Path| {
read_capped(p, MAX_UI_FONT_BYTES)
.and_then(|bytes| cadcraft_fonts::ttf::faces(&std::sync::Arc::new(bytes)).into_iter().next())
.is_some_and(|face| covers_tamil(&face))
};
candidates.iter().map(std::path::PathBuf::from).find(|p| covers(p))
})
.as_deref()
}
#[cfg(target_arch = "wasm32")]
None
}
/// Whether the interface in `language` shows the Tamil letters (தமிழ் in the language picker): only
/// the Tamil interface loads a Tamil font, so only it does.
pub fn shows_tamil(language: &str) -> bool {
language == "ta" && can_show("ta")
}
/// An installed Japanese font, for Japanese names in a non-Chinese interface. Checked once.
#[cfg_attr(target_arch = "wasm32", allow(dead_code))]
fn japanese_font() -> Option<&'static std::path::Path> {
@@ -732,13 +820,14 @@ pub fn shows_hangul(language: &str) -> bool {
/// with its glyphs (installed, or the CJK face this build embedded from craft-fonts), Korean a
/// font with Hangul, العربية an installed Arabic font or the embedded Arabic face, Tiếng Việt a
/// system interface font with its tone-marked letters ([`vietnamese_font`]), ქართული the
/// embedded Georgian face.
/// embedded Georgian face, தமிழ் an installed Tamil font ([`tamil_font`]) or the embedded Tamil face.
pub fn can_show(language: &str) -> bool {
match language {
"ko" => shows_hangul("ko"),
"vi" => vietnamese_font().is_some(),
"ar" => arabic_font().is_some() || embedded_script("Arab"),
"ka" => embedded_script("Geor"),
"ta" => tamil_font().is_some() || embedded_script("Taml"),
l if l.starts_with("zh") => cjk_font().is_some() || embedded_script("Hans") || embedded_script("Hant"),
_ => true,
}
@@ -842,6 +931,23 @@ mod tests {
}
}
/// A Tamil font counts only when its first face has every Tamil letter the interface shows:
/// the catalog's letters, its two-part and pre-base vowel signs and the language's own name
/// among them.
#[test]
fn tamil_font_needs_every_letter_of_the_tamil_interface() {
let letters = super::tamil_letters();
assert!("தமிழ்".chars().chain(['ொ', 'ோ', 'ை']).all(|c| letters.contains(&c)), "{letters:?}");
assert!(letters.iter().all(|c| ('\u{0b80}'..='\u{0bff}').contains(c)));
for bytes in [vec![], vec![0xff; 32]] {
assert!(cadcraft_fonts::ttf::faces(&std::sync::Arc::new(bytes)).first().is_none_or(|f| !super::covers_tamil(f)));
}
if let Some(path) = super::tamil_font() {
let face = std::fs::read(path).ok().and_then(|bytes| cadcraft_fonts::ttf::faces(&std::sync::Arc::new(bytes)).into_iter().next());
assert!(face.is_some_and(|f| super::covers_tamil(&f)), "{}", path.display());
}
}
/// The interface's own script leads the embedded faces it loads, and العربية adds its face.
#[test]
fn embedded_faces_lead_with_the_interfaces_own_script() {
@@ -858,6 +964,16 @@ mod tests {
// العربية adds the Arabic face, after the CJK ones egui's bundled faces have no glyphs for.
assert_eq!(families(&super::embedded_ui_faces(&faces, "ar")), ["BIZ UDPGothic", "Han Test Face", "Noto Sans Georgian", "Noto Sans Arabic"]);
assert_eq!(families(&super::embedded_ui_faces(&faces, "ka")), ["BIZ UDPGothic", "Han Test Face", "Noto Sans Georgian"]);
// தமிழ் adds the Tamil face; no other interface loads it.
let tamil = face("Noto Sans Tamil", &["Taml"]);
let with_tamil = [&japanese, &chinese, &arabic, &georgian, &tamil];
assert_eq!(
families(&super::embedded_ui_faces(&with_tamil, "ta")),
["BIZ UDPGothic", "Han Test Face", "Noto Sans Georgian", "Noto Sans Tamil"]
);
for language in ["en", "ar", "ka", "zh"] {
assert!(!families(&super::embedded_ui_faces(&with_tamil, language)).contains(&"Noto Sans Tamil"), "{language}");
}
// Another weight is a style of a face, not an interface face of its own.
let bold = CraftFont { family: "BIZ UDPGothic", style: "Bold", scripts: &["Jpan"], bytes: &[] };
assert!(super::embedded_ui_faces(&[&bold], "en").is_empty());
@@ -877,6 +993,9 @@ mod tests {
assert!(!super::embedded_script("Hans") || super::can_show("zh"));
// ქართული rides on the embedded Georgian face alone.
assert_eq!(super::can_show("ka"), super::embedded_script("Geor"));
// தமிழ் takes an installed Tamil font or the embedded Tamil face.
assert!(super::any_script(&[face("Noto Sans Tamil", &["Taml"])], "Taml") && !super::any_script(&faces, "Taml"));
assert_eq!(super::can_show("ta"), super::tamil_font().is_some() || super::embedded_script("Taml"));
assert!(super::can_show("en") && super::can_show("uk"));
}
+3 -2
View File
@@ -188,8 +188,9 @@ Select a language with `engine.execute` and the UI command `ui.language`:
{"id":1,"method":"engine.execute","params":{"command":"ui.language","params":{"lang":"uk"}}}
```
Supported values are `auto`, `en`, `uk`, `pt-BR`, `de`, `es`, `cs`, `ru`, `fr`, `zh`, `it`, `ko`, `sv`, `ar`, `hu`, `tr`, `bs`, `el` and `ka`.
Chinese needs an installed CJK font, Arabic an installed Arabic font; Korean needs a font covering the Korean interface from the
Supported values are `auto`, `en`, `uk`, `pt-BR`, `de`, `es`, `cs`, `ru`, `fr`, `zh`, `it`, `ko`, `sv`, `ar`, `hu`, `tr`, `bs`, `el`, `ka` and `ta`.
Chinese needs an installed CJK font, Arabic an installed Arabic font, Tamil an installed Tamil font
or the `Taml` face from craft-fonts; Korean needs a font covering the Korean interface from the
optional craft-fonts input or the operating system; Georgian needs the `Geor` face from craft-fonts (an installed font
does not count). Without a suitable font, the saved choice is
retained and the result's `shown` is `en`. `ui.set` also accepts
+29 -3
View File
@@ -1,7 +1,7 @@
# Interface languages
Choose **Edit → Interface Language** and select **Auto (system language)**, **English**,
**Українська**, **Português (Brasil)**, **Deutsch**, **Español**, **Čeština** (Czech), **Русский**, **Français**, **简体中文**, **Italiano**, **한국어** (Korean), **Svenska** (Swedish), **العربية** (Arabic), **Magyar** (Hungarian), **Türkçe** (Turkish), **Ελληνικά** (Greek), **Bosanski** (Bosnian), **ქართული** (Georgian), or **Tiếng Việt** (Vietnamese).
**Українська**, **Português (Brasil)**, **Deutsch**, **Español**, **Čeština** (Czech), **Русский**, **Français**, **简体中文**, **Italiano**, **한국어** (Korean), **Svenska** (Swedish), **العربية** (Arabic), **Magyar** (Hungarian), **Türkçe** (Turkish), **Ελληνικά** (Greek), **Bosanski** (Bosnian), **ქართული** (Georgian), **Tiếng Việt** (Vietnamese), or **தமிழ்** (Tamil).
The interface updates without restarting, including the native macOS menus.
The choice is saved with the other interface preferences (`cadcraft.prefs`, beside the theme):
eframe storage on the desktop, browser local storage on the web. Installations without a saved
@@ -11,7 +11,7 @@ Auto uses the first supported language in the operating system's preferred local
browser's `navigator.languages` on the web. BCP 47 and POSIX tags select their primary language:
`uk-UA` → `uk`, `de_AT.UTF-8` → `de`, `es-MX` → `es`, `pt_BR.UTF-8` → `pt-BR`,
`cs-CZ` and `cs_CZ.UTF-8` → `cs`, `it-IT` and `it_CH.UTF-8` → `it`, `ko-KR` and `ko_KR.UTF-8` → `ko`,
`sv-SE`, `sv-FI` and `sv_SE.UTF-8` → `sv`, `hu-HU` and `hu_HU.UTF-8` → `hu`, `tr-TR` and `tr_TR.UTF-8` → `tr`, `ka-GE` and `ka_GE.UTF-8` → `ka`. Unsupported languages fall back to English.
`sv-SE`, `sv-FI` and `sv_SE.UTF-8` → `sv`, `hu-HU` and `hu_HU.UTF-8` → `hu`, `tr-TR` and `tr_TR.UTF-8` → `tr`, `ka-GE` and `ka_GE.UTF-8` → `ka`, `ta-IN`, `ta-LK` and `ta_IN.UTF-8` → `ta`. Unsupported languages fall back to English.
Set `CADCRAFT_LOCALE=cs-CZ` to override the desktop's locale for a launch.
An explicit saved language choice takes precedence over that override.
@@ -22,7 +22,7 @@ Automation can select the language through the existing control channel:
```
The `ui.set` method also accepts `{"interfaceLanguage":"cs"}`. Supported values are `auto`,
`en`, `uk`, `pt-BR`, `de`, `es`, `cs`, `ru`, `fr`, `zh`, `it`, `ko`, `sv`, `ar`, `hu`, `tr`, `bs`, `el`, `ka`, and `vi`; invalid values are rejected without changing the current
`en`, `uk`, `pt-BR`, `de`, `es`, `cs`, `ru`, `fr`, `zh`, `it`, `ko`, `sv`, `ar`, `hu`, `tr`, `bs`, `el`, `ka`, `vi`, and `ta`; invalid values are rejected without changing the current
selection. Resetting palettes keeps the language choice.
## Translation coverage
@@ -144,6 +144,32 @@ then shows **ქართული**. A build without that face keeps the saved
in English, names the language **Georgian** in the picker, and the language command reports that a
Georgian font is needed.
## Tamil (`ta`) interface
Tamil has **1,507 rows**: 1,505 ordinary labels and two count templates with one and other forms
(**1 கமிட்**, **5 கமிட்கள்**). Menu headings take their ordinary translation, so there are no `menu`
rows, and no marked UI literal falls back to English. 1,289 rows come from the Tamil CADCraft and
shared catalogs in [storytold/craft-i18n](https://github.com/storytold/craft-i18n) (`locales/ta/`),
reviewed there for language and terminology by native speakers; the other 218 (newer strings: the
Hatch and Gradient dialog, dynamic blocks, selection and grip options, command aliases, plot
settings, drawing units and save warnings) are AI-assisted and not yet reviewed by a native
speaker. Commands use the
imperative (**சேமி**, **திற**); prompts read "… குறிப்பிடவும்" for Specify, "… உள்ளிடவும்" for
Enter and "… தேர்ந்தெடுக்கவும்" for Select. The vocabulary is ordinary Tamil drafting language:
அடுக்கு (layer), தொகுதி (block), பரிமாணம் (dimension), கோட்டு நிரப்பு (hatch), தளவமைப்பு
(layout), காட்சிப்புலம் (viewport), பிடிப்புள்ளி (grip), வெளிப்புறக் குறிப்பீடு (xref). Command
IDs, keywords the engine accepts and product and format names (DXF, PDF, AutoLISP) keep their
spelling. No other product's localization was consulted.
egui's bundled faces have no Tamil letters. The Tamil interface loads an installed Tamil font whose
first face has every Tamil letter the catalog uses (Nirmala UI or Latha on Windows, Tamil Sangam MN
or Tamil MN on macOS, Noto Sans Tamil, Lohit Tamil or Samyak Tamil on Linux), or the craft-fonts
Noto Sans Tamil (`Taml`) face when a build embeds it; the web build keeps that face among its
embedded ones. egui shapes the text with HarfRust, so vowel signs take their places around the
consonant. Only the Tamil interface loads a Tamil font, so the picker shows **தமிழ்** there and
**Tamil** in every other language. Without a Tamil font the saved `ta` choice is kept, the
interface stays in English, and the language command reports that a Tamil font is needed.
## Adding translations
The implementation follows the display-time catalog pattern used by