i18n: localize posts

This commit is contained in:
Xylight committed 2024-06-03 15:49:03 -07:00
1 parent 64107e51a0
commit c4236fa124
9 files changed
+110 -31

No files matched your search

+8 -2
View File
@@ -1,10 +1,16 @@
import { env } from '$env/dynamic/public'
import { userSettings } from '$lib/settings.js'
import { loadTranslations } from '$lib/translations.js'
import { get } from 'svelte/store'
export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export const load = async ({ url }) => {
await loadTranslations('en')
export const load = async ({}) => {
const initLocale = get(userSettings)?.language ?? navigator?.language ?? 'en'
console.log(`Loading locale ${initLocale}`)
await loadTranslations(initLocale)
return
}
+4 -6
View File
@@ -24,7 +24,7 @@
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<header>
<Header>{$t('routes.frontpage')}</Header>
<Header>{$t('routes.frontpage.title')}</Header>
</header>
<div class="flex items-center gap-2">
<Location changeDefault selected={data.listingType} />
@@ -45,11 +45,9 @@
>
<span class="flex flex-row items-center gap-1">
<Icon src={ChartBar} size="16" mini />
<FormattedNumber
number={$site?.site_view.counts.users_active_day ?? 0}
class="text-black dark:text-white font-medium"
/>
<span class="font-normal">active users</span>
{$t('routes.frontpage.footer', {
users: $site?.site_view.counts.users_active_day ?? '??',
})}
</span>
</Pageination>
</div>
+25 -1
View File
@@ -3,7 +3,14 @@
import Setting from './Setting.svelte'
import MultiSelect from '$lib/components/input/Switch.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import { Disclosure, Material, Switch, TextInput, toast } from 'mono-svelte'
import {
Disclosure,
Material,
Note,
Switch,
TextInput,
toast,
} from 'mono-svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import Link from '$lib/components/input/Link.svelte'
import {
@@ -25,6 +32,7 @@
import { removeItem } from '$lib/util.js'
import Section from './Section.svelte'
import ToggleSetting from './ToggleSetting.svelte'
import { locales } from '$lib/translations'
</script>
<svelte:head>
@@ -90,6 +98,22 @@
Go to themes <Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
</Setting>
<Setting>
<span slot="title">Language</span>
<p slot="description">
The language used for Photon's UI.
<Note>
All languages other than US English are community translated, and may
be incomplete!
</Note>
</p>
<Select bind:value={$userSettings.language}>
<option value={null}>Auto-Detect</option>
{#each $locales as locale}
<option value={locale}>{locale}</option>
{/each}
</Select>
</Setting>
<Setting>
<span slot="title">Post style</span>
<ViewSelect showLabel={false} />