f 0.1.2

A lightweight dual-pane file manager with GUI built using iced, inspired by Total Commander.
use std::fmt;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Language {
    English,
    Chinese,
    Japanese,
}

impl Language {
    const ALL: [Language; 3] = [Language::English, Language::Chinese, Language::Japanese];

    pub fn all() -> &'static [Language] {
        &Self::ALL
    }

    pub fn native_label(self) -> &'static str {
        match self {
            Language::English => "English",
            Language::Chinese => "中文",
            Language::Japanese => "日本語",
        }
    }
}

impl Default for Language {
    fn default() -> Self {
        Language::English
    }
}

impl fmt::Display for Language {
    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
        f.write_str(self.native_label())
    }
}

#[derive(Debug, Clone, Copy)]
pub struct Strings {
    pub title_base: &'static str,
    pub badge_open_source: &'static str,
    pub badge_registered: &'static str,
    pub toolbar_refresh: &'static str,
    pub toolbar_hashes: &'static str,
    pub toolbar_theme_dark: &'static str,
    pub toolbar_theme_light: &'static str,
    pub toolbar_config: &'static str,
    pub toolbar_about: &'static str,
    pub config_font_size: &'static str,
    pub config_language: &'static str,
    pub config_language_placeholder: &'static str,
    pub registration_heading: &'static str,
    pub registration_placeholder: &'static str,
    pub registration_apply: &'static str,
    pub registration_clear: &'static str,
    pub registration_status_open: &'static str,
    pub registration_status_registered: &'static str,
    pub registration_status_label: &'static str,
    pub registration_cta: &'static str,
    pub action_copy_right: &'static str,
    pub action_copy_left: &'static str,
    pub action_delete_left: &'static str,
    pub action_delete_right: &'static str,
    pub action_swap: &'static str,
    pub function_f5_copy: &'static str,
    pub function_f6_move: &'static str,
    pub function_f7_mkdir: &'static str,
    pub function_f8_delete: &'static str,
    pub function_f2_refresh: &'static str,
    pub panel_up: &'static str,
    pub panel_refresh: &'static str,
    pub input_path: &'static str,
    pub input_filter: &'static str,
    pub input_new_folder: &'static str,
    pub button_create: &'static str,
    pub input_rename_to: &'static str,
    pub button_rename: &'static str,
    pub button_cancel: &'static str,
    pub header_name: &'static str,
    pub header_extension: &'static str,
    pub header_size: &'static str,
    pub header_date: &'static str,
    pub header_attrs: &'static str,
    pub status_items: &'static str,
    pub status_selected: &'static str,
    pub status_loading: &'static str,
    pub status_error_prefix: &'static str,
    pub viewer_loading: &'static str,
    pub viewer_title: &'static str,
    pub viewer_error_title: &'static str,
    pub banner_ready: &'static str,
    pub banner_info_prefix: &'static str,
    pub banner_error_prefix: &'static str,
    pub button_close: &'static str,
    pub dir_label: &'static str,
    pub size_unit_kb: &'static str,
    pub center_view: &'static str,
    pub center_edit: &'static str,
    pub center_copy: &'static str,
    pub center_rename: &'static str,
    pub center_zip: &'static str,
    pub center_folder: &'static str,
    pub about_project: &'static str,
    pub about_author: &'static str,
    pub about_license: &'static str,
    pub new_folder_suggestion: &'static str,
}

pub fn strings(language: Language) -> &'static Strings {
    match language {
        Language::English => &EN_STRINGS,
        Language::Chinese => &ZH_STRINGS,
        Language::Japanese => &JA_STRINGS,
    }
}

const EN_STRINGS: Strings = Strings {
    title_base: "f Dual Pane File Manager",
    badge_open_source: "[Open Source Version]",
    badge_registered: "[Registered Version]",
    toolbar_refresh: "Refresh All",
    toolbar_hashes: "Hashes",
    toolbar_theme_dark: "Dark Mode",
    toolbar_theme_light: "Light Mode",
    toolbar_config: "Config",
    toolbar_about: "About",
    config_font_size: "Font Size",
    config_language: "Language",
    config_language_placeholder: "Choose",
    registration_heading: "Registration",
    registration_placeholder: "Enter registration code",
    registration_apply: "Register",
    registration_clear: "Clear",
    registration_status_open: "Not registered",
    registration_status_registered: "Registered to {name}",
    registration_status_label: "Edition",
    registration_cta: "Click to register",
    action_copy_right: "Copy ->",
    action_copy_left: "<- Copy",
    action_delete_left: "Delete Left",
    action_delete_right: "Delete Right",
    action_swap: "Swap",
    function_f5_copy: "F5 Copy",
    function_f6_move: "F6 Move",
    function_f7_mkdir: "F7 Mkdir",
    function_f8_delete: "F8 Delete",
    function_f2_refresh: "F2 Refresh",
    panel_up: "Up",
    panel_refresh: "Refresh",
    input_path: "Path",
    input_filter: "Filter",
    input_new_folder: "New folder",
    button_create: "Create",
    input_rename_to: "Rename to",
    button_rename: "Rename",
    button_cancel: "Cancel",
    header_name: "Name",
    header_extension: "Ext",
    header_size: "Size (KB)",
    header_date: "Date",
    header_attrs: "Attrs",
    status_items: "{total} items",
    status_selected: "{total} items — selected: {name}",
    status_loading: "Loading...",
    status_error_prefix: "Error",
    viewer_loading: "Loading...",
    viewer_title: "Viewing {path}",
    viewer_error_title: "Could not open {path}",
    banner_ready: "Ready",
    banner_info_prefix: "[info]",
    banner_error_prefix: "[error]",
    button_close: "Close",
    dir_label: "DIR",
    size_unit_kb: "KB",
    center_view: "View",
    center_edit: "Edit",
    center_copy: "Copy",
    center_rename: "Rename",
    center_zip: "Zip",
    center_folder: "Folder",
    about_project: "Project: https://github.com/hkwk/f",
    about_author: "Author: hkwk",
    about_license: "License: GPL-3.0-only",
    new_folder_suggestion: "New Folder",
};

