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 e245222
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 103 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
36 changes: 29 additions & 7 deletions src-tauri/Cargo.lock

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

9 changes: 1 addition & 8 deletions 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 Expand Up @@ -64,10 +64,3 @@ color-backtrace = "0"
# lto = true
# opt-level = "s"
# strip = true

[package.metadata.generate-rpm.requires]
# "webkit2gtk-4.1" = "*"
# "libappindicator-gtk3" = "*"
# "xdotool" = "*"
# "gtk3" = "*"
# "libxdo" = "*"
8 changes: 8 additions & 0 deletions src-tauri/Info.plist
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>
8 changes: 4 additions & 4 deletions src-tauri/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ path = "src/lib.rs"
[dependencies]
entity = { path = "../entity" }
global-hotkey = "0"
sea-orm = { version = "1" }
serde = { version = "1" }
serde_json = { version = "1" }
tl = "0"
sea-orm = "1"
serde = "1"
serde_json = "1"
tl = "0"
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
}
}
2 changes: 1 addition & 1 deletion src-tauri/migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ entity = { path = "../entity" }
common = { path = "../common" }
async-std = { version = "1", features = ["attributes", "tokio1"] }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1" }
serde_json = "1"

[dependencies.sea-orm-migration]
version = "1"
Expand Down
27 changes: 25 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/[email protected]", "icons/icon.icns", "icons/icon.ico"],
"linux": {
"deb": {
Expand All @@ -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"
]
}
}
}
}
5 changes: 2 additions & 3 deletions src/components/pages/app/clipboard/clipboards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { BaseClipboard } from "./base-clipboard";

export const Clipboards: Component = () => {
const { t } = useLanguage();
const { globalHotkeyEvent, hotkeys } = HotkeyStore;
const [scrollToTop, setScrollToTop] = createSignal(false);

const onScroll = async () => {
Expand Down Expand Up @@ -58,9 +57,9 @@ export const Clipboards: Component = () => {
>
<div class="relative flex items-center justify-center py-1">
<FiArrowUp class="text-xl !text-white dark:!text-white" />
<Show when={globalHotkeyEvent()}>
<Show when={HotkeyStore.globalHotkeyEvent()}>
<div class="absolute left-0 top-0 -ml-3 -mt-3 rounded-sm bg-zinc-600 px-1 text-[12px] font-semibold">
{hotkeys().find((key) => key.event === HotkeyEvent.ScrollToTop)?.key}
{HotkeyStore.hotkeys().find((key) => key.event === HotkeyEvent.ScrollToTop)?.key}
</div>
</Show>
</div>
Expand Down
10 changes: 5 additions & 5 deletions src/components/utils/dark-mode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { Toggle } from "../elements/toggle";
interface DarkModeProps {}

export const DarkMode: Component<DarkModeProps> = ({}) => {
const { settings, updateSettings } = SettingsStore;
const { darkMode } = AppStore;

createEffect(darkMode);
createEffect(AppStore.darkMode);

return (
<Toggle checked={settings()?.dark_mode} onChange={(dark_mode) => updateSettings({ ...settings()!, dark_mode })} />
<Toggle
checked={SettingsStore.settings()?.dark_mode}
onChange={(dark_mode) => SettingsStore.updateSettings({ ...SettingsStore.settings()!, dark_mode })}
/>
);
};
1 change: 0 additions & 1 deletion src/store/settings-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Settings, SettingsTab } from "../types";
import { WebWindow } from "../types/enums";
import { InvokeCommand } from "../types/tauri-invoke";
import { SETTINGS_TAB, SettingsTabName } from "../utils/constants";
import dayjs from "../utils/dayjs";

function createSettingsStore() {
const [tabs, setTabs] = createSignal<SettingsTab[]>([
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DictionaryKey } from "../lib/i18n";
import type { DictionaryKey } from "../lib/i18n";
import { HotkeyEvent } from "../types/enums";

export const LANGUAGE_KEY = "lang";
Expand Down
4 changes: 0 additions & 4 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ export function formatBytes(bytes: number = 0, decimals = 2) {

return `${parseFloat((bytes / Math.pow(k, i)).toFixed(dm))} ${sizes[i]}`;
}

export async function sleep(milis: number) {
return new Promise((resolve) => setTimeout(resolve, milis));
}

0 comments on commit e245222

Please sign in to comment.