refactor(i18n): change locale files to yaml format, closes #96 (#97)

This commit is contained in:
userquin 2021-03-19 15:32:17 +01:00 committed by GitHub
parent 711d1c845d
commit 23dc1cd483
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 135 additions and 169 deletions

View File

@ -1,6 +1,6 @@
## i18n
This directory is to serve your locale translation files. JSON under this folder would be loaded automatically and register with their filenames as locale code.
This directory is to serve your locale translation files. YAML under this folder would be loaded automatically and register with their filenames as locale code.
Check out [`vue-i18n`](https://github.com/intlify/vue-i18n-next) for more details.

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "About",
"back": "Back",
"go": "GO",
"home": "Home",
"toggle_dark": "Toggle dark mode",
"toggle_langs": "Change languages"
},
"intro": {
"desc": "Opinionated Vite Starter Template",
"dynamic-route": "Demo of dynamic route",
"hi": "Hi, {name}!",
"whats-your-name": "What's your name?"
},
"not-found": "Not found"
}

13
locales/en.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: About
back: Back
go: GO
home: Home
toggle_dark: Toggle dark mode
toggle_langs: Change languages
intro:
desc: Opinionated Vite Starter Template
dynamic-route: Demo of dynamic route
hi: Hi, {name}!
whats-your-name: What's your name?
not-found: Not found

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "Acerca de",
"back": "Atrás",
"go": "Ir",
"home": "Inicio",
"toggle_dark": "Alternar modo oscuro",
"toggle_langs": "Cambiar idiomas"
},
"intro": {
"desc": "Plantilla de Inicio de Vite Dogmática",
"dynamic-route": "Demo de ruta dinámica",
"hi": "¡Hola, {name}!",
"whats-your-name": "¿Cómo te llamas?"
},
"not-found": "No se ha encontrado"
}

13
locales/es.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: Acerca de
back: Atrás
go: Ir
home: Inicio
toggle_dark: Alternar modo oscuro
toggle_langs: Cambiar idiomas
intro:
desc: Plantilla de Inicio de Vite Dogmática
dynamic-route: Demo de ruta dinámica
hi: ¡Hola, {name}!
whats-your-name: ¿Cómo te llamas?
not-found: No se ha encontrado

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "À propos de",
"back": "Retour",
"go": "Essayer",
"home": "Maison",
"toggle_dark": "Basculer en mode sombre",
"toggle_langs": "Changer de langue"
},
"intro": {
"desc": "Example d'application Vite",
"dynamic-route": "Démo de route dynamique",
"hi": "Salut, {name} !",
"whats-your-name": "Comment t'appelles-tu ?"
},
"not-found": "Page non trouvée"
}

13
locales/fr.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: À propos de
back: Retour
go: Essayer
home: Maison
toggle_dark: Basculer en mode sombre
toggle_langs: Changer de langue
intro:
desc: Example d'application Vite
dynamic-route: Démo de route dynamique
hi: Salut, {name}!
whats-your-name: Comment t'appelles-tu?
not-found: Page non trouvée

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "Su di me",
"back": "Indietro",
"go": "Vai",
"home": "Home",
"toggle_dark": "Attiva/disattiva modalità scura",
"toggle_langs": "Cambia lingua"
},
"intro": {
"desc": "Modello per una Applicazione Vite",
"dynamic-route": "Demo di rotta dinamica",
"hi": "Ciao, {name}!",
"whats-your-name": "Come ti chiami?"
},
"not-found": "Non trovato"
}

13
locales/it.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: Su di me
back: Indietro
go: Vai
home: Home
toggle_dark: Attiva/disattiva modalità scura
toggle_langs: Cambia lingua
intro:
desc: Modello per una Applicazione Vite
dynamic-route: Demo di rotta dinamica
hi: Ciao, {name}!
whats-your-name: Come ti chiami?
not-found: Non trovato

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "これは?",
"back": "戻る",
"go": "進む",
"home": "ホーム",
"toggle_dark": "ダークモード切り替え",
"toggle_langs": "言語切り替え"
},
"intro": {
"desc": "固執された Vite スターターテンプレート",
"dynamic-route": "動的ルートのデモ",
"hi": "こんにちは、{name}",
"whats-your-name": "あなたの名前は?"
},
"not-found": "見つかりませんでした"
}

13
locales/ja.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: これは?
back: 戻る
go: 進む
home: ホーム
toggle_dark: ダークモード切り替え
toggle_langs: 言語切り替え
intro:
desc: 固執された Vite スターターテンプレート
dynamic-route: 動的ルートのデモ
hi: こんにちは、{name}!
whats-your-name: あなたの名前は?
not-found: 見つかりませんでした

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "소개",
"back": "뒤로가기",
"go": "이동",
"home": "홈",
"toggle_dark": "다크모드 토글",
"toggle_langs": "언어 변경"
},
"intro": {
"desc": "Vite 애플리케이션 템플릿",
"dynamic-route": "다이나믹 라우트 데모",
"hi": "안녕, {name}!",
"whats-your-name": "이름이 뭐예요?"
},
"not-found": "찾을 수 없습니다"
}

