2026-07-15 17:48:54 +03:00
|
|
|
|
//! Internationalization (i18n) support for the HCIE Iced GUI.
|
|
|
|
|
|
//!
|
|
|
|
|
|
//! Provides translation keys for UI strings with English and Turkish locales.
|
|
|
|
|
|
//! The `t()` function returns a `&'static str` for the given language and key,
|
|
|
|
|
|
//! enabling zero-cost string lookups at render time.
|
|
|
|
|
|
|
|
|
|
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
|
|
|
|
|
|
|
|
/// Supported UI languages.
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
|
|
|
|
|
|
pub enum Language {
|
|
|
|
|
|
#[default]
|
|
|
|
|
|
English,
|
|
|
|
|
|
Turkish,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Translation keys for menu items and common UI strings.
|
|
|
|
|
|
#[allow(dead_code)]
|
|
|
|
|
|
pub enum TranslationKey {
|
|
|
|
|
|
File,
|
|
|
|
|
|
Edit,
|
|
|
|
|
|
Image,
|
|
|
|
|
|
Layer,
|
|
|
|
|
|
Filter,
|
|
|
|
|
|
Select,
|
|
|
|
|
|
View,
|
|
|
|
|
|
Window,
|
|
|
|
|
|
Help,
|
|
|
|
|
|
Tools,
|
|
|
|
|
|
New,
|
|
|
|
|
|
Open,
|
|
|
|
|
|
Save,
|
|
|
|
|
|
Export,
|
|
|
|
|
|
Quit,
|
|
|
|
|
|
Undo,
|
|
|
|
|
|
Redo,
|
|
|
|
|
|
Settings,
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Returns the translated string for the given language and key.
|
|
|
|
|
|
///
|
|
|
|
|
|
/// Uses match arms to return `&'static str` — no allocations at call site.
|
2026-07-19 00:55:40 +03:00
|
|
|
|
#[allow(dead_code)]
|
2026-07-15 17:48:54 +03:00
|
|
|
|
pub fn t(lang: Language, key: TranslationKey) -> &'static str {
|
|
|
|
|
|
match lang {
|
|
|
|
|
|
Language::Turkish => match key {
|
|
|
|
|
|
TranslationKey::File => "Dosya",
|
|
|
|
|
|
TranslationKey::Edit => "Düzen",
|
|
|
|
|
|
TranslationKey::Image => "Görüntü",
|
|
|
|
|
|
TranslationKey::Layer => "Katman",
|
|
|
|
|
|
TranslationKey::Filter => "Filtre",
|
|
|
|
|
|
TranslationKey::Select => "Seç",
|
|
|
|
|
|
TranslationKey::View => "Görünüm",
|
|
|
|
|
|
TranslationKey::Window => "Pencere",
|
|
|
|
|
|
TranslationKey::Help => "Yardım",
|
|
|
|
|
|
TranslationKey::Tools => "Araçlar",
|
|
|
|
|
|
TranslationKey::New => "Yeni...",
|
|
|
|
|
|
TranslationKey::Open => "Aç...",
|
|
|
|
|
|
TranslationKey::Save => "Kaydet",
|
|
|
|
|
|
TranslationKey::Export => "Dışa Aktar...",
|
|
|
|
|
|
TranslationKey::Quit => "Çıkış",
|
|
|
|
|
|
TranslationKey::Undo => "Geri Al",
|
|
|
|
|
|
TranslationKey::Redo => "İleri Al",
|
|
|
|
|
|
TranslationKey::Settings => "Ayarlar",
|
|
|
|
|
|
},
|
|
|
|
|
|
Language::English => match key {
|
|
|
|
|
|
TranslationKey::File => "File",
|
|
|
|
|
|
TranslationKey::Edit => "Edit",
|
|
|
|
|
|
TranslationKey::Image => "Image",
|
|
|
|
|
|
TranslationKey::Layer => "Layer",
|
|
|
|
|
|
TranslationKey::Filter => "Filter",
|
|
|
|
|
|
TranslationKey::Select => "Select",
|
|
|
|
|
|
TranslationKey::View => "View",
|
|
|
|
|
|
TranslationKey::Window => "Window",
|
|
|
|
|
|
TranslationKey::Help => "Help",
|
|
|
|
|
|
TranslationKey::Tools => "Tools",
|
|
|
|
|
|
TranslationKey::New => "New...",
|
|
|
|
|
|
TranslationKey::Open => "Open...",
|
|
|
|
|
|
TranslationKey::Save => "Save",
|
|
|
|
|
|
TranslationKey::Export => "Export...",
|
|
|
|
|
|
TranslationKey::Quit => "Quit",
|
|
|
|
|
|
TranslationKey::Undo => "Undo",
|
|
|
|
|
|
TranslationKey::Redo => "Redo",
|
|
|
|
|
|
TranslationKey::Settings => "Settings",
|
|
|
|
|
|
},
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|