mirror of
https://github.com/saicaca/fuwari.git
synced 2026-01-11 23:02:53 +01:00
refactor: code cleanup
This commit is contained in:
@@ -20,7 +20,7 @@ enum I18nKey {
|
||||
postCount = 'postCount',
|
||||
postsCount = 'postsCount',
|
||||
|
||||
primaryColor = 'primaryColor',
|
||||
themeColor = 'themeColor',
|
||||
|
||||
more = 'more',
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
|
||||
@@ -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]: 'もっと',
|
||||
|
||||
|
||||
@@ -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]: '更多',
|
||||
|
||||
|
||||
@@ -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]: '更多',
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user