refactor: code cleanup

This commit is contained in:
saicaca
2024-02-18 18:13:43 +08:00
committed by saica.go
parent 3cd21c2da9
commit af29b9160f
51 changed files with 872 additions and 2264 deletions

View File

@@ -20,7 +20,7 @@ enum I18nKey {
postCount = 'postCount',
postsCount = 'postsCount',
primaryColor = 'primaryColor',
themeColor = 'themeColor',
more = 'more',

View File

@@ -1,5 +1,5 @@
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
import Key from '../i18nKey'
import type { Translation } from '../translation'
export const en: Translation = {
[Key.home]: 'Home',
@@ -23,7 +23,7 @@ export const en: Translation = {
[Key.postCount]: 'post',
[Key.postsCount]: 'posts',
[Key.primaryColor]: 'Primary Color',
[Key.themeColor]: 'Theme Color',
[Key.more]: 'More',

View File

@@ -1,5 +1,5 @@
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
import Key from '../i18nKey'
import type { Translation } from '../translation'
export const ja: Translation = {
[Key.home]: 'Home',
@@ -23,7 +23,7 @@ export const ja: Translation = {
[Key.postCount]: '件の投稿',
[Key.postsCount]: '件の投稿',
[Key.primaryColor]: '原色',
[Key.themeColor]: 'テーマカラー',
[Key.more]: 'もっと',

View File

@@ -1,5 +1,5 @@
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
import Key from '../i18nKey'
import type { Translation } from '../translation'
export const zh_CN: Translation = {
[Key.home]: '主页',
@@ -23,7 +23,7 @@ export const zh_CN: Translation = {
[Key.postCount]: '篇文章',
[Key.postsCount]: '篇文章',
[Key.primaryColor]: '主题色',
[Key.themeColor]: '主题色',
[Key.more]: '更多',

View File

@@ -1,5 +1,5 @@
import Key from '../i18nKey.ts'
import type { Translation } from '../translation.ts'
import Key from '../i18nKey'
import type { Translation } from '../translation'
export const zh_TW: Translation = {
[Key.home]: '首頁',
@@ -23,7 +23,7 @@ export const zh_TW: Translation = {
[Key.postCount]: '篇文章',
[Key.postsCount]: '篇文章',
[Key.primaryColor]: '主題色',
[Key.themeColor]: '主題色',
[Key.more]: '更多',

View File

@@ -1,9 +1,9 @@
import { siteConfig } from '../config.ts'
import type I18nKey from './i18nKey.ts'
import { en } from './languages/en.ts'
import { ja } from './languages/ja.ts'
import { zh_CN } from './languages/zh_CN.ts'
import { zh_TW } from './languages/zh_TW.ts'
import { siteConfig } from '../config'
import type I18nKey from './i18nKey'
import { en } from './languages/en'
import { ja } from './languages/ja'
import { zh_CN } from './languages/zh_CN'
import { zh_TW } from './languages/zh_TW'
export type Translation = {
[K in I18nKey]: string
@@ -23,8 +23,7 @@ const map: { [key: string]: Translation } = {
}
export function getTranslation(lang: string): Translation {
lang = lang.toLowerCase()
return map[lang] || defaultTranslation
return map[lang.toLowerCase()] || defaultTranslation
}
export function i18n(key: I18nKey): string {