locale for web app (#334)

* locale for web app

* more translations

* Rename profiles service to avoid locale conflict

* More translation work

* Lint fix

---------

Co-authored-by: github-action linter <githubaction@githubaction.com>
This commit is contained in:
Brahim Hadricheandgithub-action linter authored and GitHub committed 2024-03-22 17:43:03 -04:00
1 parent 019fde1e67
commit 42dadec020
54 files changed
+538 -151

No files matched your search

@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
import { tr, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -23,7 +23,7 @@
<div class="form-control m-5">
<label class="label p-0 cursor-pointer">
<div class="label-text {textSizes[level]}">{displayText}</div>
<div class="label-text {textSizes[level]}">{$tr(displayText)}</div>
<input
type="checkbox"
name={key}
@@ -32,5 +32,5 @@
class="checkbox"
/>
</label>
<div class="text-xs text-gray-500">{@html description}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
</div>
@@ -1,6 +1,7 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { searchHistoryStore } from "lib/Stores";
import { searchHistoryStore, tr } from "lib/Stores";
import { get } from "svelte/store";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -13,14 +14,15 @@
async function clearSeachHistory() {
await PlayletApi.clearSearchHistory();
searchHistoryStore.set([]);
alert("Search history cleared.");
alert(get(tr)("Search history cleared."));
}
</script>
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<div class={textSizes[level]}>{$tr(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
<button class="btn m-1" on:click={clearSeachHistory}
>Clear search history</button
>{$tr("Clear search history")}</button
>
</div>
@@ -2,6 +2,7 @@
import {
homeLayoutFileStore,
homeLayoutStore,
tr,
userPreferencesStore,
} from "lib/Stores";
import ArrowUpIcon from "assets/remote-control/arrow-up.svg.svelte";
@@ -84,10 +85,10 @@
</script>
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<div class={textSizes[level]}>{$tr(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
<button class="btn m-1" on:click={openHomeScreenEditor}
>Edit home screen</button
>{$tr("Edit home screen")}</button
>
</div>
@@ -110,7 +111,7 @@
</td>
<td>
<label class="label p-0 cursor-pointer">
<div class="label-text">{homeLayout[item.id].title}</div>
<div class="label-text">{$tr(homeLayout[item.id].title)}</div>
<input
type="checkbox"
name={item.id}
@@ -134,12 +135,12 @@
{/each}
</table>
<form method="dialog" class="flex justify-center space-x-2">
<button class="btn btn-primary" on:click={save}>Save</button>
<button class="btn btn-primary">Close</button>
<button class="btn btn-primary" on:click={save}>{$tr("Save")}</button>
<button class="btn btn-primary">{$tr("Close")}</button>
</form>
{/if}
</div>
<form method="dialog" class="modal-backdrop">
<button>Close</button>
<button>{$tr("Close")}</button>
</form>
</dialog>
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
import { tr, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
export let displayText: string = "";
export let key: string = "";
@@ -21,7 +21,7 @@
<div class="form-control m-5">
<label class="label p-0 cursor-pointer">
<div class="label-text {textSizes[level]}">{displayText}</div>
<div class="label-text {textSizes[level]}">{$tr(displayText)}</div>
<div class="join mt-2 mb-2">
<button
class="join-item btn btn-sm btn-primary"
@@ -52,5 +52,5 @@
</button>
</div>
</label>
<div class="text-xs text-gray-500">{@html description}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
</div>
@@ -1,8 +1,9 @@
<script lang="ts">
import { onMount } from "svelte";
import { PlayletApi } from "lib/Api/PlayletApi";
import { playletStateStore } from "lib/Stores";
import { playletStateStore, tr } from "lib/Stores";
import { ExternalControlProtocol } from "lib/Api/ExternalControlProtocol";
import { get } from "svelte/store";
let selectedRelease = "";
let releases = [];
@@ -65,23 +66,31 @@
if (version === "") {
version = "latest";
}
const trFn = get(tr);
if (
confirm(
`Are you sure you want to change the Playlet Library version to "${version}"?\nThis will restart Playlet.`
)
trFn(
"Are you sure you want to change the Playlet Library version to %1"
).replace("%1", version)
) +
`\n` +
trFn("This will restart Playlet.")
) {
await PlayletApi.setPlayletLibVersion(selectedRelease);
alert("Playlet Library version set. Playlet will now restart.");
alert(trFn("Playlet Library version changed. Playlet will now restart."));
await ExternalControlProtocol.restartApp(appId);
}
}
</script>
<div class="m-5">
<div class="text-lg">Playlet Library version</div>
<div class="text-lg">{$tr("Playlet Library version")}</div>
<div class="text-xs text-gray-500">
The version of Playlet Lib to use. These correspond to tagged releases on
Github. Releases that do not have a playlet-lib.zip file are disabled.
{$tr(
"The version of Playlet Lib to use. These correspond to tagged releases on Github. Releases that do not have a playlet-lib.zip file are disabled."
)}
</div>
<div class="join w-full m-1">
@@ -89,13 +98,13 @@
bind:value={selectedRelease}
class="select select-bordered join-item w-full mr-1"
>
<option selected value="">latest (default)</option>
<option selected value=""></option>
{#each releases as release}
<option disabled={!release.enabled} value={release.name}
>{release.name}</option
>
{/each}
</select>
<button class="join-item btn" on:click={apply}>Apply</button>
<button class="join-item btn" on:click={apply}>{$tr("Apply")}</button>
</div>
</div>
@@ -1,6 +1,6 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
import { tr, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
@@ -24,13 +24,13 @@
</script>
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<div class={textSizes[level]}>{$tr(displayText)}</div>
<div class="text-xs text-gray-500">{@html $tr(description)}</div>
{#each options as option}
<div class="form-control">
<label class="label cursor-pointer">
<span class="label-text">{option.displayText}</span>
<span class="label-text">{$tr(option.displayText)}</span>
<input
type="radio"
name={key}
@@ -1,8 +1,9 @@
<script lang="ts">
import { PlayletApi } from "lib/Api/PlayletApi";
import { userPreferencesStore } from "lib/Stores";
import { tr, userPreferencesStore } from "lib/Stores";
const textSizes = ["text-2xl", "text-lg", "text-base", "text-sm", "text-xs"];
const invidiousPublicInstancesLink = `<a class="link" href="https://api.invidious.io" target="_blank" rel="noopener noreferrer">https://api.invidious.io</a>`;
export let displayText: string = "";
export let key: string = "";
@@ -26,8 +27,14 @@
</script>
<div class="m-5">
<div class={textSizes[level]}>{displayText}</div>
<div class="text-xs text-gray-500">{@html description}</div>
<div class={textSizes[level]}>{$tr(displayText)}</div>
<div class="text-xs text-gray-500">
<!-- TODO:P2 this should not be hardcoded here -->
{@html $tr(description).replace(
"$INVIDIOUS_PUBLIC_INSTANCES",
invidiousPublicInstancesLink
)}
</div>
<div class="join w-full m-1">
<input
@@ -38,7 +45,7 @@
class="join-item input w-full mr-1"
/>
{#if inputValue !== currentValue}
<button class="join-item btn" on:click={save}>Save</button>
<button class="join-item btn" on:click={save}>{$tr("Save")}</button>
{/if}
</div>
</div>