14
locales/ko.yml Normal file
View File

@ -0,0 +1,14 @@
button:
about: 소개
back: 뒤로가기
go: 이동
home:
toggle_dark: 다크모드 토글
toggle_langs: 언어 변경
intro:
desc: Vite 애플리케이션 템플릿
dynamic-route: 다이나믹 라우트 데모
hi: 안녕, {name}!
whats-your-name: 이름이 뭐예요?
not-found: 찾을 수 없습니다

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "Sobre",
"back": "Voltar",
"go": "Ir",
"home": "Início",
"toggle_dark": "Alternar modo escuro",
"toggle_langs": "Mudar de idioma"
},
"intro": {
"desc": "Modelo Opinativo de Partida de Vite",
"dynamic-route": "Demonstração de rota dinâmica",
"hi": "Olá, {name}!",
"whats-your-name": "Qual é o seu nome?"
},
"not-found": "Não encontrado"
}

13
locales/pt-BR.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: Sobre
back: Voltar
go: Ir
home: Início
toggle_dark: Alternar modo escuro
toggle_langs: Mudar de idioma
intro:
desc: Modelo Opinativo de Partida de Vite
dynamic-route: Demonstração de rota dinâmica
hi: Olá, {name}!
whats-your-name: Qual é o seu nome?
not-found: Não encontrado

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "Hakkımda",
"back": "Geri",
"go": "İLERİ",
"home": "Anasayfa",
"toggle_dark": "Karanlık modu değiştir",
"toggle_langs": "Dilleri değiştir"
},
"intro": {
"desc": "Görüşlü Vite Başlangıç Şablonu",
"dynamic-route": "Dinamik rota demosu",
"hi": "Merhaba, {name}!",
"whats-your-name": "Adınız nedir ?"
},
"not-found": "Bulunamadı"
}

13
locales/tr.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: Hakkımda
back: Geri
go: İLERİ
home: Anasayfa
toggle_dark: Karanlık modu değiştir
toggle_langs: Dilleri değiştir
intro:
desc: Görüşlü Vite Başlangıç Şablonu
dynamic-route: Dinamik rota demosu
hi: Merhaba, {name}!
whats-your-name: Adınız nedir?
not-found: Bulunamadı

View File

@ -1,13 +0,0 @@
{
"button": {
"back": "Quay lại",
"go": "Đi"
},
"intro": {
"desc": "Ý kiến cá nhân Vite Template để bắt đầu",
"dynamic-route": "Bản giới thiệu về dynamic route",
"hi": "Hi, {name}!",
"whats-your-name": "Tên bạn là gì?"
},
"not-found": "Không tìm thấy"
}

13
locales/vi.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: Về
back: Quay lại
go: Đi
home: Khởi đầu
toggle_dark: Chuyển đổi chế độ tối
toggle_langs: Thay đổi ngôn ngữ
intro:
desc: Ý kiến cá nhân Vite Template để bắt đầu
dynamic-route: Bản giới thiệu về dynamic route
hi: Hi, {name}!
whats-your-name: Tên bạn là gì?
not-found: Không tìm thấy

View File

@ -1,17 +0,0 @@
{
"button": {
"about": "关于",
"back": "返回",
"go": "确定",
"home": "首页",
"toggle_dark": "切换深色模式",
"toggle_langs": "切换语言"
},
"intro": {
"desc": "固执己见的 Vite 项目模板",
"dynamic-route": "动态路由演示",
"hi": "你好,{name}",
"whats-your-name": "输入你的名字"
},
"not-found": "未找到页面"
}

13
locales/zh-CN.yml Normal file
View File

@ -0,0 +1,13 @@
button:
about: 关于
back: 返回
go: 确定
home: 首页
toggle_dark: 切换深色模式
toggle_langs: 切换语言
intro:
desc: 固执己见的 Vite 项目模板
dynamic-route: 动态路由演示
hi: 你好,{name}
whats-your-name: 输入你的名字
not-found: 未找到页面

View File

@ -5,9 +5,10 @@ import { UserModule } from '~/types'
// https://vitejs.dev/guide/features.html#glob-import
const messages = Object.fromEntries(
Object.entries(
import.meta.globEager('../../locales/*.json'))
import.meta.globEager('../../locales/*.y(a)?ml'))
.map(([key, value]) => {
return [key.slice(14, -5), value.default]
const yaml = key.endsWith('.yaml')
return [key.slice(14, yaml ? -5 : -4), value.default]
}),
)