Foro: nombres de categorías y foros según el locale (ES/EN)

Los nombres de categorías, foros, descripciones, clases e idiomas venían del seed
solo en inglés. Ahora se muestran en el idioma de la página.

Como es un conjunto fijo y conocido, se resuelve con un mapa de traducción en
código (lib/forum-i18n.ts, inglés→español) que se aplica al vuelo, sin tocar el
esquema (el inglés sigue siendo el valor guardado). Un texto no mapeado (p. ej. un
foro nuevo creado desde el admin) se muestra tal cual.

getForumIndex/getForum/getForumPath/getTopicPath aceptan el locale y localizan
name/description/category (nunca el título de un tema, que es contenido de usuario).
Las páginas pasan su locale.

Verificado en producción: /es/forum en español (Noticias, Caballero de la Muerte,
Foros por idioma) y /en/forum en inglés.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-16 12:42:51 +00:00
parent 18648c6a7e
commit 3a0b9dd5ee
7 changed files with 117 additions and 21 deletions
@@ -25,7 +25,7 @@ export default async function SubforumPage({
const t = await getTranslations('Forum')
const id = Number(forumId)
const forum = await getForum(id)
const forum = await getForum(id, locale)
if (!forum) notFound()
const session = await getSession()
@@ -42,7 +42,7 @@ export default async function SubforumPage({
)
const name = (pid: number | null) => (pid != null ? posters.get(pid)?.name ?? `#${pid}` : '')
const path = await getForumPath(id)
const path = await getForumPath(id, locale)
const hrefFor = (p: number) => `/forum/${id}?page=${p}`
return (
@@ -18,13 +18,13 @@ export default async function CreateTopicPage({
const t = await getTranslations('Forum')
const id = Number(forumId)
const forum = await getForum(id)
const forum = await getForum(id, locale)
if (!forum) notFound()
const session = await getSession()
if (!session.username) redirect(`/${locale}/forum/${id}`)
const path = await getForumPath(id)
const path = await getForumPath(id, locale)
return (
<PageShell title={t('createTopic')}>
@@ -30,7 +30,7 @@ export default async function EditPostPage({
if (!canEditPost(session, isMod, post.poster)) redirect(`/${locale}/forum/topic/${post.topic}`)
const topic = await getTopic(post.topic, true)
const path = await getTopicPath(post.topic)
const path = await getTopicPath(post.topic, locale)
return (
<PageShell title={t('editPost')}>
+1 -1
View File
@@ -10,7 +10,7 @@ export default async function ForumIndexPage({ params }: { params: Promise<{ loc
const { locale } = await params
setRequestLocale(locale)
const t = await getTranslations('Forum')
const categories = await getForumIndex()
const categories = await getForumIndex(locale)
// Nombres de los últimos posteadores de todos los foros, en una sola consulta.
const posterIds = categories.flatMap((c) => c.forums.map((f) => f.last_poster).filter(Boolean) as number[])
@@ -51,7 +51,7 @@ export default async function TopicPage({
await Promise.all(uniquePosters.map(async (pid) => [pid, await getUserPostCount(pid)] as const)),
)
const path = await getTopicPath(id)
const path = await getTopicPath(id, locale)
const canReply = Boolean(session.username) && (!topic.locked || isMod)
return (