From a82a16baeb82cb555f6f98b92293813aef4a7adb Mon Sep 17 00:00:00 2001 From: 0-don <70039285+0-don@users.noreply.github.com> Date: Thu, 26 Dec 2024 14:49:36 +0100 Subject: [PATCH] update Italian translations --- package.json | 2 +- src-tauri/Cargo.lock | 4 +- src-tauri/Cargo.toml | 2 +- src-tauri/common/src/language.rs | 107 ++++++++++++------------------- src-tauri/tauri.conf.json | 22 ++++++- 5 files changed, 65 insertions(+), 72 deletions(-) diff --git a/package.json b/package.json index 053638cd..2e3288a3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "clippy", - "version": "1.3.0", + "version": "1.3.1", "description": "Clipboard Manager built with Rust & Typescript", "license": "MIT", "type": "module", diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index c4220396..2090dc3d 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -929,9 +929,9 @@ dependencies = [ [[package]] name = "clippy" -version = "1.3.0" +version = "1.3.1" dependencies = [ - "base64 0.22.1", + "base64 0.21.7", "chrono", "color-backtrace", "common", diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 60216432..cb9cb04d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "clippy" -version = "1.3.0" +version = "1.3.1" description = "Clipboard Manager built with Rust & Typescript" authors = ["0-don"] license = "MIT" diff --git a/src-tauri/common/src/language.rs b/src-tauri/common/src/language.rs index bbd5ee76..a46c2381 100644 --- a/src-tauri/common/src/language.rs +++ b/src-tauri/common/src/language.rs @@ -1,82 +1,57 @@ use crate::types::enums::Language; pub use sea_orm::Iden; +impl Language { + fn from_iso_code(lang_code: &str) -> Self { + match &*lang_code { + code if code == Language::Mandarin.to_string() => Language::Mandarin, + code if code == Language::Hindi.to_string() => Language::Hindi, + code if code == Language::Spanish.to_string() => Language::Spanish, + code if code == Language::French.to_string() => Language::French, + code if code == Language::Arabic.to_string() => Language::Arabic, + code if code == Language::Bengali.to_string() => Language::Bengali, + code if code == Language::Portuguese.to_string() => Language::Portuguese, + code if code == Language::Russian.to_string() => Language::Russian, + code if code == Language::Urdu.to_string() => Language::Urdu, + code if code == Language::Japanese.to_string() => Language::Japanese, + code if code == Language::German.to_string() => Language::German, + code if code == Language::Korean.to_string() => Language::Korean, + code if code == Language::Vietnamese.to_string() => Language::Vietnamese, + code if code == Language::Turkish.to_string() => Language::Turkish, + code if code == Language::Italian.to_string() => Language::Italian, + code if code == Language::Thai.to_string() => Language::Thai, + code if code == Language::Polish.to_string() => Language::Polish, + code if code == Language::Dutch.to_string() => Language::Dutch, + _ => Language::English, + } + } +} + pub fn get_system_language() -> Language { if cfg!(target_os = "linux") { - if let Ok(lang) = std::env::var("LANG") { - let lang = lang.to_lowercase(); - match &lang[..2] { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } + std::env::var("LANG") + .map(|lang| Language::from_iso_code(&lang.to_lowercase()[..2])) + .unwrap_or(Language::English) } else if cfg!(target_os = "windows") { - let output = std::process::Command::new("powershell") + std::process::Command::new("powershell") .arg("-Command") .arg("(Get-Culture).TwoLetterISOLanguageName") - .output(); - - if let Ok(result) = output { - if let Ok(lang) = std::str::from_utf8(&result.stdout) { - let lang = lang.trim().to_lowercase(); - match lang.as_str() { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } - } else { - Language::English - } + .output() + .ok() + .and_then(|result| String::from_utf8(result.stdout).ok()) + .map(|lang| Language::from_iso_code(lang.trim())) + .unwrap_or(Language::English) } else if cfg!(target_os = "macos") { - let output = std::process::Command::new("defaults") + std::process::Command::new("defaults") .arg("read") .arg(".GlobalPreferences") .arg("AppleLanguages") - .output(); - - if let Ok(result) = output { - if let Ok(lang) = std::str::from_utf8(&result.stdout) { - let lang = lang.to_lowercase(); - match &lang[..2] { - s if s == Language::Mandarin.to_string() => Language::Mandarin, - s if s == Language::Hindi.to_string() => Language::Hindi, - s if s == Language::Spanish.to_string() => Language::Spanish, - s if s == Language::French.to_string() => Language::French, - s if s == Language::Arabic.to_string() => Language::Arabic, - s if s == Language::Bengali.to_string() => Language::Bengali, - s if s == Language::Portuguese.to_string() => Language::Portuguese, - s if s == Language::Russian.to_string() => Language::Russian, - s if s == Language::Urdu.to_string() => Language::Urdu, - _ => Language::English, - } - } else { - Language::English - } - } else { - Language::English - } + .output() + .ok() + .and_then(|result| String::from_utf8(result.stdout).ok()) + .map(|lang| Language::from_iso_code(&lang.to_lowercase()[..2])) + .unwrap_or(Language::English) } else { - println!("{} default English", std::env::consts::OS); Language::English } } diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index f7d1d011..6677a1a1 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -1,7 +1,7 @@ { "$schema": "https://schema.tauri.app/config/2", "productName": "clippy", - "version": "1.3.0", + "version": "1.3.1", "identifier": "clippy", "build": { "beforeDevCommand": "npm run dev", @@ -28,7 +28,7 @@ }, "bundle": { "active": true, - "targets": "all", + "targets": ["app", "deb", "rpm", "dmg", "appimage", "nsis"], "icon": ["icons/32x32.png", "icons/128x128.png", "icons/128x128@2x.png", "icons/icon.icns", "icons/icon.ico"], "linux": { "deb": { @@ -37,6 +37,24 @@ "rpm": { "depends": ["xdotool"] } + }, + "windows": { + "nsis": { + "languages": [ + "English", + "SimpChinese", + "Spanish", + "French", + "Arabic", + "Russian", + "Japanese", + "German", + "Korean", + "Turkish", + "Italian", + "Dutch" + ] + } } } }