{$t('error.shit.happens')} ({status})
10 |{$t(`error.${status}`, { default: $t('error.default') })}
11 |12 |
13 | {$locale} – {$t(`lang.${$locale}`)} 14 |
├── .nvmrc ├── .github ├── FUNDING.yml └── workflows │ ├── tests.yml │ └── publish.yml ├── .npmignore ├── pnpm-workspace.yaml ├── tests ├── data │ ├── translations │ │ ├── en │ │ │ ├── route.json │ │ │ └── common.json │ │ ├── ku │ │ │ └── common.json │ │ ├── zh-Hans │ │ │ └── common.json │ │ └── index.ts │ └── index.ts ├── tsconfig.json └── utils │ └── index.ts ├── examples ├── loaders │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── cs │ │ │ │ │ ├── more.json │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── lang.json │ │ │ │ └── en │ │ │ │ │ ├── more.json │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +server.js │ │ │ ├── +layout.svelte │ │ │ └── +layout.server.js │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── svelte.config.js │ ├── netlify.toml │ ├── vite.config.js │ ├── package.json │ └── README.md ├── locale-param │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── +layout.server.js │ │ │ └── +layout.svelte │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── svelte.config.js │ ├── netlify.toml │ ├── vite.config.js │ ├── package.json │ └── README.md ├── multi-page │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── +layout.svelte │ │ │ └── +layout.server.js │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── svelte.config.js │ ├── netlify.toml │ ├── vite.config.js │ ├── package.json │ └── README.md ├── one-page │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── content.json │ │ │ │ │ └── menu.json │ │ │ │ ├── en │ │ │ │ │ ├── content.json │ │ │ │ │ └── menu.json │ │ │ │ └── index.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ └── +layout.svelte │ │ ├── app.d.ts │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── preprocess │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── index.js │ │ │ │ └── translations.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── app.d.ts │ │ ├── app.html │ │ └── routes │ │ │ ├── +layout.svelte │ │ │ └── +page.svelte │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── single-load │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── index.js │ │ │ │ └── translations.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── app.d.ts │ │ ├── routes │ │ │ ├── +page.svelte │ │ │ └── +layout.svelte │ │ └── app.html │ ├── static │ │ └── robots.txt │ ├── svelte.config.js │ ├── netlify.toml │ ├── .gitignore │ ├── vite.config.js │ ├── package.json │ └── README.md ├── fallback-locale │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── +layout.server.js │ │ │ └── +layout.svelte │ │ ├── app.d.ts │ │ └── app.html │ ├── .gitignore │ ├── static │ │ └── favicon.png │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── locale-router │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── de │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── [lang] │ │ │ │ ├── about │ │ │ │ │ └── +page.svelte │ │ │ │ ├── +page.svelte │ │ │ │ └── +layout.svelte │ │ │ ├── +layout.js │ │ │ ├── +error.svelte │ │ │ └── +layout.server.js │ │ ├── app.d.ts │ │ ├── app.html │ │ └── hooks.server.js │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── component-scoped-csr │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ ├── component │ │ │ │ ├── translations │ │ │ │ │ ├── de │ │ │ │ │ │ └── common.json │ │ │ │ │ ├── lang.json │ │ │ │ │ ├── en │ │ │ │ │ │ └── common.json │ │ │ │ │ ├── cs │ │ │ │ │ │ └── common.json │ │ │ │ │ └── index.js │ │ │ │ └── index.svelte │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── +page.svelte │ │ │ ├── +layout.svelte │ │ │ └── +layout.server.js │ │ ├── app.d.ts │ │ └── app.html │ ├── .gitignore │ ├── static │ │ └── favicon.png │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── component-scoped-ssr │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ ├── component │ │ │ │ ├── translations │ │ │ │ │ ├── de │ │ │ │ │ │ └── common.json │ │ │ │ │ ├── lang.json │ │ │ │ │ ├── en │ │ │ │ │ │ └── common.json │ │ │ │ │ ├── cs │ │ │ │ │ │ └── common.json │ │ │ │ │ └── index.js │ │ │ │ └── index.svelte │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── about │ │ │ │ └── +page.svelte │ │ │ ├── +page.js │ │ │ ├── +page.svelte │ │ │ ├── +layout.js │ │ │ ├── +layout.svelte │ │ │ └── +layout.server.js │ │ ├── app.d.ts │ │ └── app.html │ ├── .gitignore │ ├── static │ │ └── favicon.png │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── locale-router-advanced │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ │ └── de │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ └── about.json │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── [...lang=locale] │ │ │ │ ├── about │ │ │ │ │ └── +page.svelte │ │ │ │ ├── +page.svelte │ │ │ │ └── +layout.svelte │ │ │ ├── +layout.js │ │ │ ├── +error.svelte │ │ │ └── +layout.server.js │ │ ├── app.d.ts │ │ ├── params │ │ │ └── locale.js │ │ └── app.html │ ├── .gitignore │ ├── static │ │ └── favicon.png │ ├── netlify.toml │ ├── svelte.config.js │ ├── vite.config.js │ ├── package.json │ └── README.md ├── locale-router-static │ ├── jsconfig.json │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.js │ │ │ │ ├── cs │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ ├── index.js │ │ │ │ │ └── about.json │ │ │ │ ├── en │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ ├── index.js │ │ │ │ │ └── about.json │ │ │ │ ├── de │ │ │ │ │ ├── home.json │ │ │ │ │ ├── error.json │ │ │ │ │ ├── menu.json │ │ │ │ │ ├── index.js │ │ │ │ │ └── about.json │ │ │ │ └── index.js │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── [lang] │ │ │ │ ├── about │ │ │ │ │ └── +page.svelte │ │ │ │ ├── [...error] │ │ │ │ │ ├── +page@.svelte │ │ │ │ │ └── +page.js │ │ │ │ ├── +page.svelte │ │ │ │ └── +layout.svelte │ │ │ ├── +error.svelte │ │ │ └── +layout.js │ │ ├── app.d.ts │ │ ├── app.html │ │ └── hooks.server.js │ ├── .gitignore │ ├── static │ │ └── favicon.png │ ├── vite.config.js │ ├── netlify.toml │ ├── package.json │ └── svelte.config.js ├── parser-icu │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── cs │ │ │ │ │ └── content.json │ │ │ │ ├── en │ │ │ │ │ └── content.json │ │ │ │ └── index.ts │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── +layout.ts │ │ │ ├── +layout.svelte │ │ │ └── +page.svelte │ │ ├── app.d.ts │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── tsconfig.json │ ├── netlify.toml │ ├── vite.config.js │ ├── svelte.config.js │ ├── README.md │ └── package.json ├── parser-default │ ├── src │ │ ├── lib │ │ │ ├── translations │ │ │ │ ├── lang.json │ │ │ │ ├── modifiers.ts │ │ │ │ ├── index.ts │ │ │ │ ├── en │ │ │ │ │ └── content.json │ │ │ │ └── cs │ │ │ │ │ └── content.json │ │ │ └── assets │ │ │ │ └── favicon.svg │ │ ├── routes │ │ │ ├── +layout.ts │ │ │ └── +layout.svelte │ │ ├── app.d.ts │ │ └── app.html │ ├── static │ │ └── favicon.png │ ├── .gitignore │ ├── tsconfig.json │ ├── vite.config.js │ ├── netlify.toml │ ├── svelte.config.js │ ├── package.json │ └── README.md └── tsconfig.json ├── jest.config.js ├── src ├── types.ts └── index.ts ├── tsconfig.json ├── tsup.config.js ├── .gitignore ├── .eslintrc ├── LICENSE └── package.json /.nvmrc: -------------------------------------------------------------------------------- 1 | 22 2 | 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [sveltekit-i18n] 2 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .github 2 | src 3 | tests 4 | examples 5 | docs -------------------------------------------------------------------------------- /pnpm-workspace.yaml: -------------------------------------------------------------------------------- 1 | packages: 2 | - 'examples/*' 3 | 4 | -------------------------------------------------------------------------------- /tests/data/translations/en/route.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "value" 3 | } -------------------------------------------------------------------------------- /examples/loaders/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/locale-param/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/multi-page/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/one-page/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/preprocess/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/single-load/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/fallback-locale/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/locale-router/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/cs/more.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "Nějaký další obsah..." 3 | } -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/locale-router-static/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json" 3 | } -------------------------------------------------------------------------------- /examples/one-page/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/en/more.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "Some additional content..." 3 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/parser-icu/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/preprocess/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/single-load/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /tests/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "include": [ 4 | "./" 5 | ] 6 | } -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/parser-default/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky" 4 | } -------------------------------------------------------------------------------- /examples/single-load/static/robots.txt: -------------------------------------------------------------------------------- 1 | # allow crawling everything by default 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/component/translations/de/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "Some Schweinefleisch..." 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/component/translations/de/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "Some Schweinefleisch..." 3 | } -------------------------------------------------------------------------------- /examples/loaders/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/loaders/static/favicon.png -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "de": "Deutsch", 4 | "cs": "Česky" 5 | } -------------------------------------------------------------------------------- /examples/one-page/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/one-page/static/favicon.png -------------------------------------------------------------------------------- /examples/multi-page/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/multi-page/static/favicon.png -------------------------------------------------------------------------------- /examples/parser-icu/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/parser-icu/static/favicon.png -------------------------------------------------------------------------------- /examples/preprocess/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/preprocess/static/favicon.png -------------------------------------------------------------------------------- /examples/loaders/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/locale-param/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/locale-param/static/favicon.png -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "de": "Deutsch", 4 | "cs": "Česky" 5 | } -------------------------------------------------------------------------------- /examples/locale-router/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/locale-router/static/favicon.png -------------------------------------------------------------------------------- /examples/multi-page/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/one-page/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/parser-default/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/parser-default/static/favicon.png -------------------------------------------------------------------------------- /examples/parser-icu/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/preprocess/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/component/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky", 4 | "de": "Deutsch" 5 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/component/translations/lang.json: -------------------------------------------------------------------------------- 1 | { 2 | "en": "English", 3 | "cs": "Česky", 4 | "de": "Deutsch" 5 | } -------------------------------------------------------------------------------- /examples/fallback-locale/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/fallback-locale/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/fallback-locale/static/favicon.png -------------------------------------------------------------------------------- /examples/locale-param/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/lang.js: -------------------------------------------------------------------------------- 1 | export default { 2 | en: 'English', 3 | de: 'Deutsch', 4 | cs: 'Česky', 5 | }; -------------------------------------------------------------------------------- /examples/locale-router/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/parser-default/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/component/translations/en/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "This component uses its own instance of i18n!" 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/component/translations/en/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "This component uses its own instance of i18n!" 3 | } -------------------------------------------------------------------------------- /examples/locale-router-static/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/component/translations/cs/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "Tato komponenta používá svou vlastní instanci i18n!" 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/component-scoped-csr/static/favicon.png -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/component/translations/cs/common.json: -------------------------------------------------------------------------------- 1 | { 2 | "info": "Tato komponenta používá svou vlastní instanci i18n!" 3 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/component-scoped-ssr/static/favicon.png -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 3 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | build 4 | .svelte-kit 5 | package 6 | .env 7 | .env.* 8 | !.env.example 9 | -------------------------------------------------------------------------------- /examples/locale-router-static/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/locale-router-static/static/favicon.png -------------------------------------------------------------------------------- /examples/locale-router-advanced/static/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sveltekit-i18n/lib/HEAD/examples/locale-router-advanced/static/favicon.png -------------------------------------------------------------------------------- /jest.config.js: -------------------------------------------------------------------------------- 1 | /** @type {import('ts-jest').JestConfigWithTsJest} */ 2 | export default ({ 3 | preset: 'ts-jest/presets/default-esm', 4 | testEnvironment: 'node', 5 | }); -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/one-page/src/lib/translations/cs/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/one-page/src/lib/translations/en/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/one-page/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 3 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/locale-param/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |
{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/cs/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Vítejte ve SvelteKit", 3 | "text": "Dokumentace je k přečtení na kit.svelte.dev" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/multi-page/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Welcome to SvelteKit", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/parser-icu/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "resolveJsonModule": true, 5 | "allowSyntheticDefaultImports": true 6 | } 7 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/de/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Willkommen bei SvelteKit", 3 | "text": "Besuchen Sie kit.svelte.dev, um die Dokumentation zu lesen" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/src/routes/[lang]/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/one-page/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 3 | } -------------------------------------------------------------------------------- /examples/parser-default/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./.svelte-kit/tsconfig.json", 3 | "compilerOptions": { 4 | "resolveJsonModule": true, 5 | "allowSyntheticDefaultImports": true 6 | } 7 | } -------------------------------------------------------------------------------- /examples/parser-default/vite.config.js: -------------------------------------------------------------------------------- 1 | import { sveltekit } from "@sveltejs/kit/vite"; 2 | import { defineConfig } from "vite"; 3 | 4 | export default defineConfig({ 5 | plugins: [sveltekit()], 6 | }); 7 | -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/de/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Willkommen bei SvelteKit", 3 | "text": "Besuchen Sie kit.svelte.dev, um die Dokumentation zu lesen" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/routes/[lang]/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/cs/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "No toto...", 3 | "404": "Stránka nenalezena.", 4 | "500": "Interní chyba serveru.", 5 | "default": "Něco se pokazilo." 6 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/en/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "Oh, dear...", 3 | "404": "Page not found.", 4 | "500": "Server internal error.", 5 | "default": "Some error occurred." 6 | } -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/en/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "This title is from EN (fallback) definitions", 3 | "text": "Visit kit.svelte.dev to read the documentation" 4 | } -------------------------------------------------------------------------------- /examples/fallback-locale/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/de/home.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Willkommen bei SvelteKit", 3 | "text": "Besuchen Sie kit.svelte.dev, um die Dokumentation zu lesen" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/cs/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "No toto...", 3 | "404": "Stránka nenalezena.", 4 | "500": "Interní chyba serveru.", 5 | "default": "Něco se pokazilo." 6 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/en/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "Oh, dear...", 3 | "404": "Page not found.", 4 | "500": "Server internal error.", 5 | "default": "Some error occurred." 6 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/cs/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "No toto...", 3 | "404": "Stránka nenalezena.", 4 | "500": "Interní chyba serveru.", 5 | "default": "Něco se pokazilo." 6 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/en/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "Oh, dear...", 3 | "404": "Page not found.", 4 | "500": "Server internal error.", 5 | "default": "Some error occurred." 6 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/routes/[lang]/[...error]/+page@.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('about.text')}
7 | -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/de/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "Auweh...", 3 | "404": "Seite nicht gefunden.", 4 | "500": "Server interner Fehler.", 5 | "default": "Ein Fehler ist aufgetreten." 6 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/de/error.json: -------------------------------------------------------------------------------- 1 | { 2 | "shit.happens": "Auweh...", 3 | "404": "Seite nicht gefunden.", 4 | "500": "Server interner Fehler.", 5 | "default": "Ein Fehler ist aufgetreten." 6 | } -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/single-load/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from "@sveltejs/adapter-netlify"; 2 | 3 | /** @type {import('@sveltejs/kit').Config} */ 4 | const config = { kit: { adapter: adapter() } }; 5 | 6 | export default config; 7 | -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/parser-icu/src/routes/+layout.ts: -------------------------------------------------------------------------------- 1 | import type { Load } from '@sveltejs/kit'; 2 | import { loading } from '$lib/translations'; 3 | 4 | export const load: Load = async () => { 5 | await loading.toPromise(); 6 | 7 | return {}; 8 | }; -------------------------------------------------------------------------------- /examples/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "paths": { 5 | "$lib": [ 6 | "./*/src/lib" 7 | ] 8 | } 9 | }, 10 | "include": [ 11 | "./" 12 | ] 13 | } -------------------------------------------------------------------------------- /examples/loaders/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/en/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Home", 3 | "about": "About", 4 | "notification": "You have {{count:gt; 0:{{count}} new {{count; 1:message; default:messages}}!; default:no messages...}}" 5 | } -------------------------------------------------------------------------------- /examples/multi-page/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/parser-default/src/routes/+layout.ts: -------------------------------------------------------------------------------- 1 | import type { Load } from '@sveltejs/kit'; 2 | import { loading } from '$lib/translations'; 3 | 4 | export const load: Load = async () => { 5 | await loading.toPromise(); 6 | 7 | return {}; 8 | }; -------------------------------------------------------------------------------- /examples/fallback-locale/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-param/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/one-page/src/routes/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('content.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/de/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Startseite", 3 | "about": "Über uns", 4 | "notification": "Sie haben {{count:gt; 0:{{count}} neue {{count; 1:Nachricht; default:Nachrichten}}!; default:keine Nachrichten...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router/src/routes/[lang]/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/loaders/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-netlify'; 2 | 3 | /** @type {import('@sveltejs/kit').Config} */ 4 | const config = { 5 | kit: { 6 | adapter: adapter(), 7 | }, 8 | }; 9 | 10 | export default config; 11 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/loaders/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter loaders run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/locale-param/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-netlify'; 2 | 3 | /** @type {import('@sveltejs/kit').Config} */ 4 | const config = { 5 | kit: { 6 | adapter: adapter(), 7 | }, 8 | }; 9 | 10 | export default config; 11 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/de/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Startseite", 3 | "about": "Über uns", 4 | "notification": "Sie haben {{count:gt; 0:{{count}} neue {{count; 1:Nachricht; default:Nachrichten}}!; default:keine Nachrichten...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/cs/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Domů", 3 | "about": "O nás", 4 | "notification": "{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/de/menu.json: -------------------------------------------------------------------------------- 1 | { 2 | "home": "Startseite", 3 | "about": "Über uns", 4 | "notification": "Sie haben {{count:gt; 0:{{count}} neue {{count; 1:Nachricht; default:Nachrichten}}!; default:keine Nachrichten...}}" 5 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/routes/[lang]/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/multi-page/svelte.config.js: -------------------------------------------------------------------------------- 1 | import adapter from '@sveltejs/adapter-netlify'; 2 | 3 | /** @type {import('@sveltejs/kit').Config} */ 4 | const config = { 5 | kit: { 6 | adapter: adapter(), 7 | }, 8 | }; 9 | 10 | export default config; 11 | -------------------------------------------------------------------------------- /examples/one-page/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter one-page run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/locale-param/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter locale-param run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/routes/[...lang=locale]/+page.svelte: -------------------------------------------------------------------------------- 1 | 6 | 7 |{@html $t('home.text', { link })}
9 | -------------------------------------------------------------------------------- /examples/multi-page/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter multi-page run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/parser-default/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter parser-default run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/parser-icu/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter parser-icu run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/preprocess/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter preprocess run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/single-load/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter single-load run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/locale-router/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter locale-router run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/fallback-locale/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter fallback-locale run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/preprocess/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter component-scoped-csr run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/component-scoped-ssr/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter component-scoped-ssr run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/fallback-locale/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | command = "cd ../../ && pnpm install && pnpm run build && pnpm --filter locale-router-advanced run build" 3 | publish = "build" 4 | 5 | [build.environment] 6 | NODE_VERSION = "22" 7 | 8 | [functions] 9 | node_bundler = "esbuild" -------------------------------------------------------------------------------- /examples/locale-router/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/one-page/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import adapter from '@sveltejs/adapter-netlify'; 4 | 5 | /** @type {import('@sveltejs/kit').Config} */ 6 | const config = { 7 | kit: { 8 | adapter: adapter(), 9 | }, 10 | }; 11 | 12 | export default config; 13 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/component-scoped-ssr/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | 4 | /** @type {import('@sveltejs/kit').Config} */ 5 | const config = { 6 | kit: { 7 | adapter: adapter(), 8 | }, 9 | }; 10 | 11 | export default config; 12 | -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/cs/index.js: -------------------------------------------------------------------------------- 1 | import about from './about.json'; 2 | import error from './error.json'; 3 | import home from './home.json'; 4 | import menu from './menu.json'; 5 | 6 | export default { 7 | about, 8 | error, 9 | home, 10 | menu, 11 | }; -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/de/index.js: -------------------------------------------------------------------------------- 1 | import about from './about.json'; 2 | import error from './error.json'; 3 | import home from './home.json'; 4 | import menu from './menu.json'; 5 | 6 | export default { 7 | about, 8 | error, 9 | home, 10 | menu, 11 | }; -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/en/index.js: -------------------------------------------------------------------------------- 1 | import about from './about.json'; 2 | import error from './error.json'; 3 | import home from './home.json'; 4 | import menu from './menu.json'; 5 | 6 | export default { 7 | about, 8 | error, 9 | home, 10 | menu, 11 | }; -------------------------------------------------------------------------------- /src/types.ts: -------------------------------------------------------------------------------- 1 | import type { Config as C } from '@sveltekit-i18n/base'; 2 | import type { Parser } from '@sveltekit-i18n/parser-default'; 3 | 4 | export type Config{@html $t('content.info')}
9 |{@html $l(locale, 'content.text', { link })}
12 | {/each} 13 | -------------------------------------------------------------------------------- /examples/component-scoped-csr/vite.config.js: -------------------------------------------------------------------------------- 1 | import { sveltekit } from "@sveltejs/kit/vite"; 2 | import { defineConfig } from "vite"; 3 | import path from "path"; 4 | 5 | export default defineConfig({ 6 | plugins: [sveltekit()], 7 | resolve: { 8 | alias: { 9 | "sveltekit-i18n": path.resolve(__dirname, "../../src/index.ts"), 10 | }, 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /examples/component-scoped-ssr/vite.config.js: -------------------------------------------------------------------------------- 1 | import { sveltekit } from "@sveltejs/kit/vite"; 2 | import { defineConfig } from "vite"; 3 | import path from "path"; 4 | 5 | export default defineConfig({ 6 | plugins: [sveltekit()], 7 | resolve: { 8 | alias: { 9 | "sveltekit-i18n": path.resolve(__dirname, "../../src/index.ts"), 10 | }, 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /examples/locale-router-advanced/vite.config.js: -------------------------------------------------------------------------------- 1 | import { sveltekit } from "@sveltejs/kit/vite"; 2 | import { defineConfig } from "vite"; 3 | import path from "path"; 4 | 5 | export default defineConfig({ 6 | plugins: [sveltekit()], 7 | resolve: { 8 | alias: { 9 | "sveltekit-i18n": path.resolve(__dirname, "../../src/index.ts"), 10 | }, 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /examples/locale-router-static/vite.config.js: -------------------------------------------------------------------------------- 1 | import { sveltekit } from "@sveltejs/kit/vite"; 2 | import { defineConfig } from "vite"; 3 | import path from "path"; 4 | 5 | export default defineConfig({ 6 | plugins: [sveltekit()], 7 | resolve: { 8 | alias: { 9 | "sveltekit-i18n": path.resolve(__dirname, "../../src/index.ts"), 10 | }, 11 | }, 12 | }); 13 | -------------------------------------------------------------------------------- /examples/one-page/src/routes/+layout.js: -------------------------------------------------------------------------------- 1 | import { loadTranslations } from '$lib/translations'; 2 | 3 | /** @type {import('@sveltejs/kit').Load} */ 4 | export const load = async () => { 5 | 6 | const initialLocale = 'en'; // get from cookie / url / fetch from server... 7 | 8 | await loadTranslations(initialLocale); // keep this just before the `return` 9 | 10 | return {}; 11 | }; -------------------------------------------------------------------------------- /examples/loaders/src/app.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | %sveltekit.head% 10 | 11 | 12 | 13 |{@html $t('home.text', { link })}
12 | 13 |{$t(`error.${status}`, { default: $t('error.default') })}
11 |{$t(`error.${status}`, { default: $t('error.default') })}
11 |{$t(`error.${status}`, { default: $t('error.default') })}
11 |Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 3 | } -------------------------------------------------------------------------------- /examples/parser-default/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | import preprocess from 'svelte-preprocess'; 4 | 5 | /** @type {import('@sveltejs/kit').Config} */ 6 | const config = { 7 | // Consult https://github.com/sveltejs/svelte-preprocess 8 | // for more information about preprocessors 9 | preprocess: preprocess(), 10 | 11 | kit: { 12 | adapter: adapter() 13 | } 14 | }; 15 | 16 | export default config; 17 | -------------------------------------------------------------------------------- /examples/parser-icu/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | import adapter from '@sveltejs/adapter-netlify'; 3 | import preprocess from 'svelte-preprocess'; 4 | 5 | /** @type {import('@sveltejs/kit').Config} */ 6 | const config = { 7 | // Consult https://github.com/sveltejs/svelte-preprocess 8 | // for more information about preprocessors 9 | preprocess: preprocess(), 10 | 11 | kit: { 12 | adapter: adapter() 13 | } 14 | }; 15 | 16 | export default config; 17 | 18 | -------------------------------------------------------------------------------- /examples/locale-router/src/routes/+layout.server.js: -------------------------------------------------------------------------------- 1 | import { loadTranslations, translations } from '$lib/translations'; 2 | 3 | /** @type {import('@sveltejs/kit').ServerLoad} */ 4 | export const load = async ({ url, locals }) => { 5 | const { pathname } = url; 6 | const { lang } = locals; 7 | 8 | const route = pathname.replace(new RegExp(`^/${lang}`), ''); 9 | 10 | await loadTranslations(lang, route); 11 | 12 | return { i18n: { route, lang }, translations: translations.get() }; 13 | }; -------------------------------------------------------------------------------- /examples/fallback-locale/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 3 | } -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/routes/+layout.server.js: -------------------------------------------------------------------------------- 1 | import { loadTranslations, translations } from '$lib/translations'; 2 | 3 | /** @type {import('@sveltejs/kit').ServerLoad} */ 4 | export const load = async ({ url, locals }) => { 5 | const { pathname } = url; 6 | const { lang } = locals; 7 | 8 | const route = pathname.replace(new RegExp(`^/${lang}`), ''); 9 | 10 | await loadTranslations(lang, route); 11 | 12 | return { i18n: { route, lang }, translations: translations.get() }; 13 | }; -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/cs/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "O této aplikaci", 3 | "text": "Toto je SvelteKit aplikace. Můžete si vytvořit svou vlastní vložením následujícího příkazu do příkazové řádky:
npm init svelte@next
Tato stránka je čistě statické HTML, bez nutnosti klientské interakce. Díky tomu není potřeba načítat žádný JavaScript. Zkuste zobrazit drojový kód stránky, nebo otevřete vývojářské nástroje a znovu načtěte stránku.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/routes/+layout.js: -------------------------------------------------------------------------------- 1 | import { setLocale, setRoute } from '$lib/translations'; 2 | 3 | export const prerender = true; 4 | 5 | /** @type { import('@sveltejs/kit').Load } */ 6 | export const load = async ({ url }) => { 7 | const { pathname } = url; 8 | 9 | const lang = `${pathname.match(/\w+?(?=\/|$)/) || ''}`; 10 | 11 | const route = pathname.replace(new RegExp(`^/${lang}`), ''); 12 | 13 | await setLocale(lang); 14 | await setRoute(route); 15 | 16 | return { route, lang }; 17 | }; -------------------------------------------------------------------------------- /examples/loaders/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/multi-page/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-param/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-csr/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "module": "ESNext", 4 | "noImplicitReturns": true, 5 | "noUnusedLocals": true, 6 | "removeComments": true, 7 | "outDir": "lib", 8 | "sourceMap": false, 9 | "strict": true, 10 | "target": "es2020", 11 | "lib": ["ES2020"], 12 | "moduleResolution": "node", 13 | "noEmit": true, 14 | "resolveJsonModule": true, 15 | "allowSyntheticDefaultImports": true 16 | }, 17 | "include": [ 18 | "./src", 19 | "./*.js", 20 | "./*.ts" 21 | ] 22 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/en/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "About this app", 3 | "text": "This is a SvelteKit app. You can make your own by typing the following into your command line and following the prompts:
npm init svelte@next
The page you're looking at is purely static HTML, with no client-side interactivity needed. Because of that, we don't need to load any JavaScript. Try viewing the page's source, or opening the devtools network panel and reloading.
" 4 | } -------------------------------------------------------------------------------- /examples/loaders/src/routes/about/+page.svelte: -------------------------------------------------------------------------------- 1 | 9 | 10 |{@html $t('about.text')}
12 | 13 |{$t('more.content')}
20 | {/if} -------------------------------------------------------------------------------- /examples/loaders/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "loaders", 3 | "private": true, 4 | "version": "0.0.2", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite dev", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "sveltekit-i18n": "workspace:*" 13 | }, 14 | "devDependencies": { 15 | "@sveltejs/adapter-netlify": "^5.2.4", 16 | "@sveltejs/kit": "^2.47.1", 17 | "@sveltejs/vite-plugin-svelte": "^6.2.1", 18 | "svelte": "^5.41.0", 19 | "vite": "^7.1.10" 20 | } 21 | } -------------------------------------------------------------------------------- /examples/one-page/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "one-page", 3 | "private": true, 4 | "version": "0.0.2", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite dev", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "sveltekit-i18n": "workspace:*" 13 | }, 14 | "devDependencies": { 15 | "@sveltejs/adapter-netlify": "^5.2.4", 16 | "@sveltejs/kit": "^2.47.1", 17 | "@sveltejs/vite-plugin-svelte": "^6.2.1", 18 | "svelte": "^5.41.0", 19 | "vite": "^7.1.10" 20 | } 21 | } -------------------------------------------------------------------------------- /examples/multi-page/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "multi-page", 3 | "private": true, 4 | "version": "0.0.2", 5 | "type": "module", 6 | "scripts": { 7 | "dev": "vite dev", 8 | "build": "vite build", 9 | "preview": "vite preview" 10 | }, 11 | "dependencies": { 12 | "sveltekit-i18n": "workspace:*" 13 | }, 14 | "devDependencies": { 15 | "@sveltejs/adapter-netlify": "^5.2.4", 16 | "@sveltejs/kit": "^2.47.1", 17 | "@sveltejs/vite-plugin-svelte": "^6.2.1", 18 | "svelte": "^5.41.0", 19 | "vite": "^7.1.10" 20 | } 21 | } -------------------------------------------------------------------------------- /examples/parser-icu/src/routes/+layout.svelte: -------------------------------------------------------------------------------- 1 | 7 | 8 |Dies ist eine SvelteKit-App. Sie können Ihre eigene erstellen, indem Sie Folgendes in Ihre Befehlszeile eingeben und den Eingabeaufforderungen folgen:
npm init svelte@next
Die Seite, die Sie sich ansehen, ist rein statisches HTML mit keine clientseitige Interaktivität erforderlich. Aus diesem Grund müssen wir kein JavaScript laden. Versuchen Sie, die Quelle der Seite anzuzeigen oder das devtools-Netzwerkfenster zu öffnen und neu zu laden.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-static/src/lib/translations/de/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Über diese App", 3 | "text": "Dies ist eine SvelteKit-App. Sie können Ihre eigene erstellen, indem Sie Folgendes in Ihre Befehlszeile eingeben und den Eingabeaufforderungen folgen:
npm init svelte@next
Die Seite, die Sie sich ansehen, ist rein statisches HTML mit keine clientseitige Interaktivität erforderlich. Aus diesem Grund müssen wir kein JavaScript laden. Versuchen Sie, die Quelle der Seite anzuzeigen oder das devtools-Netzwerkfenster zu öffnen und neu zu laden.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router-advanced/src/lib/translations/de/about.json: -------------------------------------------------------------------------------- 1 | { 2 | "title": "Über diese App", 3 | "text": "Dies ist eine SvelteKit-App. Sie können Ihre eigene erstellen, indem Sie Folgendes in Ihre Befehlszeile eingeben und den Eingabeaufforderungen folgen:
npm init svelte@next
Die Seite, die Sie sich ansehen, ist rein statisches HTML mit keine clientseitige Interaktivität erforderlich. Aus diesem Grund müssen wir kein JavaScript laden. Versuchen Sie, die Quelle der Seite anzuzeigen oder das devtools-Netzwerkfenster zu öffnen und neu zu laden.
" 4 | } -------------------------------------------------------------------------------- /examples/locale-router/README.md: -------------------------------------------------------------------------------- 1 | # Locale-router 2 | This app shows how to integrate locale routing using dynamic adapters (e.g. `@sveltejs/adapter-node`). It includes two pages and three language mutations (`en`, `de`, `cs`). Error pages are included as well. 3 | 4 | ## How to use this example 5 | 6 | - Download this example 7 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.) 8 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.) 9 | 10 | ## Setup 11 | 12 | ### `./src/hooks.server.js` 13 | Takes care about redirects to appropriate language mutation. -------------------------------------------------------------------------------- /examples/fallback-locale/README.md: -------------------------------------------------------------------------------- 1 | [](https://app.netlify.com/sites/fallback-locale/deploys) 2 | 3 | # Fallback locale 4 | This app shows how to use `config.fallbackLocale` parameter. 5 | 6 | ## Preview 7 | You can view this demo live on [Netlify](https://fallback-locale.netlify.app). 8 | 9 | ## How to use this example 10 | 11 | - Download this example 12 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.) 13 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.) -------------------------------------------------------------------------------- /tsup.config.js: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'tsup'; 2 | 3 | export default defineConfig( 4 | /** @type {() => import('tsup').Options} */ 5 | (options) => [ 6 | { 7 | clean: true, 8 | dts: true, 9 | format: ['esm'], 10 | entry: ['src/index.ts'], 11 | minify: !options.watch, 12 | sourcemap: options.watch, 13 | splitting: true, 14 | }, 15 | { 16 | clean: false, 17 | dts: false, 18 | format: ['cjs'], 19 | entry: ['src/index.ts'], 20 | minify: !options.watch, 21 | sourcemap: options.watch, 22 | splitting: true, 23 | }, 24 | ], 25 | ); -------------------------------------------------------------------------------- /examples/preprocess/README.md: -------------------------------------------------------------------------------- 1 | [](https://app.netlify.com/sites/preprocess-example/deploys) 2 | 3 | # Preprocess 4 | This app demonstrates behavior of `preprocess` config prop on multiple `i18n` instances. 5 | 6 | ## Preview 7 | You can view this demo live on [Netlify](https://preprocess-example.netlify.app). 8 | 9 | ## How to use this example 10 | 11 | - Download this example 12 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.) 13 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.) -------------------------------------------------------------------------------- /examples/locale-router-static/svelte.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | import adapter from '@sveltejs/adapter-static'; 4 | import lang from './src/lib/translations/lang.js'; 5 | 6 | const supportedLocales = Object.keys(lang); 7 | 8 | /** @type {import('@sveltejs/kit').Config} */ 9 | const config = { 10 | kit: { 11 | adapter: adapter(), 12 | prerender: { 13 | // NOTE: You can modify your exported error pages here. 14 | entries: supportedLocales.reduce((acc, locale) => [...acc, `/${locale}`, `/${locale}/401`, `/${locale}/403`, `/${locale}/404`, `/${locale}/500`], ['*']), 15 | }, 16 | }, 17 | }; 18 | 19 | export default config; 20 | -------------------------------------------------------------------------------- /examples/locale-param/README.md: -------------------------------------------------------------------------------- 1 | [](https://app.netlify.com/sites/locale-param/deploys) 2 | 3 | # Locale-param 4 | This `multi-page` app demonstrates lang routing based on URL parameter (e.g. `https://example.com/?lang=en`). 5 | 6 | ## Preview 7 | You can view this demo live on [Netlify](https://locale-param.netlify.app). 8 | 9 | ## How to use this example 10 | 11 | - Download this example 12 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.) 13 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.) -------------------------------------------------------------------------------- /examples/component-scoped-ssr/src/lib/component/index.svelte: -------------------------------------------------------------------------------- 1 | 4 | 5 | 10 | 11 |{$t('common.info')}
14 | 15 | 20 |({ parserOptions = {}, ...rest }: Config
) => ({
10 | ...rest,
11 | parser: parser(parserOptions),
12 | });
13 |
14 | class I18n ) {
16 | super(config && normalizeConfig(config));
17 | }
18 |
19 | loadConfig = (config: Config ) => super.configLoader(normalizeConfig (config));
20 | }
21 |
22 | export default I18n;
23 |
--------------------------------------------------------------------------------
/.github/workflows/tests.yml:
--------------------------------------------------------------------------------
1 | name: Tests
2 |
3 | on:
4 | workflow_call:
5 | workflow_dispatch:
6 | pull_request:
7 | types: [opened,reopened,synchronize]
8 | push:
9 | branches:
10 | - master
11 |
12 | jobs:
13 | Tests:
14 | runs-on: ${{ matrix.os }}
15 | strategy:
16 | matrix:
17 | node-version: [22]
18 | os: [ubuntu-latest, windows-latest, macOS-latest]
19 |
20 | steps:
21 | - uses: actions/checkout@v3
22 |
23 | - uses: pnpm/action-setup@v2
24 | with:
25 | version: 10
26 |
27 | - uses: actions/setup-node@v3
28 | with:
29 | node-version: ${{ matrix.node-version }}
30 | cache: 'pnpm'
31 |
32 | - name: Install Dependencies
33 | run: pnpm install
34 |
35 | - run: pnpm run test
36 | env:
37 | tests: true
38 |
--------------------------------------------------------------------------------
/examples/multi-page/README.md:
--------------------------------------------------------------------------------
1 | [](https://app.netlify.com/sites/multi-page-example/deploys)
2 |
3 | # Multi-page app
4 | In this app, translations are loaded dynamically according to user navigation and `$locale` change. It has built-in mechanism to prevent duplicit (server and client) translation load on app enter. It's useful, when you are fetching your translations from remote API, or using other data-expensive solution.
5 |
6 | ## Preview
7 | You can view this demo live on [Netlify](https://multi-page-example.netlify.app).
8 |
9 | ## How to use this example
10 |
11 | - Download this example
12 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.)
13 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.)
--------------------------------------------------------------------------------
/examples/component-scoped-csr/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
24 |
25 | {@html $t('home.text', { link })} {$t('content.plural', { value: number })} {$t('content.number', { value: number * currencyRatio[$locale] })} {$t('content.date', { value: now }, { date: { FULL:{ timeStyle: 'full', dateStyle: 'full' } } })} {$t('content.selectordinal', { value: number })} {$t('common.info')} {@html $tFull('content.0.text', { link })} {$tFull('content.0.something.else')} {@html $tFull('content.1.text')} {$tFull('content.1.something.else')} {@html $tPreserveArrays(`${content.text}`, { link })} {$tPreserveArrays(`${content['something.else']}`)} {@html $tNone(`${content.text}`, { link })} {$tNone(`${content.something.else}`)} {@html $tCustom(`${content.text}`, { link })} {$tCustom(`${content.something.else}`)}{$t('home.title')}
26 |
22 |
23 | {$t('menu.notification', { count })}
24 |
25 |
26 |
27 | {@render children()}
28 |
29 |
30 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "airbnb-typescript/base",
4 | "plugin:svelte/recommended"
5 | ],
6 | "parser": "@typescript-eslint/parser",
7 | "parserOptions": {
8 | "project": "**/tsconfig.json",
9 | "sourceType": "module",
10 | "extraFileExtensions": [
11 | ".svelte"
12 | ]
13 | },
14 | "plugins": [
15 | "import"
16 | ],
17 | "overrides": [
18 | {
19 | "files": [
20 | "*.svelte"
21 | ],
22 | "parser": "svelte-eslint-parser",
23 | "parserOptions": {
24 | "parser": "@typescript-eslint/parser"
25 | }
26 | }
27 | ],
28 | "rules": {
29 | "no-console": 0,
30 | "@typescript-eslint/naming-convention": 0,
31 | "@typescript-eslint/no-redeclare": 0,
32 | "@typescript-eslint/no-shadow": 0,
33 | "no-trailing-spaces": "error",
34 | "no-multiple-empty-lines": "error",
35 | "import/extensions": 0,
36 | "import/no-extraneous-dependencies": 0,
37 | "svelte/no-at-html-tags": 0
38 | },
39 | "settings": {}
40 | }
--------------------------------------------------------------------------------
/examples/multi-page/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
22 |
23 | {$t('menu.notification', { count })}
24 |
25 |
26 |
27 | {@render children()}
28 |
29 |
30 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/examples/component-scoped-csr/src/lib/component/translations/index.js:
--------------------------------------------------------------------------------
1 | import i18n from 'sveltekit-i18n';
2 | import lang from './lang.json';
3 |
4 | /** @type {import('sveltekit-i18n').Config} */
5 | export const config = {
6 | loaders: [
7 | {
8 | locale: 'en',
9 | key: 'lang',
10 | loader: () => lang,
11 | },
12 | {
13 | locale: 'en',
14 | key: 'common',
15 | loader: async () => (await import('./en/common.json')).default,
16 | },
17 | {
18 | locale: 'cs',
19 | key: 'lang',
20 | loader: () => lang,
21 | },
22 | {
23 | locale: 'cs',
24 | key: 'common',
25 | loader: async () => (await import('./cs/common.json')).default,
26 | },
27 | {
28 | locale: 'de',
29 | key: 'lang',
30 | loader: () => lang,
31 | },
32 | {
33 | locale: 'de',
34 | key: 'common',
35 | loader: async () => (await import('./de/common.json')).default,
36 | },
37 | ],
38 | };
39 |
40 | export default () => new i18n(config);
--------------------------------------------------------------------------------
/examples/fallback-locale/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
22 |
23 | {$t('menu.notification', { count })}
24 |
25 |
26 |
27 | {@render children()}
28 |
29 |
30 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/examples/component-scoped-csr/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
22 |
23 | {$t('menu.notification', { count })}
24 |
25 |
26 |
27 | {@render children()}
28 |
29 |
30 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/examples/component-scoped-ssr/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
14 |
15 |
22 |
23 | {$t('menu.notification', { count })}
24 |
25 |
26 |
27 | {@render children()}
28 |
29 |
30 |
31 |
32 |
37 |
--------------------------------------------------------------------------------
/examples/locale-param/src/routes/+layout.svelte:
--------------------------------------------------------------------------------
1 |
11 |
12 |
19 |
20 | {$t('menu.notification', { count })}
21 |
22 |
23 |
24 | {@render children()}
25 |
26 |
27 |
28 |
29 |
34 |
--------------------------------------------------------------------------------
/examples/parser-icu/src/routes/+page.svelte:
--------------------------------------------------------------------------------
1 |
13 |
14 |
27 | {$t('content.select', { value: gender })}
28 |
21 |
22 | {$t('menu.notification', { count })}
23 |
24 |
25 |
26 | {@render children()}
27 |
28 |
29 |
30 |
31 |
36 |
--------------------------------------------------------------------------------
/examples/component-scoped-csr/src/lib/component/index.svelte:
--------------------------------------------------------------------------------
1 |
18 |
19 | {$l(LOCALE, TRANSLATION_KEY)}:',
12 | text: 'Visit kit.svelte.dev to read the documentation',
13 | },
14 | },
15 | cs: {
16 | lang,
17 | menu: {
18 | notification: '{{count:gt; 0:Máte {{count}} {{count:gte; 1:novou zprávu; 2:nové zprávy; 5:nových zpráv}}!; default:Nemáte žádné zprávy...}}',
19 | },
20 | content: {
21 | title: 'Vítejte ve SvelteKit',
22 | info: 'Nyní máte přístup ke všem jazykovým mutacím prostřednictvím {$l(LOCALE, TRANSLATION_KEY)}:',
23 | text: 'Dokumentace je k přečtení na kit.svelte.dev',
24 | },
25 | },
26 | });
--------------------------------------------------------------------------------
/examples/locale-router-advanced/src/routes/[...lang=locale]/+layout.svelte:
--------------------------------------------------------------------------------
1 |
13 |
14 |
21 |
22 | {$t('menu.notification', { count })}
23 |
24 |
25 |
26 | {@render children()}
27 |
28 |
29 |
30 |
31 |
36 |
--------------------------------------------------------------------------------
/tests/data/index.ts:
--------------------------------------------------------------------------------
1 | import type { Config } from '../../src/types';
2 | export { default as getTranslations } from './translations';
3 |
4 | export const CONFIG: Config<
5 | {} /* Add your payload props here */,
6 | {} /* Add your modifier props here */
7 | > = {
8 | initLocale: 'en',
9 | log: {
10 | level: 'error',
11 | },
12 | loaders: [
13 | {
14 | key: 'common',
15 | locale: 'EN',
16 | loader: async () => (await import('../data/translations/en/common.json')).default,
17 | },
18 | {
19 | key: 'route1',
20 | locale: 'EN',
21 | routes: [/./],
22 | loader: async () => (await import('../data/translations/en/route.json')).default,
23 | },
24 | {
25 | key: 'route2',
26 | locale: 'EN',
27 | routes: ['/path#hash?a=b&c=d'],
28 | loader: async () => (await import('../data/translations/en/route.json')).default,
29 | },
30 | {
31 | key: 'common',
32 | locale: 'zh-Hans',
33 | loader: async () => (await import('../data/translations/zh-Hans/common.json')).default,
34 | },
35 | ],
36 | };
--------------------------------------------------------------------------------
/examples/parser-icu/src/lib/translations/index.ts:
--------------------------------------------------------------------------------
1 | import i18n from '@sveltekit-i18n/base';
2 | import parser from '@sveltekit-i18n/parser-icu';
3 |
4 | import type { Config } from '@sveltekit-i18n/parser-icu';
5 |
6 | import lang from './lang.json';
7 |
8 | const config: Config<{/* Translation payload props */}> = {
9 | initLocale: 'en',
10 |
11 | parser: parser(),
12 |
13 | translations: {
14 | en: { lang },
15 | cs: { lang },
16 | },
17 |
18 | loaders: [
19 | {
20 | locale: 'en',
21 | key: 'content',
22 | loader: async () => (await import('./en/content.json')).default,
23 | },
24 | {
25 | locale: 'cs',
26 | key: 'content',
27 | loader: async () => (await import('./cs/content.json')).default,
28 | },
29 | ],
30 | };
31 |
32 | export const { t, loading, locales, locale, translations } = new i18n(config);
33 |
34 | loading.subscribe(async ($loading) => {
35 | if ($loading) {
36 | console.log('Loading translations...');
37 | await loading.toPromise();
38 | console.log('Updated translations', translations.get());
39 | }
40 | });
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 sveltekit-i18n
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
--------------------------------------------------------------------------------
/examples/component-scoped-csr/src/routes/+layout.server.js:
--------------------------------------------------------------------------------
1 | import { locales, loadTranslations, translations, defaultLocale } from '$lib/translations';
2 |
3 | /** @type {import('@sveltejs/kit').ServerLoad} */
4 | export const load = async ({ url, cookies, request }) => {
5 | const { pathname } = url;
6 |
7 | // Try to get the locale from cookie
8 | let locale = (cookies.get('lang') || '').toLowerCase();
9 |
10 | // Get user preferred locale
11 | if (!locale) {
12 | locale = `${`${request.headers.get('accept-language')}`.match(/[a-zA-Z]+?(?=-|_|,|;)/)}`.toLowerCase();
13 | }
14 |
15 | // Get defined locales
16 | const supportedLocales = locales.get().map((l) => l.toLowerCase());
17 |
18 | // Use default locale if current locale is not supported
19 | if (!supportedLocales.includes(locale)) {
20 | locale = defaultLocale;
21 | }
22 |
23 | await loadTranslations(locale, pathname); // keep this just before the `return`
24 |
25 | return {
26 | i18n: { locale, route: pathname },
27 | translations: translations.get(), // `translations` on server contain all translations loaded by different clients
28 | };
29 | };
--------------------------------------------------------------------------------
/examples/component-scoped-ssr/src/routes/+layout.server.js:
--------------------------------------------------------------------------------
1 | import { locales, loadTranslations, translations, defaultLocale } from '$lib/translations';
2 |
3 | /** @type {import('@sveltejs/kit').ServerLoad} */
4 | export const load = async ({ url, cookies, request }) => {
5 | const { pathname } = url;
6 |
7 | // Try to get the locale from cookie
8 | let locale = (cookies.get('lang') || '').toLowerCase();
9 |
10 | // Get user preferred locale
11 | if (!locale) {
12 | locale = `${`${request.headers.get('accept-language')}`.match(/[a-zA-Z]+?(?=-|_|,|;)/)}`.toLowerCase();
13 | }
14 |
15 | // Get defined locales
16 | const supportedLocales = locales.get().map((l) => l.toLowerCase());
17 |
18 | // Use default locale if current locale is not supported
19 | if (!supportedLocales.includes(locale)) {
20 | locale = defaultLocale;
21 | }
22 |
23 | await loadTranslations(locale, pathname); // keep this just before the `return`
24 |
25 | return {
26 | i18n: { locale, route: pathname },
27 | translations: translations.get(), // `translations` on server contain all translations loaded by different clients
28 | };
29 | };
--------------------------------------------------------------------------------
/examples/parser-default/README.md:
--------------------------------------------------------------------------------
1 | [](https://app.netlify.com/sites/parser-default/deploys)
2 |
3 | # @sveltekit-i18n/parser-default
4 | This app demonstrates features of the [@sveltekit-i18n/parser-default](https://github.com/sveltekit-i18n/parsers/blob/master/parser-default). It includes an overview of [placeholders](https://github.com/sveltekit-i18n/parsers/blob/master/parser-default/README.md#placeholders), [built-in modifiers](https://github.com/sveltekit-i18n/parsers/blob/master/parser-default/README.md#modifiers) and [custom modifiers](https://github.com/sveltekit-i18n/parsers/blob/master/parser-default/README.md#options).
5 |
6 | ## Preview
7 | You can view this demo live on [Netlify](https://parser-default.netlify.app).
8 |
9 | ## How to use this example
10 |
11 | - Download this example
12 | - Run `cd ./parser-default/` in Terminal to navigate to example's folder
13 | - Run `npm i` to install all dependencies (or `pnpm i`, `yarn`, etc.)
14 | - Run `npm run dev -- --open` to preview (or `pnpm run dev -- --open`, `yarn dev --open`, etc.)
15 |
--------------------------------------------------------------------------------
/examples/loaders/src/routes/+layout.server.js:
--------------------------------------------------------------------------------
1 | import { locales, loadTranslations, translations, defaultLocale } from '$lib/translations';
2 |
3 | /** @type {import('@sveltejs/kit').ServerLoad} */
4 | export const load = async ({ url, cookies, request }) => {
5 | const { pathname, search } = url;
6 |
7 | // Try to get the locale from cookie
8 | let locale = (cookies.get('lang') || '').toLowerCase();
9 |
10 | // Get user preferred locale
11 | if (!locale) {
12 | locale = `${`${request.headers.get('accept-language')}`.match(/[a-zA-Z]+?(?=-|_|,|;)/)}`.toLowerCase();
13 | }
14 |
15 | // Get defined locales
16 | const supportedLocales = locales.get().map((l) => l.toLowerCase());
17 |
18 | // Use default locale if current locale is not supported
19 | if (!supportedLocales.includes(locale)) {
20 | locale = defaultLocale;
21 | }
22 |
23 | const route = `${pathname}${search}`;
24 |
25 | await loadTranslations(locale, route); // keep this just before the `return`
26 |
27 | return {
28 | i18n: { locale, route },
29 | translations: translations.get(), // `translations` on server contain all translations loaded by different clients
30 | };
31 | };
--------------------------------------------------------------------------------
/examples/locale-router-static/src/routes/[lang]/+layout.svelte:
--------------------------------------------------------------------------------
1 |
13 |
14 |
21 |
22 | {$t('menu.notification', { count })}
23 |
24 |
25 |
26 | {@render children()}
27 |
28 |
29 |
30 |
31 |
41 |
--------------------------------------------------------------------------------
/tests/utils/index.ts:
--------------------------------------------------------------------------------
1 | export const filterTranslationKeys = (localeTranslation: any, keys: string[]) => keys.reduce((a, key) => ({
2 | ...a,
3 | ...Object.keys(localeTranslation).filter((k: string) => `${k}`.startsWith(`${key}.`)).reduce((acc, k) => ({ ...acc, [k]: localeTranslation[k] }), {}),
4 | }),
5 | {},
6 | );
7 |
8 | export module DotNotation {
9 | export type Input = RecordFull preprocessing (default)
14 |
15 |
16 | {JSON.stringify($translationsFull, null, 2)}
17 |
18 |
19 | {$tFull('content.0.title')}
20 |
23 |
24 | {$tFull('content.1.title')}
25 |
28 |
29 |
30 |
31 | Arrays preserved
32 |
33 |
34 | {JSON.stringify($translationsPreserveArrays, null, 2)}
35 |
36 |
37 | {#each $tPreserveArrays('content', { default: [] }) as content}
38 | {$tPreserveArrays(`${content.title}`)}
39 |
42 | {/each}
43 |
44 |
45 |
46 | No preprocessing
47 |
48 |
49 | {JSON.stringify($translationsNone, null, 2)}
50 |
51 |
52 | {#each $tNone('content', { default: [] }) as content}
53 | {$tNone(`${content.title}`)}
54 |
57 | {/each}
58 |
59 |
60 |
61 | Custom preprocessing
62 |
63 |
64 | {JSON.stringify($translationsCustom, null, 2)}
65 |
66 |
67 | {#each $tCustom('content', { default: [] }) as content}
68 | {$tCustom(`${content.title}`)}
69 |
72 | {/each}
73 |
74 |
--------------------------------------------------------------------------------