mirror of
https://github.com/cupcakearmy/svelte-i18n.git
synced 2024-11-16 09:59:58 +01:00
WIP - add Lang.svelte component
This commit is contained in:
parent
b8ce517455
commit
31d96f24ff
13
Lang.svelte
Normal file
13
Lang.svelte
Normal file
@ -0,0 +1,13 @@
|
||||
<script>
|
||||
import { locale } from './dist/i18n.mjs'
|
||||
|
||||
let loading = false
|
||||
|
||||
$: {
|
||||
if (typeof window !== 'undefined') {
|
||||
document.documentElement.setAttribute('lang', $locale)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<slot {loading} />
|
@ -1,8 +1,9 @@
|
||||
<script context="module">
|
||||
import { locale, locales, getClientLocale } from 'svelte-i18n'
|
||||
import Lang from 'svelte-i18n/Lang.svelte'
|
||||
|
||||
export async function preload() {
|
||||
return locale.set(getClientLocale({ default: 'en-US', navigator: true }))
|
||||
return locale.set(getClientLocale({ default: 'pt-BR', navigator: true }))
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -29,6 +30,10 @@
|
||||
}
|
||||
</style>
|
||||
|
||||
<Lang let:loading>
|
||||
{loading}
|
||||
</Lang>
|
||||
|
||||
<Nav {segment} />
|
||||
|
||||
<main>
|
||||
|
@ -31,7 +31,8 @@
|
||||
"prepublishOnly": "npm run format && npm run test && npm run build"
|
||||
},
|
||||
"files": [
|
||||
"dist/"
|
||||
"dist/",
|
||||
"Lang.svelte"
|
||||
],
|
||||
"jest": {
|
||||
"collectCoverage": true,
|
||||
|
@ -7,13 +7,6 @@ import pkg from './package.json'
|
||||
|
||||
const PROD = !process.env.ROLLUP_WATCH
|
||||
|
||||
// const externals = new Set([
|
||||
// ...Object.keys(pkg.dependencies),
|
||||
// ...Object.keys(pkg.peerDependencies),
|
||||
// 'fs',
|
||||
// 'path',
|
||||
// ])
|
||||
|
||||
export default [
|
||||
{
|
||||
input: 'src/client/index.ts',
|
||||
|
2
src/client/modules.d.ts
vendored
2
src/client/modules.d.ts
vendored
@ -1 +1 @@
|
||||
declare module 'object-resolve-path'
|
||||
declare module 'object-resolve-path'
|
16
yarn.lock
16
yarn.lock
@ -4322,6 +4322,11 @@ require-main-filename@^2.0.0:
|
||||
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
|
||||
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==
|
||||
|
||||
require-relative@^0.8.7:
|
||||
version "0.8.7"
|
||||
resolved "https://registry.yarnpkg.com/require-relative/-/require-relative-0.8.7.tgz#7999539fc9e047a37928fa196f8e1563dabd36de"
|
||||
integrity sha1-eZlTn8ngR6N5KPoZb44VY9q9Nt4=
|
||||
|
||||
resolve-cwd@^2.0.0:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a"
|
||||
@ -4404,6 +4409,15 @@ rollup-plugin-commonjs@^10.1.0:
|
||||
resolve "^1.11.0"
|
||||
rollup-pluginutils "^2.8.1"
|
||||
|
||||
rollup-plugin-svelte@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-svelte/-/rollup-plugin-svelte-5.1.1.tgz#0094f94e7e6ff7579bcd9f7769b454751ba670e1"
|
||||
integrity sha512-wP3CnKHjR4fZUgNm5Iey7eItnxwnH/nAw568WJ8dpMSchBxxZ/DmKSx8e6h8k/B6SwG1wfGvWehadFJHcuFFSw==
|
||||
dependencies:
|
||||
require-relative "^0.8.7"
|
||||
rollup-pluginutils "^2.3.3"
|
||||
sourcemap-codec "^1.4.4"
|
||||
|
||||
rollup-plugin-terser@^5.1.2:
|
||||
version "5.1.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.1.2.tgz#3e41256205cb75f196fc70d4634227d1002c255c"
|
||||
@ -4433,7 +4447,7 @@ rollup-pluginutils@2.8.1:
|
||||
dependencies:
|
||||
estree-walker "^0.6.1"
|
||||
|
||||
rollup-pluginutils@^2.8.1:
|
||||
rollup-pluginutils@^2.3.3, rollup-pluginutils@^2.8.1:
|
||||
version "2.8.2"
|
||||
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
|
||||
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==
|
||||
|
Loading…
Reference in New Issue
Block a user