Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jarda-svoboda committed Jul 10, 2023
1 parent bb4d3e4 commit 79b1966
Show file tree
Hide file tree
Showing 57 changed files with 3,270 additions and 3,073 deletions.
1 change: 0 additions & 1 deletion examples/component-scoped-csr/.npmrc

This file was deleted.

5 changes: 5 additions & 0 deletions examples/component-scoped-csr/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/7e679fc0-9808-4677-be27-fdeccdd6449f/deploy-status)](https://app.netlify.com/sites/component-scoped-csr/deploys)

# Component-scoped app
This app includes multiple instances of `sveltekit-i18n`.

- app translations are loaded using SSR
- component's translations are loaded in component promise (CSR - SvelteKit does not provide server side load method for components, so translation loaders are triggered on client side only)

This approach is good for more complex apps.

## Preview
You can view this demo live on [Netlify](https://compoent-scoped-csr.netlify.app).
1 change: 0 additions & 1 deletion examples/component-scoped-ssr/.npmrc

This file was deleted.

5 changes: 5 additions & 0 deletions examples/component-scoped-ssr/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/7b79a988-ea49-40a0-bad9-842312b1c647/deploy-status)](https://app.netlify.com/sites/component-scoped-ssr/deploys)

# Component-scoped app (SSR)
This app includes multiple instances of `sveltekit-i18n`.

Expand All @@ -6,3 +8,6 @@ This app includes multiple instances of `sveltekit-i18n`.
- after the load, appropriate props are delegated back to the component instance.

This approach is good for more complex apps.

## Preview
You can view this demo live on [Netlify](https://component-scoped-ssr.netlify.app).
8 changes: 0 additions & 8 deletions examples/duplicit-load-prevention/.gitignore

This file was deleted.

1 change: 0 additions & 1 deletion examples/duplicit-load-prevention/.npmrc

This file was deleted.

4 changes: 0 additions & 4 deletions examples/duplicit-load-prevention/README.md

This file was deleted.

3 changes: 0 additions & 3 deletions examples/duplicit-load-prevention/jsconfig.json

This file was deleted.

5 changes: 0 additions & 5 deletions examples/duplicit-load-prevention/netlify.toml

This file was deleted.

21 changes: 0 additions & 21 deletions examples/duplicit-load-prevention/package.json

This file was deleted.

16 changes: 0 additions & 16 deletions examples/duplicit-load-prevention/src/app.html

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

54 changes: 0 additions & 54 deletions examples/duplicit-load-prevention/src/lib/translations/index.js

This file was deleted.

This file was deleted.

14 changes: 0 additions & 14 deletions examples/duplicit-load-prevention/src/routes/+layout.js

This file was deleted.

24 changes: 0 additions & 24 deletions examples/duplicit-load-prevention/src/routes/+layout.svelte

This file was deleted.

8 changes: 0 additions & 8 deletions examples/duplicit-load-prevention/src/routes/+page.svelte

This file was deleted.

This file was deleted.

Binary file removed examples/duplicit-load-prevention/static/favicon.png
Binary file not shown.
10 changes: 0 additions & 10 deletions examples/duplicit-load-prevention/svelte.config.js

This file was deleted.

6 changes: 0 additions & 6 deletions examples/duplicit-load-prevention/vite.config.js

This file was deleted.

1 change: 0 additions & 1 deletion examples/fallback-locale/.npmrc

This file was deleted.

5 changes: 5 additions & 0 deletions examples/fallback-locale/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/897bc245-3432-44a8-8a4b-26c6a61f2d5f/deploy-status)](https://app.netlify.com/sites/fallback-locale/deploys)

# Fallback locale
This app shows how to use `config.fallbackLocale` parameter.

## Preview
You can view this demo live on [Netlify](https://fallback-locale.netlify.app).
1 change: 0 additions & 1 deletion examples/locale-router-advanced/.npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion examples/locale-router-advanced/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/bcefda87-9dad-4c73-bf5f-d9b4c03cac9c/deploy-status)](https://locale-router-advanced.netlify.app)
[![Netlify Status](https://api.netlify.com/api/v1/badges/bcefda87-9dad-4c73-bf5f-d9b4c03cac9c/deploy-status)](https://app.netlify.com/sites/locale-router-advanced/deploys)

# Locale-router-advanced
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. The default language (`en`) has no lang prefix in URL path.
Expand Down
1 change: 0 additions & 1 deletion examples/locale-router-static/.npmrc

This file was deleted.

7 changes: 6 additions & 1 deletion examples/locale-router-static/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/d9f3cafa-1da9-41ce-a20d-885e9a668c1d/deploy-status)](https://app.netlify.com/sites/locale-router-static/deploys)

# Locale-router-static
This app shows how to integrate locale routing using `@sveltejs/adapter-static`. It includes two pages and three language mutations (`en`, `de`, `cs`). Error pages are included as well.

## Setup
## Preview
You can view this demo live on [Netlify](https://locale-router-static.netlify.app).

## Noticeable files

### `./svelte.config.js`
This config contains `prerender` object to build your site's language mutations together with desired error pages.
Expand Down
1 change: 0 additions & 1 deletion examples/locale-router/.npmrc

This file was deleted.

2 changes: 1 addition & 1 deletion examples/locale-router/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/474b5633-14d8-4e1b-846f-f122f2ad4c25/deploy-status)](https://locale-router.netlify.app)
[![Netlify Status](https://api.netlify.com/api/v1/badges/474b5633-14d8-4e1b-846f-f122f2ad4c25/deploy-status)](https://app.netlify.com/sites/locale-router/deploys)

# Locale-router
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.
Expand Down
1 change: 0 additions & 1 deletion examples/multi-page/.npmrc

This file was deleted.

7 changes: 5 additions & 2 deletions examples/multi-page/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Netlify Status](https://api.netlify.com/api/v1/badges/c5bbe5c2-c9b9-4175-aa68-fd4aec778589/deploy-status)](https://app.netlify.com/sites/multi-page-example/deploys)

# Multi-page app
In this app, translations are loaded dynamically according to user navigation and `$locale` change.
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.

This concept is great for most of web pages.
## Preview
You can view this demo live on [Netlify](https://multi-page-example.netlify.app).
10 changes: 0 additions & 10 deletions examples/multi-page/src/app.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion examples/multi-page/src/app.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!DOCTYPE html>
<html lang="en">
<html>

<head>
<meta charset="utf-8" />
Expand Down
6 changes: 5 additions & 1 deletion examples/multi-page/src/lib/translations/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import i18n from 'sveltekit-i18n';
import { dev } from '$app/environment';
import lang from './lang.json';

/** @type {import('sveltekit-i18n').Config} */
export const config = {
log: {
level: dev ? 'warn' : 'error',
},
translations: {
en: { lang },
cs: { lang },
Expand Down Expand Up @@ -45,6 +49,6 @@ export const config = {
],
};

export const { t, loading, locales, locale, loadTranslations } = new i18n(config);
export const { t, loading, locales, locale, translations, loadTranslations, addTranslations, setLocale, setRoute } = new i18n(config);

loading.subscribe(($loading) => $loading && console.log('Loading translations...'));
Loading

0 comments on commit 79b1966

Please sign in to comment.