feat: include a language switcher
This also sets the direction of layout. I hope to be able to spot design implementation failures faster this way. Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>
This commit is contained in:
parent
20a44974d5
commit
b3acfe0331
4 changed files with 27 additions and 4 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "anvil",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "anvil",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"devDependencies": {
|
||||
"@playwright/test": "1.41.2",
|
||||
"@skeletonlabs/skeleton": "2.8.0",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "anvil",
|
||||
"version": "0.0.3",
|
||||
"version": "0.0.4",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
|
|
|
@ -3,10 +3,19 @@ import { init, register } from 'svelte-i18n';
|
|||
|
||||
const defaultLocale = 'en';
|
||||
|
||||
register('en', () => import('./locales/en.json'));
|
||||
register('de', () => import('./locales/de.json'));
|
||||
register('en', () => import('./locales/en.json'));
|
||||
register('he', () => import('./locales/he.json'));
|
||||
|
||||
init({
|
||||
fallbackLocale: defaultLocale,
|
||||
initialLocale: browser ? window.navigator.language : defaultLocale
|
||||
});
|
||||
|
||||
export function mapLocaleToDir(locale: 'de' | 'en' | 'he'): 'ltr' | 'rtl' {
|
||||
if (['he'].includes(locale)) {
|
||||
return 'rtl';
|
||||
}
|
||||
|
||||
return 'ltr';
|
||||
}
|
||||
|
|
|
@ -7,6 +7,15 @@
|
|||
// Most of your app wide CSS should be put in this file
|
||||
import '../app.postcss';
|
||||
import { AppShell, AppBar } from '@skeletonlabs/skeleton';
|
||||
import { locale, locales } from 'svelte-i18n';
|
||||
|
||||
import { mapLocaleToDir } from '$lib/i18n';
|
||||
|
||||
locale.subscribe((l) => {
|
||||
if (typeof document !== 'undefined') {
|
||||
document.dir = mapLocaleToDir(l);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- App Shell -->
|
||||
|
@ -18,6 +27,11 @@
|
|||
<strong class="text-xl">Anvil</strong>
|
||||
</svelte:fragment>
|
||||
<svelte:fragment slot="trail">
|
||||
<select bind:value={$locale} class="select">
|
||||
{#each $locales as locale}
|
||||
<option value={locale}>{locale}</option>
|
||||
{/each}
|
||||
</select>
|
||||
<a
|
||||
class="btn btn-sm variant-ghost-surface"
|
||||
href="https://matrix.to/#/#general-forgefed:matrix.batsense.net"
|
||||
|
|
Loading…
Reference in a new issue