Skip to content

Commit

Permalink
WIP - add Lang.svelte component
Browse files Browse the repository at this point in the history
  • Loading branch information
kaisermann committed Nov 22, 2019
1 parent b8ce517 commit 31d96f2
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 11 deletions.
13 changes: 13 additions & 0 deletions Lang.svelte
Original file line number Diff line number Diff line change
@@ -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} />
7 changes: 6 additions & 1 deletion example/src/routes/_layout.svelte
Original file line number Diff line number Diff line change
@@ -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>

Expand All @@ -29,6 +30,10 @@
}
</style>

<Lang let:loading>
{loading}
</Lang>

<Nav {segment} />

<main>
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@
"prepublishOnly": "npm run format && npm run test && npm run build"
},
"files": [
"dist/"
"dist/",
"Lang.svelte"
],
"jest": {
"collectCoverage": true,
Expand Down
7 changes: 0 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion src/client/modules.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
declare module 'object-resolve-path'
declare module 'object-resolve-path'
16 changes: 15 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit 31d96f2

Please sign in to comment.