enhancement: Added Localization to the app

Added Localization to the app (English, Spanish)
Users can add translations in .json format in the /src/lib/lang folder and then register them in the I18n Svelte component
Maybe someone knows how to dinamically load everything in the /lang folder so you don't need to register them manually
Some strings are still missing to be updated, I'm setting up my environment to have Radarr, Sonarr and Jellyfin
Followed this guide to add Localization to Reiverr: https://phrase.com/blog/posts/a-step-by-step-guide-to-svelte-localization-with-svelte-i18n-v3/
This commit is contained in:
Axel Aguilar
2023-08-12 11:45:42 -06:00
parent eb023b811e
commit c6e19cbc93
14 changed files with 339 additions and 61 deletions

View File

@@ -6,6 +6,7 @@
import IconButton from '../IconButton.svelte';
import { fade } from 'svelte/transition';
import { modalStack } from '../Modal/Modal';
import { _ } from 'svelte-i18n';
let y = 0;
let transparent = true;
@@ -58,11 +59,11 @@
<div
class="flex items-center justify-center gap-4 md:gap-8 font-normal text-sm tracking-wider text-zinc-200"
>
<a href="/" class={$page && getLinkStyle('/')}>Home</a>
<a href="/discover" class={$page && getLinkStyle('/discover')}>Discover</a>
<a href="/library" class={$page && getLinkStyle('/library')}>Library</a>
<a href="/sources" class={$page && getLinkStyle('/sources')}>Sources</a>
<a href="/settings" class={$page && getLinkStyle('/settings')}>Settings</a>
<a href="/" class={$page && getLinkStyle('/')}>{$_('navbarHome')}</a>
<a href="/discover" class={$page && getLinkStyle('/discover')}>{$_('navbarDiscover')}</a>
<a href="/library" class={$page && getLinkStyle('/library')}>{$_('navbarLibrary')}</a>
<a href="/sources" class={$page && getLinkStyle('/sources')}>{$_('navbarSources')}</a>
<a href="/settings" class={$page && getLinkStyle('/settings')}>{$_('navbarSettings')}</a>
</div>
<div class="flex gap-2 items-center">
<IconButton on:click={openSearchModal}>

View File

@@ -8,6 +8,7 @@
import ModalHeader from '../Modal/ModalHeader.svelte';
import { onMount } from 'svelte';
import type { TitleType } from '$lib/types';
import { _ } from 'svelte-i18n';
export let modalId: Symbol;
@@ -75,13 +76,15 @@
on:input={handleInput}
type="text"
class="flex-1 bg-transparent font-light outline-none"
placeholder="Search for Movies and Shows..."
placeholder={$_('searchModalPlaceholder')}
/>
</ModalHeader>
{#if resultProps === undefined || inputValue === ''}
<div class="text-sm text-zinc-200 opacity-50 font-light p-4">No recent searches</div>
<div class="text-sm text-zinc-200 opacity-50 font-light p-4">
{$_('searchNoRecentSearches')}
</div>
{:else if resultProps?.length === 0 && !fetching}
<div class="text-sm text-zinc-200 opacity-50 font-light p-4">No search results</div>
<div class="text-sm text-zinc-200 opacity-50 font-light p-4">{$_('searchNoResults')}</div>
{:else}
<div class="py-2">
{#each resultProps.slice(0, 5) as result}