-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
118 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSAppleEventsUsageDescription</key> | ||
<string>Clippy needs access to send keyboard events</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
|
@@ -28,7 +28,7 @@ | |
}, | ||
"bundle": { | ||
"active": true, | ||
"targets": "all", | ||
"targets": ["app", "deb", "rpm", "dmg", "appimage", "nsis"], | ||
"icon": ["icons/32x32.png", "icons/128x128.png", "icons/[email protected]", "icons/icon.icns", "icons/icon.ico"], | ||
"linux": { | ||
"deb": { | ||
|
@@ -37,6 +37,29 @@ | |
"rpm": { | ||
"depends": ["xdotool"] | ||
} | ||
}, | ||
"macOS": { | ||
"minimumSystemVersion": "10.13", | ||
"exceptionDomain": "", | ||
"frameworks": [] | ||
}, | ||
"windows": { | ||
"nsis": { | ||
"languages": [ | ||
"English", | ||
"SimpChinese", | ||
"Spanish", | ||
"French", | ||
"Arabic", | ||
"Russian", | ||
"Japanese", | ||
"German", | ||
"Korean", | ||
"Turkish", | ||
"Italian", | ||
"Dutch" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters