feat(iced): add internationalization support
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
|
||||
use crate::ai_chat::{self, AiChatState, ChatMessage, SYSTEM_PROMPT};
|
||||
use crate::dialogs;
|
||||
use crate::i18n;
|
||||
use crate::dock::state::{DockState, PaneType};
|
||||
use crate::io::tablet::TabletState;
|
||||
use crate::panels;
|
||||
@@ -191,6 +192,8 @@ pub struct HcieIcedApp {
|
||||
pub dock_profile_rename_buf: String,
|
||||
/// Whether the dock profile dialog is visible.
|
||||
pub show_dock_profile_dialog: bool,
|
||||
/// Current UI language for internationalization.
|
||||
pub language: i18n::Language,
|
||||
}
|
||||
|
||||
/// A recently opened file entry.
|
||||
@@ -745,6 +748,7 @@ impl HcieIcedApp {
|
||||
dock_profile_rename_idx: None,
|
||||
dock_profile_rename_buf: String::new(),
|
||||
show_dock_profile_dialog: false,
|
||||
language: i18n::Language::default(),
|
||||
};
|
||||
|
||||
// Apply saved settings to tool state
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
//! 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.
|
||||
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",
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ mod canvas;
|
||||
mod color_picker;
|
||||
mod dialogs;
|
||||
mod dock;
|
||||
mod i18n;
|
||||
mod io;
|
||||
mod panels;
|
||||
mod script;
|
||||
|
||||
Reference in New Issue
Block a user