const ZH_STRINGS: Strings = Strings {
    title_base: "f 双栏文件管理器",
    badge_open_source: "[开源版]",
    badge_registered: "[注册版]",
    toolbar_refresh: "刷新全部",
    toolbar_hashes: "计算哈希",
    toolbar_theme_dark: "夜间模式",
    toolbar_theme_light: "日间模式",
    toolbar_config: "设置",
    toolbar_about: "关于",
    config_font_size: "字体大小",
    config_language: "界面语言",
    config_language_placeholder: "请选择",
    registration_heading: "软件注册",
    registration_placeholder: "输入注册码",
    registration_apply: "注册",
    registration_clear: "清除",
    registration_status_open: "当前未注册",
    registration_status_registered: "注册用户:{name}",
    registration_status_label: "版本",
    registration_cta: "点击输入注册码",
    action_copy_right: "复制 ->",
    action_copy_left: "<- 复制",
    action_delete_left: "删除左侧",
    action_delete_right: "删除右侧",
    action_swap: "交换",
    function_f5_copy: "F5 复制",
    function_f6_move: "F6 移动",
    function_f7_mkdir: "F7 新建",
    function_f8_delete: "F8 删除",
    function_f2_refresh: "F2 刷新",
    panel_up: "上级",
    panel_refresh: "刷新",
    input_path: "路径",
    input_filter: "筛选",
    input_new_folder: "新建文件夹",
    button_create: "创建",
    input_rename_to: "重命名为",
    button_rename: "重命名",
    button_cancel: "取消",
    header_name: "文件名",
    header_extension: "扩展名",
    header_size: "大小(KB)",
    header_date: "日期",
    header_attrs: "属性",
    status_items: "{total} 项",
    status_selected: "{total} 项 — 已选:{name}",
    status_loading: "加载中...",
    status_error_prefix: "错误",
    viewer_loading: "加载中...",
    viewer_title: "查看 {path}",
    viewer_error_title: "无法打开 {path}",
    banner_ready: "就绪",
    banner_info_prefix: "[提示]",
    banner_error_prefix: "[错误]",
    button_close: "关闭",
    dir_label: "目录",
    size_unit_kb: "KB",
    center_view: "查看",
    center_edit: "编辑",
    center_copy: "复制",
    center_rename: "重命名",
    center_zip: "压缩",
    center_folder: "新建",
    about_project: "项目: https://github.com/hkwk/f",
    about_author: "作者: hkwk",
    about_license: "许可证: GPL-3.0-only",
    new_folder_suggestion: "新建文件夹",
};

const JA_STRINGS: Strings = Strings {
    title_base: "f デュアルペインファイルマネージャ",
    badge_open_source: "[オープンソース版]",
    badge_registered: "[登録版]",
    toolbar_refresh: "再読み込み",
    toolbar_hashes: "ハッシュ",
    toolbar_theme_dark: "ダークモード",
    toolbar_theme_light: "ライトモード",
    toolbar_config: "設定",
    toolbar_about: "情報",
    config_font_size: "フォントサイズ",
    config_language: "表示言語",
    config_language_placeholder: "選択",
    registration_heading: "ライセンス登録",
    registration_placeholder: "登録コードを入力",
    registration_apply: "登録",
    registration_clear: "解除",
    registration_status_open: "未登録です",
    registration_status_registered: "{name} として登録済み",
    registration_status_label: "エディション",
    registration_cta: "登録コードを入力",
    action_copy_right: "コピー ->",
    action_copy_left: "<- コピー",
    action_delete_left: "左側を削除",
    action_delete_right: "右側を削除",
    action_swap: "入れ替え",
    function_f5_copy: "F5 コピー",
    function_f6_move: "F6 移動",
    function_f7_mkdir: "F7 作成",
    function_f8_delete: "F8 削除",
    function_f2_refresh: "F2 更新",
    panel_up: "上へ",
    panel_refresh: "更新",
    input_path: "パス",
    input_filter: "フィルター",
    input_new_folder: "新しいフォルダー",
    button_create: "作成",
    input_rename_to: "名前を変更",
    button_rename: "変更",
    button_cancel: "キャンセル",
    header_name: "名前",
    header_extension: "拡張子",
    header_size: "サイズ(KB)",
    header_date: "日時",
    header_attrs: "属性",
    status_items: "{total} 件",
    status_selected: "{total} 件 — 選択: {name}",
    status_loading: "読み込み中...",
    status_error_prefix: "エラー",
    viewer_loading: "読み込み中...",
    viewer_title: "{path} を表示",
    viewer_error_title: "{path} を開けません",
    banner_ready: "待機中",
    banner_info_prefix: "[情報]",
    banner_error_prefix: "[エラー]",
    button_close: "閉じる",
    dir_label: "DIR",
    size_unit_kb: "KB",
    center_view: "表示",
    center_edit: "編集",
    center_copy: "コピー",
    center_rename: "名前変更",
    center_zip: "圧縮",
    center_folder: "フォルダ",
    about_project: "プロジェクト: https://github.com/hkwk/f",
    about_author: "作者: hkwk",
    about_license: "ライセンス: GPL-3.0-only",
    new_folder_suggestion: "新しいフォルダー",
};