-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Settings: Allow to change UI language
- Loading branch information
1 parent
357daa0
commit 597bf47
Showing
5 changed files
with
111 additions
and
14 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,14 +1,49 @@ | ||
<vbox class="appearance"> | ||
<DarkMode /> | ||
<HeaderGroupBox> | ||
<hbox slot="header">{$t`Dark mode`}</hbox> | ||
<DarkMode /> | ||
</HeaderGroupBox> | ||
|
||
<HeaderGroupBox> | ||
<hbox slot="header">{$t`Language`}</hbox> | ||
<hbox> | ||
<LanguageDropDown bind:language /> | ||
{#if language != getUILocale()} | ||
<Button | ||
label="Save and restart" | ||
icon={RestartIcon} | ||
on:click={onChangeLanguage} | ||
classes="restart" | ||
/> | ||
{/if} | ||
</hbox> | ||
</HeaderGroupBox> | ||
</vbox> | ||
|
||
<script lang="ts"> | ||
import { getUILocale, saveUILocale, setUILocale, t } from "../../../l10n/l10n"; | ||
import { appGlobal } from "../../../logic/app"; | ||
import DarkMode from "./DarkMode.svelte"; | ||
import LanguageDropDown from "./LanguageDropDown.svelte"; | ||
import HeaderGroupBox from "../../Shared/HeaderGroupBox.svelte"; | ||
import Button from "../../Shared/Button.svelte"; | ||
import RestartIcon from "lucide-svelte/icons/rotate-ccw"; | ||
let language = getUILocale(); | ||
async function onChangeLanguage() { | ||
saveUILocale(language); | ||
setUILocale(language); | ||
await appGlobal.remoteApp.restartApp(); // unfortunately needed for the strings in ts modules | ||
} | ||
</script> | ||
|
||
<style> | ||
.appearance :global(.darkmode svg) { | ||
width: 32px; | ||
height: 32px; | ||
} | ||
.appearance :global(.restart) { | ||
margin-left: 24px; | ||
} | ||
</style> |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<select bind:value={language} on:change> | ||
{#each Object.keys(localeNames) as langCode } | ||
<option value={langCode}> | ||
{localeNames[langCode]} | ||
</option> | ||
{/each} | ||
</select> | ||
|
||
<script lang="ts"> | ||
import { localeNames } from "../../../l10n/list"; | ||
/** 2-letter ISO language code. in/out */ | ||
export let language: string; | ||
</script> | ||
|
||
<style> | ||
</style> |
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,9 +1,33 @@ | ||
export const sourceLocale = 'en'; | ||
|
||
/* List of languages, as shown in the settings UI. | ||
* Do *not* translate these. | ||
* (Otherwise, if you do cannot read Chinese, you cannot find German anymore.) | ||
* Lang codes: <https://www.wikiwand.com/en/List_of_ISO_639_language_codes> */ | ||
export const localeNames = { | ||
'ar': "Arabic / اَلْعَرَبِيَّةُ", | ||
'cs': "Czech / Čeština", | ||
'da': "Danish / Dansk", | ||
'de': "German / Deutsch", | ||
'el': "Greek / Ελληνικά", | ||
'en': "English", | ||
'es': "Spanish / Español", | ||
'fi': "Finnish / Suomi", | ||
'fr': "French / Français", | ||
'it': "Italian / Italiano", | ||
'ja': "Japanese / 日本語", | ||
'nl': "Dutch / Nederlands", | ||
'no': "Norwegian / Norsk", | ||
'pl': "Polish / Polski", | ||
'pt': "Portuguese / Português", | ||
'ro': "Romanian / Românește", | ||
'ru': "Russian / Русский язык", | ||
'sv': "Swedish / Svenska", | ||
'uk': "Ukranian / Українська", | ||
'zh': "Simplified Chinese (Taiwan) / 简体中文", | ||
}; | ||
|
||
/** List of available locales in this build. | ||
* Must match ./locales/<locale>/* files and | ||
* the imports in ./l10n.ts. | ||
* Lang codes: <https://www.wikiwand.com/en/List_of_ISO_639_language_codes> */ | ||
export const locales = [ | ||
'ar', 'cs', 'da', 'de', 'el', 'en', 'es', 'fi', 'fr', | ||
'it', 'ja', 'nl', 'no', 'pl', 'pt', 'ro', 'ru', 'sv', 'uk', 'zh' | ||
]; | ||
export const sourceLocale = 'en'; | ||
* the imports in ./l10n.ts. */ | ||
export const locales = Object.keys(localeNames); |
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