mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-09-28 15:14:45 +02:00
chore: 🤖 localize more things on example
This commit is contained in:
parent
1b0138c3f3
commit
20e5a00e2e
@ -2,6 +2,11 @@
|
|||||||
"title": {
|
"title": {
|
||||||
"index": "Sapper project template!"
|
"index": "Sapper project template!"
|
||||||
},
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "",
|
||||||
|
"about": "",
|
||||||
|
"blog": ""
|
||||||
|
},
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Great success!",
|
"success": "Great success!",
|
||||||
"high_five": "High five",
|
"high_five": "High five",
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
{
|
|
||||||
"title": {
|
|
||||||
"index": "Sapper project template!"
|
|
||||||
},
|
|
||||||
"messages": {
|
|
||||||
"success": "Great success!",
|
|
||||||
"high_five": "High five",
|
|
||||||
"try_editing": "Try editing this file (src/routes/index.svelte) to test live reloading."
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,6 +2,11 @@
|
|||||||
"title": {
|
"title": {
|
||||||
"index": "Sapper project template!"
|
"index": "Sapper project template!"
|
||||||
},
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "Home",
|
||||||
|
"about": "About",
|
||||||
|
"blog": "Blog"
|
||||||
|
},
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Great success!",
|
"success": "Great success!",
|
||||||
"high_five": "High five",
|
"high_five": "High five",
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
"title": {
|
"title": {
|
||||||
"index": " Plantilla de proyecto Sapper!"
|
"index": " Plantilla de proyecto Sapper!"
|
||||||
},
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "Inicio",
|
||||||
|
"about": "Acerca",
|
||||||
|
"blog": "Blog"
|
||||||
|
},
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Gran éxito!",
|
"success": "Gran éxito!",
|
||||||
"high_five": "Cinco altos",
|
"high_five": "Cinco altos",
|
||||||
|
@ -2,6 +2,11 @@
|
|||||||
"title": {
|
"title": {
|
||||||
"index": "Modelo de projeto em Sapper!"
|
"index": "Modelo de projeto em Sapper!"
|
||||||
},
|
},
|
||||||
|
"nav": {
|
||||||
|
"home": "Home",
|
||||||
|
"about": "Sobre",
|
||||||
|
"blog": "Blog"
|
||||||
|
},
|
||||||
"messages": {
|
"messages": {
|
||||||
"success": "Suuuucesso!",
|
"success": "Suuuucesso!",
|
||||||
"high_five": "Toca aqui",
|
"high_five": "Toca aqui",
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { _ } from 'svelte-i18n'
|
||||||
|
|
||||||
export let segment;
|
export let segment;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -50,11 +52,11 @@
|
|||||||
|
|
||||||
<nav>
|
<nav>
|
||||||
<ul>
|
<ul>
|
||||||
<li><a class:selected='{segment === undefined}' href='.'>home</a></li>
|
<li><a class:selected='{segment === undefined}' href='.'>{$_('nav.home')}</a></li>
|
||||||
<li><a class:selected='{segment === "about"}' href='about'>about</a></li>
|
<li><a class:selected='{segment === "about"}' href='about'>{$_('nav.about')}</a></li>
|
||||||
|
|
||||||
<!-- for the blog link, we're using rel=prefetch so that Sapper prefetches
|
<!-- for the blog link, we're using rel=prefetch so that Sapper prefetches
|
||||||
the blog data when we hover over the link or tap it on a touchscreen -->
|
the blog data when we hover over the link or tap it on a touchscreen -->
|
||||||
<li><a rel=prefetch class:selected='{segment === "blog"}' href='blog'>blog</a></li>
|
<li><a rel=prefetch class:selected='{segment === "blog"}' href='blog'>{$_('nav.blog')}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import { register } from 'svelte-i18n'
|
import { register, getClientLocale, locale } from 'svelte-i18n'
|
||||||
|
|
||||||
register('en', () => import('../messages/en.json'))
|
register('en', () => import('../messages/en.json'))
|
||||||
register('pt-BR', () => import('../messages/pt-BR.json'))
|
register('pt-BR', () => import('../messages/pt-BR.json'))
|
||||||
register('en-US', () => import('../messages/en-US.json'))
|
|
||||||
register('es-ES', () => import('../messages/es-ES.json'))
|
register('es-ES', () => import('../messages/es-ES.json'))
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
import { locale, locales, getClientLocale, waitLocale } from 'svelte-i18n'
|
import { locales, locale, waitLocale,getClientLocale } from 'svelte-i18n'
|
||||||
import Lang from 'svelte-i18n/Lang.svelte'
|
import Lang from 'svelte-i18n/Lang.svelte'
|
||||||
|
|
||||||
export async function preload() {
|
export async function preload() {
|
||||||
return locale.set(getClientLocale({ default: 'pt-BR', navigator: true }))
|
const initialLocale = getClientLocale({
|
||||||
|
default: 'pt-BR',
|
||||||
|
navigator: true
|
||||||
|
})
|
||||||
|
return locale.set(initialLocale)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -12,7 +16,8 @@
|
|||||||
|
|
||||||
const localeLabels = {
|
const localeLabels = {
|
||||||
'pt-BR': 'Português',
|
'pt-BR': 'Português',
|
||||||
'en-US': 'English',
|
'en': 'English',
|
||||||
|
'en-US': 'English US',
|
||||||
'es-ES': 'Espanõl',
|
'es-ES': 'Espanõl',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<script context="module">
|
<script context="module">
|
||||||
import { register, waitLocale } from 'svelte-i18n'
|
import { register, waitLocale } from 'svelte-i18n'
|
||||||
|
|
||||||
register('en-US', () => import('./_locales/en-US.json'))
|
register('en', () => import('./_locales/en.json'))
|
||||||
register('pt-BR', () => import('./_locales/pt-BR.json'))
|
register('pt-BR', () => import('./_locales/pt-BR.json'))
|
||||||
register('es-ES', () => import('./_locales/es-ES.json'))
|
register('es-ES', () => import('./_locales/es-ES.json'))
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ describe('utilities', () => {
|
|||||||
|
|
||||||
it('should get the fallback locale', () => {
|
it('should get the fallback locale', () => {
|
||||||
window.location.hostname = 'pt.example.com'
|
window.location.hostname = 'pt.example.com'
|
||||||
expect(getClientLocale({ hostname: /^.*?\./ })).toBe('pt')
|
expect(getClientLocale({ hostname: /^(.*?)\./ })).toBe('pt')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user