feat(phase2): localization EN/RU + additional widget types
- Add svelte-i18n with 224 translation keys (English + Russian) - Language switcher in header (EN/RU toggle, persists to localStorage) - Extract all hardcoded strings from 37 component/page files - Add 4 new widget types: Bookmark, Note (markdown), Embed (iframe), Status - WidgetRenderer dispatches by type, WidgetGrid supports full-width widgets - Type-specific config forms in board editor - Install marked for markdown rendering
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
<script lang="ts">
|
||||
import { t } from 'svelte-i18n';
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { LayoutData } from './$types.js';
|
||||
import { page } from '$app/stores';
|
||||
|
||||
let { data, children }: { data: LayoutData; children: Snippet } = $props();
|
||||
|
||||
const navItems = [
|
||||
{ href: '/admin/users', label: 'Users' },
|
||||
{ href: '/admin/groups', label: 'Groups' },
|
||||
{ href: '/admin/settings', label: 'Settings' }
|
||||
] as const;
|
||||
const navItems = $derived([
|
||||
{ href: '/admin/users', labelKey: 'admin.users' },
|
||||
{ href: '/admin/groups', labelKey: 'admin.groups' },
|
||||
{ href: '/admin/settings', labelKey: 'admin.settings' }
|
||||
]);
|
||||
|
||||
function isActive(href: string): boolean {
|
||||
return $page.url.pathname === href;
|
||||
@@ -20,7 +21,7 @@
|
||||
<div class="mx-auto max-w-6xl">
|
||||
<!-- Admin header -->
|
||||
<div class="mb-6 flex flex-wrap items-center gap-4 rounded-xl border border-border bg-card p-4 shadow-sm">
|
||||
<span class="text-sm font-semibold text-foreground">Admin Panel</span>
|
||||
<span class="text-sm font-semibold text-foreground">{$t('admin.panel')}</span>
|
||||
<div class="flex gap-1">
|
||||
{#each navItems as item (item.href)}
|
||||
<a
|
||||
@@ -29,12 +30,12 @@
|
||||
? 'bg-primary text-primary-foreground'
|
||||
: 'text-muted-foreground hover:bg-accent hover:text-foreground'}"
|
||||
>
|
||||
{item.label}
|
||||
{$t(item.labelKey)}
|
||||
</a>
|
||||
{/each}
|
||||
</div>
|
||||
<div class="ml-auto text-xs text-muted-foreground">
|
||||
{data.user.displayName} (admin)
|
||||
{data.user.displayName} ({$t('admin.role_admin').toLowerCase()})
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from 'svelte-i18n';
|
||||
import type { PageData } from './$types.js';
|
||||
import GroupTable from '$lib/components/admin/GroupTable.svelte';
|
||||
import { superForm } from 'sveltekit-superforms/client';
|
||||
@@ -18,28 +19,28 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>Group Management — Admin</title>
|
||||
<title>{$t('admin.group_management')} — {$t('admin.panel')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div>
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold text-card-foreground">Group Management</h1>
|
||||
<h1 class="text-2xl font-bold text-card-foreground">{$t('admin.group_management')}</h1>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (showCreateForm = !showCreateForm)}
|
||||
class="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
>
|
||||
{showCreateForm ? 'Cancel' : 'Create Group'}
|
||||
{showCreateForm ? $t('common.cancel') : $t('admin.create_group')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if showCreateForm}
|
||||
<div class="mb-6 rounded-lg border border-border bg-card p-6">
|
||||
<h2 class="mb-4 text-lg font-semibold text-card-foreground">New Group</h2>
|
||||
<h2 class="mb-4 text-lg font-semibold text-card-foreground">{$t('admin.new_group')}</h2>
|
||||
<form method="POST" action="?/create" use:enhance class="space-y-4">
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label for="name" class="mb-1 block text-sm font-medium text-foreground">Name</label>
|
||||
<label for="name" class="mb-1 block text-sm font-medium text-foreground">{$t('common.name')}</label>
|
||||
<input
|
||||
id="name"
|
||||
name="name"
|
||||
@@ -51,7 +52,7 @@
|
||||
{#if $errors.name}<span class="text-xs text-destructive">{$errors.name}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="mb-1 block text-sm font-medium text-foreground">Description</label>
|
||||
<label for="description" class="mb-1 block text-sm font-medium text-foreground">{$t('common.description')}</label>
|
||||
<input
|
||||
id="description"
|
||||
name="description"
|
||||
@@ -68,7 +69,7 @@
|
||||
bind:checked={$form.isDefault}
|
||||
class="h-4 w-4 rounded border-input"
|
||||
/>
|
||||
<label for="isDefault" class="text-sm font-medium text-foreground">Default group (auto-assign new users)</label>
|
||||
<label for="isDefault" class="text-sm font-medium text-foreground">{$t('admin.default_group_hint')}</label>
|
||||
</div>
|
||||
</div>
|
||||
{#if $errors._errors}
|
||||
@@ -78,7 +79,7 @@
|
||||
type="submit"
|
||||
class="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90"
|
||||
>
|
||||
Create Group
|
||||
{$t('admin.create_group')}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from 'svelte-i18n';
|
||||
import type { PageData } from './$types.js';
|
||||
import SettingsForm from '$lib/components/admin/SettingsForm.svelte';
|
||||
|
||||
@@ -6,13 +7,13 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>System Settings — Admin</title>
|
||||
<title>{$t('admin.system_settings')} — {$t('admin.panel')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div>
|
||||
<div class="mb-6">
|
||||
<h1 class="text-2xl font-bold text-card-foreground">System Settings</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">Configure global application settings.</p>
|
||||
<h1 class="text-2xl font-bold text-card-foreground">{$t('admin.system_settings')}</h1>
|
||||
<p class="mt-1 text-sm text-muted-foreground">{$t('admin.settings_description')}</p>
|
||||
</div>
|
||||
|
||||
<SettingsForm form={data.form} />
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import { t } from 'svelte-i18n';
|
||||
import type { PageData } from './$types.js';
|
||||
import UserTable from '$lib/components/admin/UserTable.svelte';
|
||||
import { superForm } from 'sveltekit-superforms/client';
|
||||
@@ -18,28 +19,28 @@
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
<title>User Management — Admin</title>
|
||||
<title>{$t('admin.user_management')} — {$t('admin.panel')}</title>
|
||||
</svelte:head>
|
||||
|
||||
<div>
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<h1 class="text-2xl font-bold text-card-foreground">User Management</h1>
|
||||
<h1 class="text-2xl font-bold text-card-foreground">{$t('admin.user_management')}</h1>
|
||||
<button
|
||||
type="button"
|
||||
onclick={() => (showCreateForm = !showCreateForm)}
|
||||
class="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring"
|
||||
>
|
||||
{showCreateForm ? 'Cancel' : 'Create User'}
|
||||
{showCreateForm ? $t('common.cancel') : $t('admin.create_user')}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{#if showCreateForm}
|
||||
<div class="mb-6 rounded-lg border border-border bg-card p-6">
|
||||
<h2 class="mb-4 text-lg font-semibold text-card-foreground">New User</h2>
|
||||
<h2 class="mb-4 text-lg font-semibold text-card-foreground">{$t('admin.new_user')}</h2>
|
||||
<form method="POST" action="?/create" use:enhance class="space-y-4">
|
||||
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<label for="email" class="mb-1 block text-sm font-medium text-foreground">Email</label>
|
||||
<label for="email" class="mb-1 block text-sm font-medium text-foreground">{$t('auth.email')}</label>
|
||||
<input
|
||||
id="email"
|
||||
name="email"
|
||||
@@ -51,7 +52,7 @@
|
||||
{#if $errors.email}<span class="text-xs text-destructive">{$errors.email}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<label for="displayName" class="mb-1 block text-sm font-medium text-foreground">Display Name</label>
|
||||
<label for="displayName" class="mb-1 block text-sm font-medium text-foreground">{$t('auth.display_name')}</label>
|
||||
<input
|
||||
id="displayName"
|
||||
name="displayName"
|
||||
@@ -63,7 +64,7 @@
|
||||
{#if $errors.displayName}<span class="text-xs text-destructive">{$errors.displayName}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<label for="password" class="mb-1 block text-sm font-medium text-foreground">Password</label>
|
||||
<label for="password" class="mb-1 block text-sm font-medium text-foreground">{$t('auth.password')}</label>
|
||||
<input
|
||||
id="password"
|
||||
name="password"
|
||||
@@ -74,15 +75,15 @@
|
||||
{#if $errors.password}<span class="text-xs text-destructive">{$errors.password}</span>{/if}
|
||||
</div>
|
||||
<div>
|
||||
<label for="role" class="mb-1 block text-sm font-medium text-foreground">Role</label>
|
||||
<label for="role" class="mb-1 block text-sm font-medium text-foreground">{$t('admin.role_column')}</label>
|
||||
<select
|
||||
id="role"
|
||||
name="role"
|
||||
bind:value={$form.role}
|
||||
class="w-full rounded-md border border-input bg-background px-3 py-2 text-sm text-foreground"
|
||||
>
|
||||
<option value="user">User</option>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="user">{$t('admin.role_user')}</option>
|
||||
<option value="admin">{$t('admin.role_admin')}</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -93,7 +94,7 @@
|
||||
type="submit"
|
||||
class="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90"
|
||||
>
|
||||
Create User
|
||||
{$t('admin.create_user')}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user