2024-01-07 01:15:25 +01:00
|
|
|
<script lang="ts">
|
2024-02-22 15:36:14 +01:00
|
|
|
import type { ComboBoxOption } from '$lib/components/shared-components/combobox.svelte';
|
|
|
|
|
import SettingCombobox from '$lib/components/shared-components/settings/setting-combobox.svelte';
|
|
|
|
|
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { fallbackLang, fallbackLocale, langs, locales } from '$lib/constants';
|
2024-05-14 21:31:47 +02:00
|
|
|
import {
|
|
|
|
|
alwaysLoadOriginalFile,
|
|
|
|
|
colorTheme,
|
2024-06-04 21:53:00 +02:00
|
|
|
lang,
|
2024-05-14 21:31:47 +02:00
|
|
|
locale,
|
|
|
|
|
loopVideo,
|
|
|
|
|
playVideoThumbnailOnHover,
|
|
|
|
|
showDeleteModal,
|
|
|
|
|
sidebarSettings,
|
|
|
|
|
} from '$lib/stores/preferences.store';
|
2024-02-22 15:36:14 +01:00
|
|
|
import { findLocale } from '$lib/utils';
|
|
|
|
|
import { onMount } from 'svelte';
|
2024-01-07 01:15:25 +01:00
|
|
|
import { fade } from 'svelte/transition';
|
2024-06-04 21:53:00 +02:00
|
|
|
import { t, locale as i18nLocale, init } from 'svelte-i18n';
|
|
|
|
|
import { get } from 'svelte/store';
|
2024-01-07 01:15:25 +01:00
|
|
|
|
2024-02-22 15:36:14 +01:00
|
|
|
let time = new Date();
|
|
|
|
|
|
|
|
|
|
$: formattedDate = time.toLocaleString(editedLocale, {
|
|
|
|
|
year: 'numeric',
|
|
|
|
|
month: '2-digit',
|
|
|
|
|
day: '2-digit',
|
|
|
|
|
});
|
|
|
|
|
$: timePortion = time.toLocaleString(editedLocale, {
|
|
|
|
|
hour: '2-digit',
|
|
|
|
|
minute: '2-digit',
|
|
|
|
|
second: '2-digit',
|
|
|
|
|
});
|
|
|
|
|
$: selectedDate = `${formattedDate} ${timePortion}`;
|
|
|
|
|
$: editedLocale = findLocale($locale).code;
|
|
|
|
|
$: selectedOption = {
|
|
|
|
|
value: findLocale(editedLocale).code || fallbackLocale.code,
|
|
|
|
|
label: findLocale(editedLocale).name || fallbackLocale.name,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onMount(() => {
|
|
|
|
|
const interval = setInterval(() => {
|
|
|
|
|
time = new Date();
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const getAllLanguages = (): ComboBoxOption[] => {
|
|
|
|
|
return locales
|
|
|
|
|
.filter(({ code }) => Intl.NumberFormat.supportedLocalesOf(code).length > 0)
|
|
|
|
|
.map((locale) => ({
|
|
|
|
|
label: locale.name,
|
|
|
|
|
value: locale.code,
|
|
|
|
|
}));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleToggleColorTheme = () => {
|
2024-01-07 01:15:25 +01:00
|
|
|
$colorTheme.system = !$colorTheme.system;
|
|
|
|
|
};
|
2024-02-22 15:36:14 +01:00
|
|
|
|
|
|
|
|
const handleToggleLocaleBrowser = () => {
|
|
|
|
|
$locale = $locale ? undefined : fallbackLocale.code;
|
|
|
|
|
};
|
|
|
|
|
|
2024-06-04 21:53:00 +02:00
|
|
|
const handleLanguageChange = async (newLang: string | undefined) => {
|
|
|
|
|
newLang = newLang || fallbackLang;
|
|
|
|
|
$lang = newLang;
|
|
|
|
|
|
|
|
|
|
const previousLang = get(i18nLocale);
|
|
|
|
|
|
|
|
|
|
if (newLang === 'dev') {
|
|
|
|
|
await init({ fallbackLocale: 'dev', initialLocale: 'dev' });
|
|
|
|
|
} else if (previousLang == 'dev' && newLang !== 'dev') {
|
|
|
|
|
await init({ fallbackLocale: 'en-US', initialLocale: newLang });
|
|
|
|
|
}
|
|
|
|
|
$i18nLocale = newLang;
|
|
|
|
|
};
|
|
|
|
|
|
2024-02-22 15:36:14 +01:00
|
|
|
const handleLocaleChange = (newLocale: string | undefined) => {
|
2024-06-06 13:47:22 +02:00
|
|
|
if (newLocale) {
|
|
|
|
|
$locale = newLocale;
|
|
|
|
|
}
|
2024-02-22 15:36:14 +01:00
|
|
|
};
|
2024-01-07 01:15:25 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<section class="my-4">
|
|
|
|
|
<div in:fade={{ duration: 500 }}>
|
|
|
|
|
<div class="ml-4 mt-4 flex flex-col gap-4">
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('theme_selection')}
|
|
|
|
|
subtitle={$t('theme_selection_description')}
|
2024-01-07 01:15:25 +01:00
|
|
|
bind:checked={$colorTheme.system}
|
2024-02-22 15:36:14 +01:00
|
|
|
on:toggle={handleToggleColorTheme}
|
2024-01-07 01:15:25 +01:00
|
|
|
/>
|
|
|
|
|
</div>
|
2024-02-22 10:14:11 -05:00
|
|
|
|
2024-06-04 21:53:00 +02:00
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingCombobox
|
|
|
|
|
comboboxPlaceholder={$t('language')}
|
|
|
|
|
{selectedOption}
|
|
|
|
|
options={langs.map((lang) => ({ label: lang.name, value: lang.code }))}
|
|
|
|
|
title={$t('language')}
|
|
|
|
|
subtitle={$t('language_setting_description')}
|
|
|
|
|
onSelect={(combobox) => handleLanguageChange(combobox?.value)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2024-02-22 15:36:14 +01:00
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('default_locale')}
|
|
|
|
|
subtitle={$t('default_locale_description')}
|
2024-02-22 15:36:14 +01:00
|
|
|
checked={$locale == undefined}
|
|
|
|
|
on:toggle={handleToggleLocaleBrowser}
|
|
|
|
|
>
|
2024-02-22 19:08:55 +01:00
|
|
|
<p class="mt-2 dark:text-gray-400">{selectedDate}</p>
|
2024-02-22 15:36:14 +01:00
|
|
|
</SettingSwitch>
|
|
|
|
|
</div>
|
|
|
|
|
{#if $locale !== undefined}
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingCombobox
|
2024-06-04 21:53:00 +02:00
|
|
|
comboboxPlaceholder={$t('searching_locales')}
|
2024-02-22 15:36:14 +01:00
|
|
|
{selectedOption}
|
|
|
|
|
options={getAllLanguages()}
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('custom_locale')}
|
|
|
|
|
subtitle={$t('custom_locale_description')}
|
2024-02-22 15:36:14 +01:00
|
|
|
onSelect={(combobox) => handleLocaleChange(combobox?.value)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
{/if}
|
2024-02-22 10:14:11 -05:00
|
|
|
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('display_original_photos')}
|
|
|
|
|
subtitle={$t('display_original_photos_setting_description')}
|
2024-02-22 10:14:11 -05:00
|
|
|
bind:checked={$alwaysLoadOriginalFile}
|
|
|
|
|
on:toggle={() => ($alwaysLoadOriginalFile = !$alwaysLoadOriginalFile)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-11 12:45:01 -04:00
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
|
|
|
|
title="Play video thumbnail on hover"
|
2024-06-04 21:53:00 +02:00
|
|
|
subtitle={$t('video_hover_setting_description')}
|
2024-03-11 12:45:01 -04:00
|
|
|
bind:checked={$playVideoThumbnailOnHover}
|
|
|
|
|
on:toggle={() => ($playVideoThumbnailOnHover = !$playVideoThumbnailOnHover)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-05-14 21:31:47 +02:00
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('loop_videos')}
|
|
|
|
|
subtitle={$t('loop_videos_description')}
|
2024-05-14 21:31:47 +02:00
|
|
|
bind:checked={$loopVideo}
|
|
|
|
|
on:toggle={() => ($loopVideo = !$loopVideo)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-03-11 12:45:01 -04:00
|
|
|
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('permanent_deletion_warning')}
|
|
|
|
|
subtitle={$t('permanent_deletion_warning_setting_description')}
|
2024-03-11 12:45:01 -04:00
|
|
|
bind:checked={$showDeleteModal}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-02-22 10:14:11 -05:00
|
|
|
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('people')}
|
|
|
|
|
subtitle={$t('people_sidebar_description')}
|
2024-02-22 10:14:11 -05:00
|
|
|
bind:checked={$sidebarSettings.people}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ml-4">
|
|
|
|
|
<SettingSwitch
|
2024-06-04 21:53:00 +02:00
|
|
|
title={$t('sharing')}
|
|
|
|
|
subtitle={$t('sharing_sidebar_description')}
|
2024-02-22 10:14:11 -05:00
|
|
|
bind:checked={$sidebarSettings.sharing}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-01-07 01:15:25 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</section>
|