WIP - add Lang.svelte component

This commit is contained in:
Christian Kaisermann 2019-11-19 18:23:20 -03:00
parent b8ce517455
commit 31d96f24ff
6 changed files with 37 additions and 11 deletions

13
Lang.svelte Normal file
View 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} />

View File

@ -1,8 +1,9 @@
<script context="module"> <script context="module">
import { locale, locales, getClientLocale } from 'svelte-i18n' import { locale, locales, getClientLocale } from 'svelte-i18n'
import Lang from 'svelte-i18n/Lang.svelte'
export async function preload() { export async function preload() {
return locale.set(getClientLocale({ default: 'en-US', navigator: true })) return locale.set(getClientLocale({ default: 'pt-BR', navigator: true }))
} }
</script> </script>
@ -29,6 +30,10 @@
} }
</style> </style>
<Lang let:loading>
{loading}
</Lang>
<Nav {segment} /> <Nav {segment} />
<main> <main>

View File

@ -31,7 +31,8 @@
"prepublishOnly": "npm run format && npm run test && npm run build" "prepublishOnly": "npm run format && npm run test && npm run build"
}, },
"files": [ "files": [
"dist/" "dist/",
"Lang.svelte"
], ],
"jest": { "jest": {
"collectCoverage": true, "collectCoverage": true,

View File

@ -7,13 +7,6 @@ import pkg from './package.json'
const PROD = !process.env.ROLLUP_WATCH const PROD = !process.env.ROLLUP_WATCH
// const externals = new Set([
// ...Object.keys(pkg.dependencies),
// ...Object.keys(pkg.peerDependencies),
// 'fs',
// 'path',
// ])
export default [ export default [
{ {
input: 'src/client/index.ts', input: 'src/client/index.ts',

View File

@ -1 +1 @@
declare module 'object-resolve-path' declare module 'object-resolve-path'

View File

@ -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" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== 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: resolve-cwd@^2.0.0:
version "2.0.0" version "2.0.0"
resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" 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" resolve "^1.11.0"
rollup-pluginutils "^2.8.1" 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: rollup-plugin-terser@^5.1.2:
version "5.1.2" version "5.1.2"
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-5.1.2.tgz#3e41256205cb75f196fc70d4634227d1002c255c" 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: dependencies:
estree-walker "^0.6.1" estree-walker "^0.6.1"
rollup-pluginutils@^2.8.1: rollup-pluginutils@^2.3.3, rollup-pluginutils@^2.8.1:
version "2.8.2" version "2.8.2"
resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e" resolved "https://registry.yarnpkg.com/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz#72f2af0748b592364dbd3389e600e5a9444a351e"
integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ== integrity sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==