mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-06-30 18:54:49 +02:00
docs: ✏️ initial wiki docs
This commit is contained in:
parent
649b779a6e
commit
6fe6c8cca8
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "docs"]
|
||||||
|
path = docs
|
||||||
|
url = git@github.com:kaisermann/svelte-i18n.wiki.git
|
1
docs
Submodule
1
docs
Submodule
|
@ -0,0 +1 @@
|
||||||
|
Subproject commit acadff6027a315e011a7157ae3b139d5e4cc3ae5
|
|
@ -39,28 +39,19 @@ export default {
|
||||||
dedupe,
|
dedupe,
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
json(),
|
json({
|
||||||
|
namedExports: false,
|
||||||
|
compact: !dev,
|
||||||
|
}),
|
||||||
legacy &&
|
legacy &&
|
||||||
babel({
|
babel({
|
||||||
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
extensions: ['.js', '.mjs', '.html', '.svelte'],
|
||||||
runtimeHelpers: true,
|
runtimeHelpers: true,
|
||||||
exclude: ['node_modules/@babel/**'],
|
exclude: ['node_modules/@babel/**'],
|
||||||
presets: [
|
presets: [['@babel/preset-env', { targets: '> 0.25%, not dead' }]],
|
||||||
[
|
|
||||||
'@babel/preset-env',
|
|
||||||
{
|
|
||||||
targets: '> 0.25%, not dead',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
plugins: [
|
plugins: [
|
||||||
'@babel/plugin-syntax-dynamic-import',
|
'@babel/plugin-syntax-dynamic-import',
|
||||||
[
|
['@babel/plugin-transform-runtime', { useESModules: true }],
|
||||||
'@babel/plugin-transform-runtime',
|
|
||||||
{
|
|
||||||
useESModules: true,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
@ -88,7 +79,10 @@ export default {
|
||||||
dedupe,
|
dedupe,
|
||||||
}),
|
}),
|
||||||
commonjs(),
|
commonjs(),
|
||||||
json(),
|
json({
|
||||||
|
namedExports: false,
|
||||||
|
compact: !dev,
|
||||||
|
}),
|
||||||
],
|
],
|
||||||
external: Object.keys(pkg.dependencies).concat(
|
external: Object.keys(pkg.dependencies).concat(
|
||||||
require('module').builtinModules ||
|
require('module').builtinModules ||
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { register, getClientLocale, locale } from 'svelte-i18n'
|
import { register } 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'))
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
<script context="module">
|
<script context="module">
|
||||||
import { locales, locale, waitLocale,getClientLocale } from 'svelte-i18n'
|
import { locales, locale, waitLocale,getClientLocale } from 'svelte-i18n'
|
||||||
import Lang from 'svelte-i18n/Lang.svelte'
|
import Intl from 'svelte-i18n/Intl.svelte'
|
||||||
|
|
||||||
export async function preload() {
|
export async function preload() {
|
||||||
const initialLocale = getClientLocale({
|
const initialLocale = getClientLocale({
|
||||||
default: 'pt-BR',
|
default: 'en-US',
|
||||||
navigator: true
|
navigator: true
|
||||||
})
|
})
|
||||||
return locale.set(initialLocale)
|
return locale.set(initialLocale)
|
||||||
|
@ -33,19 +33,40 @@
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading {
|
||||||
|
position: fixed;
|
||||||
|
z-index: 10;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
top: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: rgba(0, 0, 0, .5);
|
||||||
|
color: #fff;
|
||||||
|
font-family: monospace;
|
||||||
|
font-size: 4rem;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<Lang let:loading>{loading}</Lang>
|
<Intl let:loading>
|
||||||
|
{#if loading}
|
||||||
|
<div class="loading">Loading...</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<Nav {segment} />
|
<Nav {segment} />
|
||||||
|
<main>
|
||||||
<main>
|
<select bind:value={$locale}>
|
||||||
<select bind:value={$locale}>
|
{#each $locales as locale}
|
||||||
{#each $locales as locale}
|
{#if locale in localeLabels}
|
||||||
{#if locale in localeLabels}
|
<option value={locale}>{localeLabels[locale]}</option>
|
||||||
<option value={locale}>{localeLabels[locale]}</option>
|
{/if}
|
||||||
{/if}
|
{/each}
|
||||||
{/each}
|
</select>
|
||||||
</select>
|
<slot />
|
||||||
<slot />
|
</main>
|
||||||
</main>
|
</Intl>
|
|
@ -5,7 +5,7 @@
|
||||||
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'))
|
||||||
|
|
||||||
export async function preload() {
|
export async function preload(page, session) {
|
||||||
return waitLocale()
|
return waitLocale()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -15,9 +15,9 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{$_('title.about', { default: 'About' })}</title>
|
<title>{$_('title.about')}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<h1>{$_('about_this_site', { default: 'About this site' })}</h1>
|
<h1>{$_('about_this_site')}</h1>
|
||||||
|
|
||||||
<p>{$_('about_content[0]', { default: "This is the 'about' page. There's not much here." })}</p>
|
<p>{$_('about_content[0]')}</p>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user