Skip to content

Commit

Permalink
update Italian translations
Browse files Browse the repository at this point in the history
  • Loading branch information
0-don committed Dec 26, 2024
1 parent 76fd108 commit a82a16b
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 72 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
107 changes: 41 additions & 66 deletions src-tauri/common/src/language.rs
Original file line number Diff line number Diff line change
@@ -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
}
}
22 changes: 20 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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": {
Expand All @@ -37,6 +37,24 @@
"rpm": {
"depends": ["xdotool"]
}
},
"windows": {
"nsis": {
"languages": [
"English",
"SimpChinese",
"Spanish",
"French",
"Arabic",
"Russian",
"Japanese",
"German",
"Korean",
"Turkish",
"Italian",
"Dutch"
]
}
}
}
}

0 comments on commit a82a16b

Please sign in to comment.