feat: add Spanish i18n (#157)

* Create es.ts

Added Spanish translation for site content and interface elements.

* Update translation.ts

Added Spanish (es) translation support to the language configuration.
This commit is contained in:
Marcos 2024-08-27 18:22:43 +02:00 committed by GitHub
parent e9c8930559
commit 075cb8e10a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 42 additions and 2 deletions

38
src/i18n/languages/es.ts Normal file
View File

@ -0,0 +1,38 @@
import Key from '../i18nKey'
import type { Translation } from '../translation'
export const es: Translation = {
[Key.home]: 'Inicio',
[Key.about]: 'Sobre mí',
[Key.archive]: 'Archivo',
[Key.search]: 'Buscar',
[Key.tags]: 'Etiquetas',
[Key.categories]: 'Categorías',
[Key.recentPosts]: 'Publicaciones recientes',
[Key.comments]: 'Comentarios',
[Key.untitled]: 'Sin título',
[Key.uncategorized]: 'Sin categoría',
[Key.noTags]: 'Sin etiquetas',
[Key.wordCount]: 'palabra',
[Key.wordsCount]: 'palabras',
[Key.minuteCount]: 'minuto',
[Key.minutesCount]: 'minutos',
[Key.postCount]: 'publicación',
[Key.postsCount]: 'publicaciones',
[Key.themeColor]: 'Color del tema',
[Key.lightMode]: 'Claro',
[Key.darkMode]: 'Oscuro',
[Key.systemMode]: 'Sistema',
[Key.more]: 'Más',
[Key.author]: 'Autor',
[Key.publishedAt]: 'Publicado el',
[Key.license]: 'Licencia',
}

View File

@ -1,10 +1,11 @@
import { siteConfig } from '../config' import { siteConfig } from '../config'
import type I18nKey from './i18nKey' import type I18nKey from './i18nKey'
import { en } from './languages/en' import { en } from './languages/en'
import { es } from './languages/es'
import { ja } from './languages/ja' import { ja } from './languages/ja'
import { ko } from './languages/ko'
import { zh_CN } from './languages/zh_CN' import { zh_CN } from './languages/zh_CN'
import { zh_TW } from './languages/zh_TW' import { zh_TW } from './languages/zh_TW'
import { ko } from './languages/ko'
export type Translation = { export type Translation = {
[K in I18nKey]: string [K in I18nKey]: string
@ -13,6 +14,7 @@ export type Translation = {
const defaultTranslation = en const defaultTranslation = en
const map: { [key: string]: Translation } = { const map: { [key: string]: Translation } = {
es: es,
en: en, en: en,
en_us: en, en_us: en,
en_gb: en, en_gb: en,
@ -32,4 +34,4 @@ export function getTranslation(lang: string): Translation {
export function i18n(key: I18nKey): string { export function i18n(key: I18nKey): string {
const lang = siteConfig.lang || 'en' const lang = siteConfig.lang || 'en'
return getTranslation(lang)[key] return getTranslation(lang)[key]
} }