From c7624b626d43e23ae46b9b6370a2261b73ed228b Mon Sep 17 00:00:00 2001 From: young Date: Sat, 10 Aug 2024 05:55:36 +0800 Subject: [PATCH] feat!: Remove i18n support --- Cargo.lock | 388 -------------------------------------------- Cargo.toml | 3 - i18n/en-US/text.ftl | 18 -- i18n/zh-TW/text.ftl | 18 -- src/language.rs | 17 -- src/main.rs | 15 +- 6 files changed, 1 insertion(+), 458 deletions(-) delete mode 100644 i18n/en-US/text.ftl delete mode 100644 i18n/zh-TW/text.ftl delete mode 100644 src/language.rs diff --git a/Cargo.lock b/Cargo.lock index c950123..07ce01c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,274 +2,12 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "async-trait" -version = "0.1.81" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "autocfg" -version = "1.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" - -[[package]] -name = "chunky-vec" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb7bdea464ae038f09197b82430b921c53619fc8d2bcaf7b151013b3ca008017" - -[[package]] -name = "displaydoc" -version = "0.2.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "elsa" -version = "1.10.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d98e71ae4df57d214182a2e5cb90230c0192c6ddfcaa05c36453d46a54713e10" -dependencies = [ - "stable_deref_trait", -] - -[[package]] -name = "fluent" -version = "0.16.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb74634707bebd0ce645a981148e8fb8c7bccd4c33c652aeffd28bf2f96d555a" -dependencies = [ - "fluent-bundle", - "unic-langid", -] - -[[package]] -name = "fluent-bundle" -version = "0.15.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fe0a21ee80050c678013f82edf4b705fe2f26f1f9877593d13198612503f493" -dependencies = [ - "fluent-langneg", - "fluent-syntax", - "intl-memoizer", - "intl_pluralrules", - "rustc-hash", - "self_cell 0.10.3", - "smallvec", - "unic-langid", -] - -[[package]] -name = "fluent-fallback" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1010c29cde3a7eeb231c59d95411dcea1c1d91ad00dd733b076dbd885815024a" -dependencies = [ - "async-trait", - "chunky-vec", - "fluent-bundle", - "futures", - "once_cell", - "pin-cell", - "rustc-hash", - "unic-langid", -] - -[[package]] -name = "fluent-langneg" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c4ad0989667548f06ccd0e306ed56b61bd4d35458d54df5ec7587c0e8ed5e94" -dependencies = [ - "unic-langid", -] - -[[package]] -name = "fluent-resmgr" -version = "0.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2a2360469fd304ea6560a6dfb8f843328d3a6498f1c867f187e57993609af7e" -dependencies = [ - "elsa", - "fluent-bundle", - "fluent-fallback", - "futures", - "rustc-hash", - "thiserror", - "unic-langid", -] - -[[package]] -name = "fluent-syntax" -version = "0.11.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a530c4694a6a8d528794ee9bbd8ba0122e779629ac908d15ad5a7ae7763a33d" -dependencies = [ - "thiserror", -] - -[[package]] -name = "futures" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" -dependencies = [ - "futures-channel", - "futures-core", - "futures-executor", - "futures-io", - "futures-sink", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-channel" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" -dependencies = [ - "futures-core", - "futures-sink", -] - -[[package]] -name = "futures-core" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" - -[[package]] -name = "futures-executor" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" -dependencies = [ - "futures-core", - "futures-task", - "futures-util", -] - -[[package]] -name = "futures-io" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" - -[[package]] -name = "futures-macro" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "futures-sink" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" - -[[package]] -name = "futures-task" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" - -[[package]] -name = "futures-util" -version = "0.3.30" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" -dependencies = [ - "futures-channel", - "futures-core", - "futures-io", - "futures-macro", - "futures-sink", - "futures-task", - "memchr", - "pin-project-lite", - "pin-utils", - "slab", -] - -[[package]] -name = "intl-memoizer" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe22e020fce238ae18a6d5d8c502ee76a52a6e880d99477657e6acc30ec57bda" -dependencies = [ - "type-map", - "unic-langid", -] - -[[package]] -name = "intl_pluralrules" -version = "7.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "078ea7b7c29a2b4df841a7f6ac8775ff6074020c6776d48491ce2268e068f972" -dependencies = [ - "unic-langid", -] - [[package]] name = "itoa" version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "once_cell" -version = "1.19.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" - -[[package]] -name = "pin-cell" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e1f4c4ebd3c5f82080164b7d9cc8e505cd9536fda8c750b779daceb4b7180a7b" - -[[package]] -name = "pin-project-lite" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "proc-macro-hack" -version = "0.5.20+deprecated" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc375e1527247fe1a97d8b7156678dfe7c1af2fc075c9a4db3690ecd2a148068" - [[package]] name = "proc-macro2" version = "1.0.86" @@ -288,33 +26,12 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "rustc-hash" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" - [[package]] name = "ryu" version = "1.0.18" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f" -[[package]] -name = "self_cell" -version = "0.10.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14e4d63b804dc0c7ec4a1e52bcb63f02c7ac94476755aa579edac21e01f915d" -dependencies = [ - "self_cell 1.0.4", -] - -[[package]] -name = "self_cell" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a" - [[package]] name = "serde" version = "1.0.204" @@ -346,27 +63,6 @@ dependencies = [ "serde", ] -[[package]] -name = "slab" -version = "0.4.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67" -dependencies = [ - "autocfg", -] - -[[package]] -name = "smallvec" -version = "1.13.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" - -[[package]] -name = "stable_deref_trait" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" - [[package]] name = "syn" version = "2.0.69" @@ -378,87 +74,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "thiserror" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.61" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "tinystr" -version = "0.7.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f" -dependencies = [ - "displaydoc", -] - -[[package]] -name = "type-map" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f" -dependencies = [ - "rustc-hash", -] - -[[package]] -name = "unic-langid" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23dd9d1e72a73b25e07123a80776aae3e7b0ec461ef94f9151eed6ec88005a44" -dependencies = [ - "unic-langid-impl", - "unic-langid-macros", -] - -[[package]] -name = "unic-langid-impl" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0a5422c1f65949306c99240b81de9f3f15929f5a8bfe05bb44b034cc8bf593e5" -dependencies = [ - "tinystr", -] - -[[package]] -name = "unic-langid-macros" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0da1cd2c042d3c7569a1008806b02039e7a4a2bdf8f8e96bd3c792434a0e275e" -dependencies = [ - "proc-macro-hack", - "tinystr", - "unic-langid-impl", - "unic-langid-macros-impl", -] - -[[package]] -name = "unic-langid-macros-impl" -version = "0.9.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ed7f4237ba393424195053097c1516bd4590dc82b84f2f97c5c69e12704555b" -dependencies = [ - "proc-macro-hack", - "quote", - "syn", - "unic-langid-impl", -] - [[package]] name = "unicode-ident" version = "1.0.12" @@ -469,9 +84,6 @@ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" name = "yu" version = "0.1.0" dependencies = [ - "fluent", - "fluent-resmgr", "serde", "serde_json", - "unic-langid", ] diff --git a/Cargo.toml b/Cargo.toml index fd5dee5..94d33e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,8 +4,5 @@ version = "0.1.0" edition = "2021" [dependencies] -fluent = "0.16.1" -fluent-resmgr = "0.0.7" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" -unic-langid = { version = "0.9.5", features = ["macros"] } diff --git a/i18n/en-US/text.ftl b/i18n/en-US/text.ftl deleted file mode 100644 index 64d3cc3..0000000 --- a/i18n/en-US/text.ftl +++ /dev/null @@ -1,18 +0,0 @@ -unknown = Unknown -command = Command -usage = Usage -install = Install -uninstall = Uninstall -upgrade = Upgrade -list = List -search = Search -help = Help -version = Version - -unknown-command = Unknown command -unknown-package = Unknown package -unknown-package-manager = Unknown package manager - -usage-install = Install a package: yu install -usage-uninstall = Uninstall a package: yu uninstall -usage-upgrade = upgrade all packages: yu upgrade diff --git a/i18n/zh-TW/text.ftl b/i18n/zh-TW/text.ftl deleted file mode 100644 index 47c0802..0000000 --- a/i18n/zh-TW/text.ftl +++ /dev/null @@ -1,18 +0,0 @@ -unknown = 未知 -command = 命令 -usage = 使用方法 -install = 安裝 -uninstall = 卸載 -upgrade = 更新 -list = 列出 -search = 搜尋 -help = 幫助 -version = 版本 - -unknown-command = 未知的命令 -unknown-package = 未知的軟體包 -unknown-package-manager = 未知的軟體包管理器 - -usage-install = 安裝一個軟體包:yu install -usage-uninstall = 卸載一個軟體包:yu uninstall -usage-upgrade = 更新所有軟體包:yu upgrade diff --git a/src/language.rs b/src/language.rs deleted file mode 100644 index 4ce576d..0000000 --- a/src/language.rs +++ /dev/null @@ -1,17 +0,0 @@ -use fluent::FluentResource; -use fluent::FluentBundle; - -use unic_langid::LanguageIdentifier; - -pub fn load_resource(langid: &LanguageIdentifier, file: &str) -> FluentResource { - println!("Loading resource for language: {:?}", langid); - FluentResource::try_new(file.to_string()).expect("Failed to parse FluentResource") -} - -pub fn print_message>(bundle: FluentBundle, message: &str) { - let msg = bundle.get_message(message).expect("Message doesn't exist."); - let pattern = msg.value().expect("Message has no value."); - let mut errors = vec![]; - let value = bundle.format_pattern(pattern, None, &mut errors); - print!("{}", value); -} diff --git a/src/main.rs b/src/main.rs index 67ffbac..fd335cd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,19 +1,9 @@ use std::process::{Stdio}; -use fluent::FluentBundle; -use unic_langid::langid; - mod env; mod syntax; -mod language; fn main() { - let langid_zh_tw = langid!("zh-TW"); - let ftl_content = include_str!("../i18n/zh-TW/text.ftl"); - let resource = language::load_resource(&langid_zh_tw, ftl_content); - let mut bundle = FluentBundle::new(vec![langid_zh_tw]); - bundle.add_resource(resource).expect("Failed to add resource"); - let args: Vec = std::env::args().collect(); let package_manager = env::detect_package_manager(); if args.len() < 2 { @@ -21,17 +11,14 @@ fn main() { return; } - // check second parameter match args[1].as_str() { "install" => install(package_manager.clone(), args[2].clone()), "uninstall" => uninstall(package_manager.clone(), args[2].clone()), "upgrade" => upgrade(package_manager.clone()), _ => { - language::print_message(bundle, "unknown-command"); - print!(": {}", args[1]); + println!("Unknown command: {}", args[1]); } } - 0; } fn install(manager: String, package: String) {