mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
refactor: 💡 move about messages to their own dir (not working)
This commit is contained in:
parent
408b40cc8c
commit
b8ce517455
|
@ -1,10 +1,7 @@
|
||||||
{
|
{
|
||||||
"title": {
|
"title": {
|
||||||
"about": "About",
|
|
||||||
"index": "Sapper project template!"
|
"index": "Sapper project template!"
|
||||||
},
|
},
|
||||||
"about_this_site": "About this site",
|
|
||||||
"about_content": ["This is the 'about' page. There's not much here."],
|
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Great success!",
|
"success": "Great success!",
|
||||||
"high_five": "High five",
|
"high_five": "High five",
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
{
|
{
|
||||||
"title": {
|
"title": {
|
||||||
"about": "About",
|
|
||||||
"index": "Sapper project template!"
|
"index": "Sapper project template!"
|
||||||
},
|
},
|
||||||
"about_this_site": "About this site",
|
|
||||||
"about_content": ["This is the 'about' page. There's not much here."],
|
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Great success!",
|
"success": "Great success!",
|
||||||
"high_five": "High five",
|
"high_five": "High five",
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
{
|
{
|
||||||
"title": {
|
"title": {
|
||||||
"about": "Acerca de",
|
|
||||||
"index": " Plantilla de proyecto Sapper!"
|
"index": " Plantilla de proyecto Sapper!"
|
||||||
},
|
},
|
||||||
"about_this_site": " Acerca de este sitio",
|
|
||||||
"about_content": ["Esta es la página 'acerca de'. No hay mucho aquí."],
|
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Gran éxito!",
|
"success": "Gran éxito!",
|
||||||
"high_five": "Cinco altos",
|
"high_five": "Cinco altos",
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
{
|
{
|
||||||
"title": {
|
"title": {
|
||||||
"about": "Sobre",
|
|
||||||
"index": "Modelo de projeto em Sapper!"
|
"index": "Modelo de projeto em Sapper!"
|
||||||
},
|
},
|
||||||
"about_this_site": "Sobre este site",
|
|
||||||
"about_content": ["Esta é a página 'sobre'. Não há muito aqui."],
|
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Suuuucesso!",
|
"success": "Suuuucesso!",
|
||||||
"high_five": "Toca aqui",
|
"high_five": "Toca aqui",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script context="module">
|
<script context="module">
|
||||||
import { locale, getClientLocale } from 'svelte-i18n'
|
import { locale, locales, getClientLocale } from 'svelte-i18n'
|
||||||
|
|
||||||
export async function preload() {
|
export async function preload() {
|
||||||
return locale.set(getClientLocale({ default: 'en-US', navigator: true }))
|
return locale.set(getClientLocale({ default: 'en-US', navigator: true }))
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
<script>
|
<script>
|
||||||
import Nav from '../components/Nav.svelte'
|
import Nav from '../components/Nav.svelte'
|
||||||
|
|
||||||
const locales = {
|
const localeLabels = {
|
||||||
'pt-BR': 'Português',
|
'pt-BR': 'Português',
|
||||||
'en-US': 'English',
|
'en-US': 'English',
|
||||||
'es-ES': 'Espanõl',
|
'es-ES': 'Espanõl',
|
||||||
|
@ -33,8 +33,8 @@
|
||||||
|
|
||||||
<main>
|
<main>
|
||||||
<select bind:value={$locale}>
|
<select bind:value={$locale}>
|
||||||
{#each Object.entries(locales) as [locale, label]}
|
{#each $locales as locale}
|
||||||
<option value={locale}>{label}</option>
|
<option value={locale}>{localeLabels[locale]}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
<script>
|
|
||||||
import { _ } from 'svelte-i18n'
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<title>{$_('title.about', { default: 'About' })}</title>
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<h1>{$_('about_this_site', { default: 'About this site' })}</h1>
|
|
||||||
|
|
||||||
<p>
|
|
||||||
{$_('about_content[0]', {
|
|
||||||
default: "This is the 'about' page. There's not much here.",
|
|
||||||
})}
|
|
||||||
</p>
|
|
7
example/src/routes/about/_locales/default.json
Normal file
7
example/src/routes/about/_locales/default.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"about": "About"
|
||||||
|
},
|
||||||
|
"about_this_site": "About this site",
|
||||||
|
"about_content": ["This is the 'about' page. There's not much here."]
|
||||||
|
}
|
7
example/src/routes/about/_locales/en-US.json
Normal file
7
example/src/routes/about/_locales/en-US.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"about": "About"
|
||||||
|
},
|
||||||
|
"about_this_site": "About this site",
|
||||||
|
"about_content": ["This is the 'about' page. There's not much here."]
|
||||||
|
}
|
7
example/src/routes/about/_locales/es-ES.json
Normal file
7
example/src/routes/about/_locales/es-ES.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"about": "Acerca de"
|
||||||
|
},
|
||||||
|
"about_this_site": " Acerca de este sitio",
|
||||||
|
"about_content": ["Esta es la página 'acerca de'. No hay mucho aquí."]
|
||||||
|
}
|
7
example/src/routes/about/_locales/pt-BR.json
Normal file
7
example/src/routes/about/_locales/pt-BR.json
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"title": {
|
||||||
|
"about": "Sobre"
|
||||||
|
},
|
||||||
|
"about_this_site": "Sobre este site",
|
||||||
|
"about_content": ["Esta é a página 'sobre'. Não há muito aqui."]
|
||||||
|
}
|
27
example/src/routes/about/index.svelte
Normal file
27
example/src/routes/about/index.svelte
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
<script context="module">
|
||||||
|
// import { partial } from 'svelte-i18n'
|
||||||
|
|
||||||
|
export async function preload() {
|
||||||
|
// return partial({
|
||||||
|
// 'en-US': () => import('./_locales/en-US.json'),
|
||||||
|
// 'pt-BR': () => import('./_locales/pt-BR.json'),
|
||||||
|
// 'es-ES': () => import('./_locales/es-ES.json'),
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { _ } from 'svelte-i18n'
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>{$_('title.about', { default: 'About' })}</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
|
<h1>{$_('about_this_site', { default: 'About this site' })}</h1>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{$_('about_content[0]', {
|
||||||
|
default: "This is the 'about' page. There's not much here.",
|
||||||
|
})}
|
||||||
|
</p>
|
Loading…
Reference in New Issue
Block a user