i18n: internationalize all admin pages
Add full i18n coverage for the admin section — locale keys, layout nav, users, videos, and articles pages (list, new, edit). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
import { page } from "$app/state";
|
||||
import { SvelteURLSearchParams } from "svelte/reactivity";
|
||||
import { toast } from "svelte-sonner";
|
||||
import { _ } from "svelte-i18n";
|
||||
import { adminUpdateUser, adminDeleteUser } from "$lib/services";
|
||||
import { getAssetUrl } from "$lib/api";
|
||||
import { Button } from "$lib/components/ui/button";
|
||||
@@ -48,10 +49,10 @@
|
||||
updatingId = user.id;
|
||||
try {
|
||||
await adminUpdateUser({ userId: user.id, role: newRole });
|
||||
toast.success(`Role updated to ${newRole}`);
|
||||
toast.success($_("admin.users.role_updated", { values: { role: newRole } }));
|
||||
await invalidateAll();
|
||||
} catch {
|
||||
toast.error("Failed to update role");
|
||||
toast.error($_("admin.users.role_update_failed"));
|
||||
} finally {
|
||||
updatingId = null;
|
||||
}
|
||||
@@ -67,12 +68,12 @@
|
||||
deleting = true;
|
||||
try {
|
||||
await adminDeleteUser(deleteTarget.id);
|
||||
toast.success("User deleted");
|
||||
toast.success($_("admin.users.delete_success"));
|
||||
deleteOpen = false;
|
||||
deleteTarget = null;
|
||||
await invalidateAll();
|
||||
} catch {
|
||||
toast.error("Failed to delete user");
|
||||
toast.error($_("admin.users.delete_error"));
|
||||
} finally {
|
||||
deleting = false;
|
||||
}
|
||||
@@ -85,14 +86,14 @@
|
||||
|
||||
<div class="p-3 sm:p-6">
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<h1 class="text-2xl font-bold">Users</h1>
|
||||
<span class="text-sm text-muted-foreground">{data.total} total</span>
|
||||
<h1 class="text-2xl font-bold">{$_("admin.users.title")}</h1>
|
||||
<span class="text-sm text-muted-foreground">{$_("admin.users.total", { values: { total: data.total } })}</span>
|
||||
</div>
|
||||
|
||||
<!-- Filters -->
|
||||
<div class="flex flex-wrap gap-3 mb-4">
|
||||
<Input
|
||||
placeholder="Search email or name…"
|
||||
placeholder={$_("admin.users.search_placeholder")}
|
||||
class="max-w-xs"
|
||||
value={searchValue}
|
||||
oninput={(e) => {
|
||||
@@ -108,7 +109,7 @@
|
||||
variant={data.role === role || (!data.role && role === "") ? "default" : "outline"}
|
||||
onclick={() => setRole(role)}
|
||||
>
|
||||
{role || "All"}
|
||||
{role ? $_(`admin.users.role_${role}`) : $_("admin.users.filter_all")}
|
||||
</Button>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -119,11 +120,11 @@
|
||||
<table class="w-full text-sm">
|
||||
<thead class="bg-muted/30">
|
||||
<tr>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground">User</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground hidden sm:table-cell">Email</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground">Role</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground hidden md:table-cell">Joined</th>
|
||||
<th class="px-4 py-3 text-right font-medium text-muted-foreground">Actions</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground">{$_("admin.users.col_user")}</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground hidden sm:table-cell">{$_("admin.users.col_email")}</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground">{$_("admin.users.col_role")}</th>
|
||||
<th class="px-4 py-3 text-left font-medium text-muted-foreground hidden md:table-cell">{$_("admin.users.col_joined")}</th>
|
||||
<th class="px-4 py-3 text-right font-medium text-muted-foreground">{$_("admin.users.col_actions")}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-border/30">
|
||||
@@ -148,7 +149,7 @@
|
||||
<div class="flex items-center gap-1.5">
|
||||
<span class="font-medium truncate">{user.artist_name || user.first_name || "—"}</span>
|
||||
{#if user.is_admin}
|
||||
<Badge variant="default" class="shrink-0 text-[10px] px-1.5 py-0">Admin</Badge>
|
||||
<Badge variant="default" class="shrink-0 text-[10px] px-1.5 py-0">{$_("admin.users.admin_badge")}</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<span class="text-xs text-muted-foreground sm:hidden truncate block">{user.email}</span>
|
||||
@@ -167,8 +168,8 @@
|
||||
{user.role}
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="viewer">Viewer</SelectItem>
|
||||
<SelectItem value="model">Model</SelectItem>
|
||||
<SelectItem value="viewer">{$_("admin.users.role_viewer")}</SelectItem>
|
||||
<SelectItem value="model">{$_("admin.users.role_model")}</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</td>
|
||||
@@ -194,7 +195,7 @@
|
||||
|
||||
{#if data.items.length === 0}
|
||||
<tr>
|
||||
<td colspan="5" class="px-4 py-8 text-center text-muted-foreground">No users found</td>
|
||||
<td colspan="5" class="px-4 py-8 text-center text-muted-foreground">{$_("admin.users.no_results")}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
</tbody>
|
||||
@@ -205,7 +206,7 @@
|
||||
{#if data.total > data.limit}
|
||||
<div class="flex items-center justify-between mt-4">
|
||||
<span class="text-sm text-muted-foreground">
|
||||
Showing {data.offset + 1}–{Math.min(data.offset + data.limit, data.total)} of {data.total}
|
||||
{$_("admin.users.showing", { values: { start: data.offset + 1, end: Math.min(data.offset + data.limit, data.total), total: data.total } })}
|
||||
</span>
|
||||
<div class="flex gap-2">
|
||||
<Button
|
||||
@@ -218,7 +219,7 @@
|
||||
goto(`?${params.toString()}`);
|
||||
}}
|
||||
>
|
||||
Previous
|
||||
{$_("common.previous")}
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
@@ -230,7 +231,7 @@
|
||||
goto(`?${params.toString()}`);
|
||||
}}
|
||||
>
|
||||
Next
|
||||
{$_("common.next")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -241,17 +242,15 @@
|
||||
<Dialog.Root bind:open={deleteOpen}>
|
||||
<Dialog.Content>
|
||||
<Dialog.Header>
|
||||
<Dialog.Title>Delete user</Dialog.Title>
|
||||
<Dialog.Title>{$_("admin.users.delete_title")}</Dialog.Title>
|
||||
<Dialog.Description>
|
||||
Are you sure you want to permanently delete <strong
|
||||
>{deleteTarget?.artist_name || deleteTarget?.email}</strong
|
||||
>? This cannot be undone.
|
||||
{$_("admin.users.delete_description", { values: { name: deleteTarget?.artist_name || deleteTarget?.email } })}
|
||||
</Dialog.Description>
|
||||
</Dialog.Header>
|
||||
<Dialog.Footer>
|
||||
<Button variant="outline" onclick={() => (deleteOpen = false)}>Cancel</Button>
|
||||
<Button variant="outline" onclick={() => (deleteOpen = false)}>{$_("common.cancel")}</Button>
|
||||
<Button variant="destructive" disabled={deleting} onclick={handleDelete}>
|
||||
{deleting ? "Deleting…" : "Delete"}
|
||||
{deleting ? $_("admin.common.deleting") : $_("common.delete")}
|
||||
</Button>
|
||||
</Dialog.Footer>
|
||||
</Dialog.Content>
|
||||
|
||||
Reference in New Issue
Block a user