From 6ad0e36f4d46062db497cf06c882d1423925c998 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sat, 20 Jan 2024 02:00:45 -0800 Subject: feat: localisation --- bun.lockb | Bin 151831 -> 169499 bytes package.json | 1 + src/lib/Settings/Categories/Display.svelte | 5 ++++ src/lib/Styles/input.css | 8 +++++++ src/lib/locale/en.json | 13 +++++++++++ src/lib/locale/ja.json | 13 +++++++++++ src/routes/+layout.svelte | 36 +++++++++++++++++++++-------- src/stores/settings.ts | 2 ++ 8 files changed, 69 insertions(+), 9 deletions(-) create mode 100644 src/lib/locale/en.json create mode 100644 src/lib/locale/ja.json diff --git a/bun.lockb b/bun.lockb index acee8237..a79f81de 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index d314c257..fa05a0a9 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,7 @@ "modern-screenshot": "^4.4.33", "rss-parser": "^3.13.0", "string-similarity": "^4.0.4", + "svelte-i18n": "^4.0.0", "svelte-notifications": "^0.9.98", "wanakana": "^5.3.1" } diff --git a/src/lib/Settings/Categories/Display.svelte b/src/lib/Settings/Categories/Display.svelte index 553204ce..ee53dd9e 100644 --- a/src/lib/Settings/Categories/Display.svelte +++ b/src/lib/Settings/Categories/Display.svelte @@ -72,6 +72,11 @@ /> + +Interface language

diff --git a/src/lib/Styles/input.css b/src/lib/Styles/input.css index 0f2b810f..381f2ebe 100644 --- a/src/lib/Styles/input.css +++ b/src/lib/Styles/input.css @@ -113,6 +113,14 @@ button:disabled:active { transform: scale(0.75); } +.unclickable-button { + transform: scale(1); +} + +.unclickable-button:active { + transform: scale(1) !important; +} + .smaller-button { background-color: var(--base0C); transform: scale(0.75); diff --git a/src/lib/locale/en.json b/src/lib/locale/en.json new file mode 100644 index 00000000..f968a7d6 --- /dev/null +++ b/src/lib/locale/en.json @@ -0,0 +1,13 @@ +{ + "navigation": { + "home": "Home", + "completed": "Completed", + "subtitle_schedule": "Subtitle Schedule", + "new_releases": "New Releases", + "tools": "Tools", + "settings": "Settings", + "profile": "Profile", + "log_in": "Log in with AniList", + "log_out": "Log out" + } +} diff --git a/src/lib/locale/ja.json b/src/lib/locale/ja.json new file mode 100644 index 00000000..6c6afb38 --- /dev/null +++ b/src/lib/locale/ja.json @@ -0,0 +1,13 @@ +{ + "navigation": { + "home": "ホーム", + "completed": "完成メディア", + "subtitle_schedule": "字幕スケジュール", + "new_releases": "新発売", + "tools": "ツール", + "settings": "設定", + "profile": "プロフィール", + "log_in": "AniListでログイン", + "log_out": "ログアウト" + } +} diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 1118ebcf..bafc9272 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -13,9 +13,23 @@ import Notification from '$lib/Notification/Notification.svelte'; import Root from '$lib/Home/Root.svelte'; import root from '$lib/Utility/root'; + import { addMessages, init, _ } from 'svelte-i18n'; + import en from '$lib/locale/en.json'; + import ja from '$lib/locale/ja.json'; export let data; + addMessages('en', en); + addMessages('ja', ja); + + $: { + // import(`../lib/locale/${$settings.displayLanguage}.json`).then((module) => { + // addMessages($settings.displayLanguage, module.default); + // }); + + init({ fallbackLocale: 'en', initialLocale: $settings.displayLanguage }); + } + let currentUserIdentity = { name: '', id: -1, @@ -63,19 +77,21 @@