-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
af91eea
commit df6d904
Showing
5 changed files
with
70 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
{ | ||
"$schema": "https://inlang.com/schema/project-settings", | ||
"sourceLanguageTag": "en", | ||
"languageTags": [ | ||
"en", | ||
"fr" | ||
], | ||
"modules": [ | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js" | ||
], | ||
"plugin.inlang.messageFormat": { | ||
"pathPattern": "./messages/{languageTag}.json" | ||
} | ||
} | ||
"$schema": "https://inlang.com/schema/project-settings", | ||
"sourceLanguageTag": "en", | ||
"languageTags": ["en", "fr"], | ||
"modules": [ | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-valid-js-identifier@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js", | ||
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js" | ||
], | ||
"plugin.inlang.messageFormat": { | ||
"pathPattern": "./messages/{languageTag}.json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export const LOCALE_MAP = { | ||
'en': { | ||
'name': 'English', | ||
'flag': '🇬🇧' | ||
}, | ||
'fr': { | ||
'name': 'French', | ||
'flag': '🇫🇷' | ||
}, | ||
} | ||
en: { | ||
name: 'English', | ||
flag: '🇬🇧' | ||
}, | ||
fr: { | ||
name: 'French', | ||
flag: '🇫🇷' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,34 @@ | ||
<script> | ||
import { languageTag, onSetLanguageTag, setLanguageTag, sourceLanguageTag } from '$paraglide/runtime'; | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { browser } from '$app/environment'; | ||
import { | ||
languageTag, | ||
onSetLanguageTag, | ||
setLanguageTag, | ||
sourceLanguageTag | ||
} from '$paraglide/runtime'; | ||
import { onDestroy, onMount } from 'svelte'; | ||
import { browser } from '$app/environment'; | ||
onMount(() => { | ||
const valueFromSession = sessionStorage.getItem('lang') || sourceLanguageTag; | ||
// @ts-ignore | ||
setLanguageTag(valueFromSession); | ||
}) | ||
onMount(() => { | ||
const valueFromSession = sessionStorage.getItem('lang') || sourceLanguageTag; | ||
// @ts-ignore | ||
setLanguageTag(valueFromSession); | ||
}); | ||
onDestroy(() => { | ||
if (browser) { | ||
sessionStorage.removeItem('lang'); | ||
} | ||
}) | ||
onDestroy(() => { | ||
if (browser) { | ||
sessionStorage.removeItem('lang'); | ||
} | ||
}); | ||
// initialize the language tag | ||
$: _languageTag = languageTag; | ||
// initialize the language tag | ||
$: _languageTag = languageTag; | ||
onSetLanguageTag((newLanguageTag) => { | ||
// @ts-ignore | ||
_languageTag = newLanguageTag; | ||
}); | ||
onSetLanguageTag((newLanguageTag) => { | ||
// @ts-ignore | ||
_languageTag = newLanguageTag; | ||
}); | ||
</script> | ||
|
||
{#key _languageTag} | ||
<slot></slot> | ||
{/key} | ||
<slot /> | ||
{/key} |