aboutsummaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-01-20 23:10:52 -0800
committerFuwn <[email protected]>2024-01-20 23:10:52 -0800
commitd5ce12edb3822ae0f354a7a77f33f43fa16b205d (patch)
treeefe175362887f0b0bf4021ec4abe20db81449ae5 /src/lib
parentfeat(locale): settings framework localisation (diff)
downloaddue.moe-d5ce12edb3822ae0f354a7a77f33f43fa16b205d.tar.xz
due.moe-d5ce12edb3822ae0f354a7a77f33f43fa16b205d.zip
refactor(locale): typed locales
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/Locale/en.json68
-rw-r--r--src/lib/Locale/english.ts72
-rw-r--r--src/lib/Locale/ja.json68
-rw-r--r--src/lib/Locale/japanese.ts72
-rw-r--r--src/lib/Locale/layout.ts74
5 files changed, 218 insertions, 136 deletions
diff --git a/src/lib/Locale/en.json b/src/lib/Locale/en.json
deleted file mode 100644
index c9508c8d..00000000
--- a/src/lib/Locale/en.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "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"
- },
- "settings": {
- "tooltips": {
- "author": "Author of due.moe"
- },
- "rss_feeds": {
- "title": "RSS Feeds",
- "buttons": {
- "copy_to_clipboard": "Copy to clipboard"
- },
- "tooltips": {
- "rss": "Web feed data format"
- }
- },
- "display": {
- "title": "Display",
- "categories": {
- "media": "Media",
- "date_and_time": "Date & Time",
- "motion_and_accessibility": "Motion & Accessibility",
- "collapse_panels_by_default": "Collapse panels by default",
- "hide_panels": "Hide panels",
- "include_additional_media": "Include additional media"
- },
- "tooltips": {
- "beta": "Beta"
- }
- },
- "debug": {
- "title": "Debug",
- "tooltips": {
- "version": "Current due.moe version hash"
- }
- },
- "calculation": {
- "title": "Calculation"
- },
- "cache": {
- "title": "Cache"
- },
- "attributions": {
- "title": "Attributions"
- },
- "media": {
- "anime": "Anime",
- "manga": "Manga",
- "upcoming_anime": "Upcoming anime",
- "paused_media": "Paused media",
- "unresolved_media": "Unresolved media",
- "planned_anime": "Planned anime"
- },
- "languages": {
- "english": "English",
- "japanese": "Japanese"
- }
- }
-}
diff --git a/src/lib/Locale/english.ts b/src/lib/Locale/english.ts
new file mode 100644
index 00000000..2216e34d
--- /dev/null
+++ b/src/lib/Locale/english.ts
@@ -0,0 +1,72 @@
+import type { Locale } from './layout';
+
+const English: Locale = {
+ 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'
+ },
+ settings: {
+ tooltips: {
+ author: 'Author of due.moe'
+ },
+ rss_feeds: {
+ title: 'RSS Feeds',
+ buttons: {
+ copy_to_clipboard: 'Copy to clipboard'
+ },
+ tooltips: {
+ rss: 'Web feed data format'
+ }
+ },
+ display: {
+ title: 'Display',
+ categories: {
+ media: 'Media',
+ date_and_time: 'Date & Time',
+ motion_and_accessibility: 'Motion & Accessibility',
+ collapse_panels_by_default: 'Collapse panels by default',
+ hide_panels: 'Hide panels',
+ include_additional_media: 'Include additional media'
+ },
+ tooltips: {
+ beta: 'Beta'
+ }
+ },
+ debug: {
+ title: 'Debug',
+ tooltips: {
+ version: 'Current due.moe version hash'
+ }
+ },
+ calculation: {
+ title: 'Calculation'
+ },
+ cache: {
+ title: 'Cache'
+ },
+ attributions: {
+ title: 'Attributions'
+ },
+ media: {
+ anime: 'Anime',
+ manga: 'Manga',
+ upcoming_anime: 'Upcoming anime',
+ paused_media: 'Paused media',
+ unresolved_media: 'Unresolved media',
+ planned_anime: 'Planned anime'
+ },
+ languages: {
+ english: 'English',
+ japanese: 'Japanese'
+ }
+ }
+};
+
+export default English;
diff --git a/src/lib/Locale/ja.json b/src/lib/Locale/ja.json
deleted file mode 100644
index 359aeec1..00000000
--- a/src/lib/Locale/ja.json
+++ /dev/null
@@ -1,68 +0,0 @@
-{
- "navigation": {
- "home": "ホーム",
- "completed": "完成メディア",
- "subtitle_schedule": "字幕スケジュール",
- "new_releases": "新発売",
- "tools": "ツール",
- "settings": "設定",
- "profile": "プロフィール",
- "log_in": "AniListでログイン",
- "log_out": "ログアウト"
- },
- "settings": {
- "tooltips": {
- "author": "due.moeの作者"
- },
- "rss_feeds": {
- "title": "RSSフィード",
- "buttons": {
- "copy_to_clipboard": "クリップボードにコピー"
- },
- "tooltips": {
- "rss": "ウェブフィードデータフォーマット"
- }
- },
- "display": {
- "title": "表示",
- "categories": {
- "date_and_time": "日付と時刻",
- "media": "メディア",
- "motion_and_accessibility": "モーションとアクセシビリティ",
- "collapse_panels_by_default": "メディアパネルをデフォルトで折りたたむ",
- "hide_panels": "メディアパネルを隠す",
- "include_additional_media": "デフォルトでは含まれていないメディアグループを追加する"
- },
- "tooltips": {
- "beta": "ベータ"
- }
- },
- "debug": {
- "title": "デバッグ",
- "tooltips": {
- "version": "現在のdue.moeのバージョンハッシュ"
- }
- },
- "calculation": {
- "title": "計算"
- },
- "cache": {
- "title": "キャッシュ"
- },
- "attributions": {
- "title": "帰属"
- },
- "media": {
- "anime": "アニメ",
- "manga": "マンガ",
- "upcoming_anime": "近日放送予定のアニメ",
- "paused_media": "視聴を一時停止したメディア",
- "unresolved_media": "未解決のメディア",
- "planned_anime": "視聴予定アニメ"
- },
- "languages": {
- "english": "英語",
- "japanese": "日本語"
- }
- }
-}
diff --git a/src/lib/Locale/japanese.ts b/src/lib/Locale/japanese.ts
new file mode 100644
index 00000000..2756d78a
--- /dev/null
+++ b/src/lib/Locale/japanese.ts
@@ -0,0 +1,72 @@
+import type { Locale } from './layout';
+
+const Japanese: Locale = {
+ navigation: {
+ home: 'ホーム',
+ completed: '完成メディア',
+ subtitle_schedule: '字幕スケジュール',
+ new_releases: '新発売',
+ tools: 'ツール',
+ settings: '設定',
+ profile: 'プロフィール',
+ log_in: 'AniListでログイン',
+ log_out: 'ログアウト'
+ },
+ settings: {
+ tooltips: {
+ author: 'due.moeの作者'
+ },
+ rss_feeds: {
+ title: 'RSSフィード',
+ buttons: {
+ copy_to_clipboard: 'クリップボードにコピー'
+ },
+ tooltips: {
+ rss: 'ウェブフィードデータフォーマット'
+ }
+ },
+ display: {
+ title: '表示',
+ categories: {
+ date_and_time: '日付と時刻',
+ media: 'メディア',
+ motion_and_accessibility: 'モーションとアクセシビリティ',
+ collapse_panels_by_default: 'メディアパネルをデフォルトで折りたたむ',
+ hide_panels: 'メディアパネルを隠す',
+ include_additional_media: 'デフォルトでは含まれていないメディアグループを追加する'
+ },
+ tooltips: {
+ beta: 'ベータ'
+ }
+ },
+ debug: {
+ title: 'デバッグ',
+ tooltips: {
+ version: '現在のdue.moeのバージョンハッシュ'
+ }
+ },
+ calculation: {
+ title: '計算'
+ },
+ cache: {
+ title: 'キャッシュ'
+ },
+ attributions: {
+ title: '帰属'
+ },
+ media: {
+ anime: 'アニメ',
+ manga: 'マンガ',
+ upcoming_anime: '近日放送予定のアニメ',
+ paused_media: '視聴を一時停止したメディア',
+ unresolved_media: '未解決のメディア',
+ planned_anime: '視聴予定アニメ'
+ },
+ languages: {
+ english: '英語',
+ japanese: '日本語'
+ }
+ }
+};
+
+export default Japanese;
diff --git a/src/lib/Locale/layout.ts b/src/lib/Locale/layout.ts
new file mode 100644
index 00000000..45c58a33
--- /dev/null
+++ b/src/lib/Locale/layout.ts
@@ -0,0 +1,74 @@
+type LocaleValue = string | LocaleValue[] | { [key: string]: LocaleValue };
+
+export interface LocaleDictionary {
+ [key: string]: LocaleDictionary | string | Array<string | LocaleDictionary> | null;
+}
+
+export interface Locale {
+ navigation: {
+ home: LocaleValue;
+ completed: LocaleValue;
+ subtitle_schedule: LocaleValue;
+ new_releases: LocaleValue;
+ tools: LocaleValue;
+ settings: LocaleValue;
+ profile: LocaleValue;
+ log_in: LocaleValue;
+ log_out: LocaleValue;
+ };
+ settings: {
+ tooltips: {
+ author: LocaleValue;
+ };
+ rss_feeds: {
+ title: LocaleValue;
+ buttons: {
+ copy_to_clipboard: LocaleValue;
+ };
+ tooltips: {
+ rss: LocaleValue;
+ };
+ };
+ display: {
+ title: LocaleValue;
+ categories: {
+ media: LocaleValue;
+ date_and_time: LocaleValue;
+ motion_and_accessibility: LocaleValue;
+ collapse_panels_by_default: LocaleValue;
+ hide_panels: LocaleValue;
+ include_additional_media: LocaleValue;
+ };
+ tooltips: {
+ beta: LocaleValue;
+ };
+ };
+ debug: {
+ title: LocaleValue;
+ tooltips: {
+ version: LocaleValue;
+ };
+ };
+ calculation: {
+ title: LocaleValue;
+ };
+ cache: {
+ title: LocaleValue;
+ };
+ attributions: {
+ title: LocaleValue;
+ };
+ media: {
+ anime: LocaleValue;
+ manga: LocaleValue;
+ upcoming_anime: LocaleValue;
+ paused_media: LocaleValue;
+ unresolved_media: LocaleValue;
+ planned_anime: LocaleValue;
+ };
+ languages: {
+ english: LocaleValue;
+ japanese: LocaleValue;
+ };
+ };
+}