= ({ user }) => {
return (
-
-
+
{diff.lines.map ((line, index) => {
const colour = cn (
diff --git a/frontend/src/pages/help/HelpListPage.tsx b/frontend/src/pages/help/HelpListPage.tsx
index bf0341c..0bbf5c1 100644
--- a/frontend/src/pages/help/HelpListPage.tsx
+++ b/frontend/src/pages/help/HelpListPage.tsx
@@ -15,6 +15,8 @@ import { compareHelpEditions,
getHelpSearchEntries,
helpEditionDate,
normaliseHelpSearchText } from '@/lib/help'
+import { localeLanguage } from '@/lib/locales'
+import { useLocale } from '@/lib/useLocale'
import { helpKeys } from '@/lib/queryKeys'
import { LIST_LIMIT_OPTIONS } from '@/lib/settings'
import { dateString, inputClass } from '@/lib/utils'
@@ -30,6 +32,7 @@ const defaultDirection: Record = {
const HelpSearchPage: FC = () => {
+ const language = localeLanguage (useLocale ())
const [searchParams, setSearchParams] = useSearchParams ()
const pageValue = searchParams.get ('page') ?? '1'
const pageNumber = Number (pageValue)
@@ -49,8 +52,8 @@ const HelpSearchPage: FC = () => {
const [title, setTitle] = useState (conditions.title)
const [text, setText] = useState (conditions.text)
const { data: entries = [], isLoading: loading, error } = useQuery ({
- queryKey: helpKeys.index ('ja'),
- queryFn: () => getHelpSearchEntries ('ja'),
+ queryKey: helpKeys.index (language),
+ queryFn: () => getHelpSearchEntries (language),
staleTime: Infinity })
useEffect (() => {
diff --git a/frontend/src/pages/materials/MaterialDetailPage.tsx b/frontend/src/pages/materials/MaterialDetailPage.tsx
index 2be6299..fba4219 100644
--- a/frontend/src/pages/materials/MaterialDetailPage.tsx
+++ b/frontend/src/pages/materials/MaterialDetailPage.tsx
@@ -3,6 +3,7 @@ import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useParams } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import TagLink from '@/components/TagLink'
import WikiBody from '@/components/WikiBody'
import FieldError from '@/components/common/FieldError'
@@ -28,6 +29,7 @@ type MaterialFormField = 'tag' | 'file' | 'url' | 'exportPaths'
const MaterialDetailPage: FC = () => {
+ const locale = useLocale ()
const { id } = useParams ()
const qc = useQueryClient ()
@@ -40,8 +42,8 @@ const MaterialDetailPage: FC = () => {
useValidationErrors ()
const { data: material, isError, isLoading } = useQuery ({
- queryKey: materialsKeys.show (id ?? ''),
- queryFn: () => fetchMaterial (id ?? ''),
+ queryKey: materialsKeys.show (id ?? '', locale),
+ queryFn: () => fetchMaterial (id ?? '', locale),
enabled: id != null})
const materialTitle = material
? material.tag?.name ?? `素材 #${ material.id }`
@@ -76,10 +78,10 @@ const MaterialDetailPage: FC = () => {
formData.append ('url', url)
formData.append ('export_paths[legacy_drive]', exportPath)
- return await updateMaterial (id ?? '', formData)
+ return await updateMaterial (id ?? '', formData, locale)
},
onSuccess: async data => {
- qc.setQueryData (materialsKeys.show (id ?? ''), data)
+ qc.setQueryData (materialsKeys.show (id ?? '', locale), data)
await invalidateMaterialQueries ()
toast ({ title: '更新成功!' })
},
diff --git a/frontend/src/pages/materials/MaterialHistoryPage.tsx b/frontend/src/pages/materials/MaterialHistoryPage.tsx
index 920fbad..b8e2308 100644
--- a/frontend/src/pages/materials/MaterialHistoryPage.tsx
+++ b/frontend/src/pages/materials/MaterialHistoryPage.tsx
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import PrefetchLink from '@/components/PrefetchLink'
import FormField from '@/components/common/FormField'
import PageTitle from '@/components/common/PageTitle'
@@ -19,10 +20,11 @@ import type { FC, FormEvent } from 'react'
const MaterialHistoryPage: FC = () => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const query = new URLSearchParams (location.search)
const materialId = query.get ('material_id') ?? ''
@@ -47,13 +49,13 @@ const MaterialHistoryPage: FC = () => {
...(tag && { tag }),
...(eventType && { eventType }),
page,
- limit }),
+ limit }, locale),
queryFn: () => fetchMaterialChanges ({
...(materialId && { materialId }),
...(tag && { tag }),
...(eventType && { eventType }),
page,
- limit }) })
+ limit }, locale) })
const versions = data?.versions ?? []
const totalPages = data ? Math.ceil (data.count / limit) : 0
diff --git a/frontend/src/pages/materials/MaterialListPage.tsx b/frontend/src/pages/materials/MaterialListPage.tsx
index 7a5b718..a8634aa 100644
--- a/frontend/src/pages/materials/MaterialListPage.tsx
+++ b/frontend/src/pages/materials/MaterialListPage.tsx
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useMemo, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import nikumaru from '@/assets/fonts/nikumaru.otf'
import PrefetchLink from '@/components/PrefetchLink'
import DateTimeField from '@/components/common/DateTimeField'
@@ -210,8 +211,9 @@ const GroupHeading: FC<{
const MaterialListPage: FC = () => {
+ const locale = useLocale ()
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const query = useMemo (() => new URLSearchParams (location.search), [location.search])
const materialFilter = parseMaterialFilter (query.get ('material_filter'), 'present')
@@ -277,8 +279,8 @@ const MaterialListPage: FC = () => {
page,
limit}
const { data, isLoading, isError } = useQuery ({
- queryKey: materialsKeys.index (keys),
- queryFn: () => fetchMaterials (keys)})
+ queryKey: materialsKeys.index (keys, locale),
+ queryFn: () => fetchMaterials (keys, locale)})
const tagScope = data?.tagScope ?? null
const materials = data?.materials ?? []
const groups = data?.groups ?? []
diff --git a/frontend/src/pages/materials/MaterialNewPage.tsx b/frontend/src/pages/materials/MaterialNewPage.tsx
index ef8c6a9..3c60339 100644
--- a/frontend/src/pages/materials/MaterialNewPage.tsx
+++ b/frontend/src/pages/materials/MaterialNewPage.tsx
@@ -1,8 +1,9 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import FieldError from '@/components/common/FieldError'
import Form from '@/components/common/Form'
import FormField from '@/components/common/FormField'
@@ -13,6 +14,7 @@ import { Button } from '@/components/ui/button'
import { toast } from '@/components/ui/use-toast'
import { SITE_TITLE } from '@/config'
import { createMaterial } from '@/lib/materials'
+import { unlocalisedPath } from '@/lib/locales'
import { materialsKeys } from '@/lib/queryKeys'
import { inputClass } from '@/lib/utils'
import { useValidationErrors } from '@/lib/useValidationErrors'
@@ -23,14 +25,16 @@ type MaterialFormField = 'tag' | 'file' | 'url' | 'exportPaths'
const MaterialNewPage: FC = () => {
+ const locale = useLocale ()
const qc = useQueryClient ()
const location = useLocation ()
const query = new URLSearchParams (location.search)
const tagQuery = query.get ('tag') ?? ''
const returnToQuery = query.get ('return_to') ?? ''
- const safeReturnTo = returnToQuery.startsWith ('/materials') ? returnToQuery : ''
+ const safeReturnTo =
+ unlocalisedPath (returnToQuery).startsWith ('/materials') ? returnToQuery : ''
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const [file, setFile] = useState (null)
const [filePreview, setFilePreview] = useState ('')
@@ -51,7 +55,7 @@ const MaterialNewPage: FC = () => {
formData.append ('url', url)
formData.append ('export_paths[legacy_drive]', exportPath)
- return await createMaterial (formData)
+ return await createMaterial (formData, locale)
},
onSuccess: async () => {
await qc.invalidateQueries ({ queryKey: materialsKeys.root })
diff --git a/frontend/src/pages/materials/MaterialSyncSuppressionsPage.tsx b/frontend/src/pages/materials/MaterialSyncSuppressionsPage.tsx
index f398bbc..b155de9 100644
--- a/frontend/src/pages/materials/MaterialSyncSuppressionsPage.tsx
+++ b/frontend/src/pages/materials/MaterialSyncSuppressionsPage.tsx
@@ -2,6 +2,7 @@ import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import { useState } from 'react'
import { Helmet } from 'react-helmet-async'
+import { useLocale } from '@/lib/useLocale'
import FormField from '@/components/common/FormField'
import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
@@ -52,6 +53,7 @@ const reasonName = (reason: string): string =>
const MaterialSyncSuppressionsPage: FC = () => {
+ const locale = useLocale ()
const qc = useQueryClient ()
const [sourceKind, setSourceKind] =
useState ('uri')
@@ -61,8 +63,8 @@ const MaterialSyncSuppressionsPage: FC = () => {
const [reason, setReason] = useState (REASONS[0])
const { data, isError, isLoading } = useQuery ({
- queryKey: materialsKeys.suppressions (),
- queryFn: fetchMaterialSyncSuppressions})
+ queryKey: materialsKeys.suppressions (locale),
+ queryFn: () => fetchMaterialSyncSuppressions (locale)})
const createMutation = useMutation ({
mutationFn: async () =>
@@ -71,9 +73,9 @@ const MaterialSyncSuppressionsPage: FC = () => {
sourceUri,
drivePath,
driveFileId,
- reason}),
+ reason}, locale),
onSuccess: async () => {
- await qc.invalidateQueries ({ queryKey: materialsKeys.suppressions () })
+ await qc.invalidateQueries ({ queryKey: materialsKeys.suppressions (locale) })
await qc.invalidateQueries ({ queryKey: materialsKeys.root })
setSourceUri ('')
setDrivePath ('')
diff --git a/frontend/src/pages/posts/PostDetailPage.tsx b/frontend/src/pages/posts/PostDetailPage.tsx
index 01957df..9431c22 100644
--- a/frontend/src/pages/posts/PostDetailPage.tsx
+++ b/frontend/src/pages/posts/PostDetailPage.tsx
@@ -3,6 +3,7 @@ import { motion } from 'framer-motion'
import { useEffect, useRef, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useParams } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import PostEditForm from '@/components/PostEditForm'
import PostEmbed from '@/components/PostEmbed'
import PostList from '@/components/PostList'
@@ -29,6 +30,7 @@ type Props = { user: User | null }
const PostDetailPage: FC = ({ user }) => {
+ const locale = useLocale ()
const editable = canEditContent (user)
const behaviourSettings = useClientBehaviourSettings ()
const thumbnailMode = behaviourSettings.thumbnailMode ?? 'normal'
@@ -42,12 +44,12 @@ const PostDetailPage: FC = ({ user }) => {
? { duration: .08, ease: 'linear' as const }
: { duration: .2, ease: 'easeOut' as const }
const postId = String (id ?? '')
- const postKey = postsKeys.show (postId)
+ const postKey = postsKeys.show (postId, locale)
const { data: post, isError: errorFlg, error } = useQuery ({
enabled: Boolean (id),
queryKey: postKey,
- queryFn: () => fetchPost (postId) })
+ queryFn: () => fetchPost (postId, locale) })
const qc = useQueryClient ()
@@ -181,7 +183,7 @@ const PostDetailPage: FC = ({ user }) => {
{
- qc.setQueryData (postsKeys.show (postId),
+ qc.setQueryData (postsKeys.show (postId, locale),
(prev: Post | undefined) => newPost ?? prev)
qc.invalidateQueries ({ queryKey: postsKeys.root })
qc.invalidateQueries ({ queryKey: tagsKeys.root })
diff --git a/frontend/src/pages/posts/PostHistoryPage.tsx b/frontend/src/pages/posts/PostHistoryPage.tsx
index 446dc38..3a9a5e5 100644
--- a/frontend/src/pages/posts/PostHistoryPage.tsx
+++ b/frontend/src/pages/posts/PostHistoryPage.tsx
@@ -4,6 +4,7 @@ import { useEffect } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import TagLink from '@/components/TagLink'
import PrefetchLink from '@/components/PrefetchLink'
import PageTitle from '@/components/common/PageTitle'
@@ -39,6 +40,7 @@ const renderDiff = (diff: { current: string | null; prev: string | null }) => (
const PostHistoryPage: FC = () => {
+ const locale = useLocale ()
const dialogue = useDialogue ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
@@ -61,25 +63,25 @@ const PostHistoryPage: FC = () => {
const tagQueryId = tagId ?? ''
const { data: tag } = useQuery ({
enabled: Boolean (tagId),
- queryKey: tagsKeys.show (tagQueryId),
- queryFn: () => fetchTag (tagQueryId) })
+ queryKey: tagsKeys.show (tagQueryId, locale),
+ queryFn: () => fetchTag (tagQueryId, locale) })
const externalTagQueryId = externalTagId ?? ''
const { data: externalTag } = useQuery ({
enabled: Boolean (externalTagId),
- queryKey: tagsKeys.externalShow (externalTagQueryId),
- queryFn: () => fetchExternalTag (externalTagQueryId) })
+ queryKey: tagsKeys.externalShow (externalTagQueryId, locale),
+ queryFn: () => fetchExternalTag (externalTagQueryId, locale) })
const { data, isLoading: loading } = useQuery ({
queryKey: postsKeys.changes ({ ...(id && { post: id }),
...(tagId && { tag: tagId }),
...(externalTagId && { externalTag: externalTagId }),
- page, limit }),
+ page, limit }, locale),
queryFn: () => fetchPostChanges ({ ...(id && { post: id }),
...(tagId && { tag: tagId }),
...(externalTagId && {
externalTag: externalTagId }),
- page, limit }) })
+ page, limit }, locale) })
const changes = data?.versions ?? []
const totalPages = data ? Math.ceil (data.count / limit) : 0
const displayedTag = externalTag ?? tag
@@ -121,7 +123,7 @@ const PostHistoryPage: FC = () => {
const originalCreatedBefore = change.originalCreatedBefore.current
await updatePost ({ id, title, tags, duration, parentPostIds,
originalCreatedFrom, originalCreatedBefore },
- { force: true })
+ { force: true }, locale)
qc.invalidateQueries ({ queryKey: postsKeys.root })
qc.invalidateQueries ({ queryKey: tagsKeys.root })
diff --git a/frontend/src/pages/posts/PostImportReviewPage.tsx b/frontend/src/pages/posts/PostImportReviewPage.tsx
index 9dcc181..6c636bc 100644
--- a/frontend/src/pages/posts/PostImportReviewPage.tsx
+++ b/frontend/src/pages/posts/PostImportReviewPage.tsx
@@ -2,8 +2,9 @@ import { AnimatePresence, motion } from 'framer-motion'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { ChevronRight } from 'lucide-react'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
import PrefetchLink from '@/components/PrefetchLink'
@@ -595,10 +596,11 @@ const editableRowDirty = (row: PostImportRow): boolean =>
const PostImportReviewPage: FC = ({ user }) => {
+ const locale = useLocale ()
const editable = canEditContent (user)
const dialogue = useDialogue ()
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const existingRowsTransition =
@@ -696,7 +698,7 @@ const PostImportReviewPage: FC = ({ user }) => {
try
{
- const preview = await apiGet ('/posts/metadata', {
+ const preview = await apiGet ('/posts/metadata', { locale,
params: { url: currentRow.url },
signal: controller.signal })
if (!(active) || metadataSequenceRef.current !== sequence)
@@ -770,7 +772,7 @@ const PostImportReviewPage: FC = ({ user }) => {
active = false
controllers.forEach (controller => controller.abort ())
}
- }, [commitRows, currentRowBySource, location.search, updateRows])
+ }, [commitRows, currentRowBySource, location.search, updateRows, locale])
useEffect (() => {
if (editingRow == null || resultRepairMode (rowsRef.current) !== 'failed')
@@ -871,12 +873,12 @@ const PostImportReviewPage: FC = ({ user }) => {
urlChanged
? mergePreviewRow (
nextRow,
- await apiGet ('/posts/metadata', {
+ await apiGet ('/posts/metadata', { locale,
params: { url: nextRow.url } }))
: nextRow
const dryRun = await apiPost (
'/posts?dry=1',
- buildDryRunFormData (candidateRow))
+ buildDryRunFormData (candidateRow), { locale })
const mergedRow = mergeDryRunRow (candidateRow, dryRun)
const mergedRows = updateRows (currentRows =>
replaceImportRow (currentRows, mergedRow))
@@ -974,7 +976,7 @@ const PostImportReviewPage: FC = ({ user }) => {
const result = await apiPost<{ results: BulkApiRow[] }>(
'/posts/bulk',
- buildBulkFormData ([target]))
+ buildBulkFormData ([target]), { locale })
if (result.results.length !== 1)
{
updateRows (currentRows => replaceImportRow (currentRows, originalRow))
@@ -1018,7 +1020,7 @@ const PostImportReviewPage: FC = ({ user }) => {
{
const result = await apiPost<{ results: BulkApiRow[] }>(
'/posts/bulk',
- buildBulkFormData (latestProcessingRows))
+ buildBulkFormData (latestProcessingRows), { locale })
if (result.results.length !== latestProcessingRows.length)
{
toast ({ title: '登録結果が不完全でした' })
diff --git a/frontend/src/pages/posts/PostImportSourcePage.tsx b/frontend/src/pages/posts/PostImportSourcePage.tsx
index fc65b69..cc0783a 100644
--- a/frontend/src/pages/posts/PostImportSourcePage.tsx
+++ b/frontend/src/pages/posts/PostImportSourcePage.tsx
@@ -1,7 +1,8 @@
import { useEffect, useRef, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useNavigate } from 'react-router-dom'
+
+import { useLocaleNavigate } from '@/lib/useLocale'
import FieldError from '@/components/common/FieldError'
import Form from '@/components/common/Form'
import FormField from '@/components/common/FormField'
@@ -40,7 +41,7 @@ const SOURCE_ISSUES_ID = 'post-import-source-issues'
const PostImportSourcePage: FC = ({ user }) => {
const editable = canEditContent (user)
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const [source, setSource] = useState ('')
const [loading, setLoading] = useState (false)
const [sourceIssues, setSourceIssues] = useState> ([])
diff --git a/frontend/src/pages/posts/PostListPage.tsx b/frontend/src/pages/posts/PostListPage.tsx
index 6f56c9d..3568dec 100644
--- a/frontend/src/pages/posts/PostListPage.tsx
+++ b/frontend/src/pages/posts/PostListPage.tsx
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useLayoutEffect, useMemo, useRef, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import PostList from '@/components/PostList'
import PrefetchLink from '@/components/PrefetchLink'
import TagSidebar from '@/components/TagSidebar'
@@ -33,12 +34,13 @@ const parseLimit = (value: string | null): 20 | 50 | 100 | null => {
const PostListPage: FC = () => {
+ const locale = useLocale ()
const containerRef = useRef (null)
const [wikiPage, setWikiPage] = useState (null)
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const query = new URLSearchParams (location.search)
const tagsQuery = query.get ('tags') ?? ''
const anyFlg = query.get ('match') === 'any'
@@ -59,8 +61,8 @@ const PostListPage: FC = () => {
createdFrom: '', createdTo: '', updatedFrom: '', updatedTo: '',
order } as const
const { data, isLoading: loading } = useQuery ({
- queryKey: postsKeys.index (keys),
- queryFn: () => fetchPosts (keys) })
+ queryKey: postsKeys.index (keys, locale),
+ queryFn: () => fetchPosts (keys, locale) })
const posts = data?.posts ?? []
const cursor = ''
const totalPages = data ? Math.ceil (data.count / limit) : 0
@@ -111,14 +113,14 @@ const PostListPage: FC = () => {
try
{
const tagName = tags[0]
- setWikiPage (await fetchWikiPageByTitle (tagName, { }))
+ setWikiPage (await fetchWikiPageByTitle (tagName, { }, locale))
}
catch
{
;
}
}) ()
- }, [location.search, tags])
+ }, [location.search, tags, locale])
return (
{
const PostSearchPage: FC = () => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const thumbnailTransition = clientAnimationTransition (
@@ -79,7 +81,7 @@ const PostSearchPage: FC = () => {
)
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const query = useMemo (() => new URLSearchParams (location.search),
[location.search])
@@ -130,8 +132,8 @@ const PostSearchPage: FC = () => {
updatedTo: qUpdatedTo,
order }
const { data, isLoading: loading } = useQuery ({
- queryKey: postsKeys.index (keys),
- queryFn: () => fetchPosts (keys) })
+ queryKey: postsKeys.index (keys, locale),
+ queryFn: () => fetchPosts (keys, locale) })
const results = data?.posts ?? []
const totalPages = data ? Math.ceil (data.count / limit) : 0
diff --git a/frontend/src/pages/tags/NicoTagListPage.tsx b/frontend/src/pages/tags/NicoTagListPage.tsx
index 74f4d77..a7cb63e 100644
--- a/frontend/src/pages/tags/NicoTagListPage.tsx
+++ b/frontend/src/pages/tags/NicoTagListPage.tsx
@@ -2,8 +2,9 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
import { Check, LoaderCircle, Pencil, X } from 'lucide-react'
import { Fragment, useEffect, useMemo, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import TagLink from '@/components/TagLink'
import SortHeader from '@/components/SortHeader'
import FieldError from '@/components/common/FieldError'
@@ -40,11 +41,12 @@ const setIf = (qs: URLSearchParams, key: string, value: string) => {
const NicoTagListPage: FC
= ({ user }) => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const dialogue = useDialogue ()
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const queryClient = useQueryClient ()
const query = useMemo (() => new URLSearchParams (location.search), [location.search])
@@ -66,8 +68,8 @@ const NicoTagListPage: FC = ({ user }) => {
const keys = {
name: qName, linkedTag: qLinkedTag, linkStatus: qLinkStatus, page, limit, order }
const { data, isError, isLoading: loading } = useQuery ({
- queryKey: tagsKeys.nicoIndex (keys),
- queryFn: () => fetchNicoTags (keys) })
+ queryKey: tagsKeys.nicoIndex (keys, locale),
+ queryFn: () => fetchNicoTags (keys, locale) })
const nicoTags = data?.tags ?? []
const count = data?.count ?? 0
@@ -128,7 +130,7 @@ const NicoTagListPage: FC = ({ user }) => {
try
{
await apiPut (`/tags/nico/${ id }`, formData,
- { headers: { 'Content-Type': 'multipart/form-data' } })
+ { locale, headers: { 'Content-Type': 'multipart/form-data' } })
setErrorsByTagId (errors => ({ ...errors, [id]: [] }))
setEditingId (null)
await queryClient.invalidateQueries ({ queryKey: tagsKeys.nicoRoot })
diff --git a/frontend/src/pages/tags/TagDetailPage.tsx b/frontend/src/pages/tags/TagDetailPage.tsx
index d1e3e76..64f87ac 100644
--- a/frontend/src/pages/tags/TagDetailPage.tsx
+++ b/frontend/src/pages/tags/TagDetailPage.tsx
@@ -2,6 +2,7 @@ import { useQuery, useQueryClient } from '@tanstack/react-query'
import { useEffect, useState } from 'react'
import { useParams } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import TagLink from '@/components/TagLink'
import FieldError from '@/components/common/FieldError'
import FormField from '@/components/common/FormField'
@@ -28,13 +29,14 @@ type TagFormField =
const TagDetailPage: FC = () => {
+ const locale = useLocale ()
const { id } = useParams ()
const tagId = String (id ?? '')
- const tagKey = tagsKeys.show (tagId)
+ const tagKey = tagsKeys.show (tagId, locale)
const { data: tag, isLoading: loading } = useQuery ({
queryKey: tagKey,
- queryFn: () => fetchTag (tagId) })
+ queryFn: () => fetchTag (tagId, locale) })
const [name, setName] = useState ('')
const [category, setCategory] = useState ('general')
@@ -60,7 +62,7 @@ const TagDetailPage: FC = () => {
try
{
- const data = await apiPut (`/tags/${ id }`, formData)
+ const data = await apiPut (`/tags/${ id }`, formData, { locale })
setName (data.name)
setCategory (data.category as Category)
diff --git a/frontend/src/pages/tags/TagHistoryPage.tsx b/frontend/src/pages/tags/TagHistoryPage.tsx
index f95d2ae..28061cc 100644
--- a/frontend/src/pages/tags/TagHistoryPage.tsx
+++ b/frontend/src/pages/tags/TagHistoryPage.tsx
@@ -3,6 +3,7 @@ import { useEffect } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import PrefetchLink from '@/components/PrefetchLink'
import PageTitle from '@/components/common/PageTitle'
import Pagination from '@/components/common/Pagination'
@@ -45,6 +46,7 @@ const renderStateDiff = (diff: { current: string | null; prev: string | null })
const TagHistoryPage: FC = () => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const location = useLocation ()
@@ -54,8 +56,8 @@ const TagHistoryPage: FC = () => {
const limit = Number (query.get ('limit') ?? 20)
const { data, isLoading: loading } = useQuery ({
- queryKey: tagsKeys.changes ({ ...(id && { id }), page, limit }),
- queryFn: () => fetchTagChanges ({ ...(id && { id }), page, limit }) })
+ queryKey: tagsKeys.changes ({ ...(id && { id }), page, limit }, locale),
+ queryFn: () => fetchTagChanges ({ ...(id && { id }), page, limit }, locale) })
const changes = data?.versions ?? []
const totalPages = data ? Math.ceil (data.count / limit) : 0
@@ -210,7 +212,7 @@ const TagHistoryPage: FC = () => {
change.parentTags
.filter (t => t.type !== 'removed')
.map (t => t.tag.name)
- .join (' ') })
+ .join (' ') }, { locale })
qc.invalidateQueries ({ queryKey: postsKeys.root })
qc.invalidateQueries ({ queryKey: tagsKeys.root })
diff --git a/frontend/src/pages/tags/TagListPage.tsx b/frontend/src/pages/tags/TagListPage.tsx
index 8dde00d..ad34248 100644
--- a/frontend/src/pages/tags/TagListPage.tsx
+++ b/frontend/src/pages/tags/TagListPage.tsx
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useMemo, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import PrefetchLink from '@/components/PrefetchLink'
import SortHeader from '@/components/SortHeader'
import TagLink from '@/components/TagLink'
@@ -73,11 +74,12 @@ const parseOrder = (value: string | null): FetchTagsOrder | null => {
const TagListPage: FC = () => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const query = useMemo (() => new URLSearchParams (location.search), [location.search])
@@ -129,8 +131,8 @@ const TagListPage: FC = () => {
updatedTo: qUpdatedTo,
deprecated: qDeprecated }
const { data, isLoading: loading } = useQuery ({
- queryKey: tagsKeys.index (keys),
- queryFn: () => fetchTags (keys) })
+ queryKey: tagsKeys.index (keys, locale),
+ queryFn: () => fetchTags (keys, locale) })
const results = data?.tags ?? []
const totalPages = data ? Math.ceil (data.count / limit) : 0
diff --git a/frontend/src/pages/theatres/TheatreDetailPage.tsx b/frontend/src/pages/theatres/TheatreDetailPage.tsx
index 1c99361..550cc99 100644
--- a/frontend/src/pages/theatres/TheatreDetailPage.tsx
+++ b/frontend/src/pages/theatres/TheatreDetailPage.tsx
@@ -3,6 +3,7 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useParams } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import ErrorScreen from '@/components/ErrorScreen'
import PostEditForm from '@/components/PostEditForm'
import PostEmbed from '@/components/PostEmbed'
@@ -215,6 +216,7 @@ type Props = { user: User | null }
const TheatreDetailPage: FC = ({ user }: Props) => {
+ const locale = useLocale ()
const behaviourSettings = useClientBehaviourSettings ()
const animationMode = behaviourSettings.animation ?? 'normal'
const layoutTransition = clientAnimationTransition (
@@ -286,16 +288,16 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
return
setProgrammes (await apiGet (
- `/theatres/${ id }/programmes`, { params: { limit: '100' } }))
- }, [id])
+ `/theatres/${ id }/programmes`, { locale, params: { limit: '100' } }))
+ }, [id, locale])
const refreshWeights = useCallback (async () => {
if (!(id))
return
setWeights (await apiGet (
- `/theatres/${ id }/post_selection_weights`))
- }, [id])
+ `/theatres/${ id }/post_selection_weights`, { locale }))
+ }, [id, locale])
const advancePost = useCallback (async () => {
if (!(id))
@@ -304,7 +306,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
setLoading (true)
try
{
- await apiPatch (`/theatres/${ id }/next_post`)
+ await apiPatch (`/theatres/${ id }/next_post`, { }, { locale })
await refreshProgrammes ()
await refreshWeights ()
}
@@ -316,7 +318,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
{
setLoading (false)
}
- }, [id, refreshProgrammes, refreshWeights])
+ }, [id, refreshProgrammes, refreshWeights, locale])
useEffect (() => {
loadingRef.current = loading
@@ -365,7 +367,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
void (async () => {
try
{
- const data = await apiGet (`/theatres/${ id }`)
+ const data = await apiGet (`/theatres/${ id }`, { locale })
if (!(cancelled))
setTheatre (data)
}
@@ -381,7 +383,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
return () => {
cancelled = true
}
- }, [id, refreshProgrammes, refreshWeights])
+ }, [id, refreshProgrammes, refreshWeights, locale])
useEffect (() => {
if (!(id))
@@ -400,7 +402,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
{
const newComments = await apiGet (
`/theatres/${ id }/comments`,
- { params: { no_gt: lastCommentNoRef.current, limit: '20' } })
+ { locale, params: { no_gt: lastCommentNoRef.current, limit: '20' } })
if (!(cancelled) && newComments.length > 0)
{
@@ -433,7 +435,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
}
const watchingRequestedAt = performance.now ()
- const nextInfo = await apiPut (`/theatres/${ id }/watching`)
+ const nextInfo = await apiPut (`/theatres/${ id }/watching`, { }, { locale })
if (!(cancelled) && watchingRequestedAt >= theatreInfoReceivedAtRef.current)
applyTheatreInfo (nextInfo)
}
@@ -454,7 +456,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
cancelled = true
clearInterval (interval)
}
- }, [applyTheatreInfo, currentPostElapsedMs, id])
+ }, [applyTheatreInfo, currentPostElapsedMs, id, locale])
useEffect (() => {
if (!(id) || !(theatreInfo.hostFlg) || loadingRef.current || theatreInfo.postId != null)
@@ -487,7 +489,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
void (async () => {
try
{
- const nextPost = await fetchPost (String (theatreInfo.postId))
+ const nextPost = await fetchPost (String (theatreInfo.postId), locale)
if (!(cancelled))
setPost (nextPost)
}
@@ -500,7 +502,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
return () => {
cancelled = true
}
- }, [theatreInfo.postId])
+ }, [theatreInfo.postId, locale])
useEffect (() => {
void refreshProgrammes ()
@@ -570,9 +572,9 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
const nextInfo =
theatreInfo.skipVote.voted
? await apiDelete (
- `/theatres/${ id }/skip_vote`, { params: { post_id: post.id } })
+ `/theatres/${ id }/skip_vote`, { locale, params: { post_id: post.id } })
: await apiPut (
- `/theatres/${ id }/skip_vote`, { post_id: post.id })
+ `/theatres/${ id }/skip_vote`, { post_id: post.id }, { locale })
applyTheatreInfo (nextInfo)
@@ -586,7 +588,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
catch (error)
{
if (isApiError (error) && error.response?.status === 409)
- applyTheatreInfo (await apiPut (`/theatres/${ id }/watching`))
+ applyTheatreInfo (await apiPut (`/theatres/${ id }/watching`, { }, { locale }))
console.error (error)
}
@@ -600,7 +602,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
const handleDelete = async (commentNo: number) => {
try
{
- await apiDelete (`/theatres/${ id }/comments/${ commentNo }`)
+ await apiDelete (`/theatres/${ id }/comments/${ commentNo }`, { locale })
setComments (prev => {
const rtn = [...prev]
const idx = rtn.findIndex (x => x.no === commentNo)
@@ -625,7 +627,7 @@ const TheatreDetailPage: FC = ({ user }: Props) => {
{
setSending (true)
clearValidationErrors ()
- await apiPost (`/theatres/${ id }/comments`, { content })
+ await apiPost (`/theatres/${ id }/comments`, { content }, { locale })
setContent ('')
commentsRef.current?.scrollTo ({
top: 0,
diff --git a/frontend/src/pages/users/SettingPage.tsx b/frontend/src/pages/users/SettingPage.tsx
index 1ece04a..572a76c 100644
--- a/frontend/src/pages/users/SettingPage.tsx
+++ b/frontend/src/pages/users/SettingPage.tsx
@@ -1,7 +1,8 @@
import { useCallback, useEffect, useMemo, useState } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useBeforeUnload, useLocation, useNavigate } from 'react-router-dom'
+import { useBeforeUnload, useLocation } from 'react-router-dom'
+import { useLocaleNavigate } from '@/lib/useLocale'
import FieldError from '@/components/common/FieldError'
import FormField from '@/components/common/FormField'
import Label from '@/components/common/Label'
@@ -251,7 +252,7 @@ const ensureCompleteThemeSlots = (
): UserThemeSlotMap =>
USER_THEME_SLOT_SELECTIONS.reduce (
(complete, selection) => {
- const [_, baseTheme, slotNo] = selection.split (':')
+ const [, baseTheme, slotNo] = selection.split (':')
complete[selection] =
themeSlots[selection]
?? getDefaultUserThemeSlot (
@@ -267,7 +268,7 @@ const comparableThemeTokensForSelection = (
themeSlots: UserThemeSlotMap,
selection: UserThemeSlotSelection,
): ThemeTokens => {
- const [_, baseTheme, slotNo] = selection.split (':')
+ const [, baseTheme, slotNo] = selection.split (':')
const fallback =
getDefaultUserThemeSlot (
baseTheme as BuiltinThemeId,
@@ -647,7 +648,7 @@ const ThemeSection: FC = (
const SettingPage: FC = ({ user, setUser }) => {
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const dialogue = useDialogue ()
const { registerUnsavedChangesSource } = useUnsavedChangesGuard ()
@@ -811,7 +812,7 @@ const SettingPage: FC = ({ user, setUser }) => {
const discardThemeChanges = () => {
const selection = displayedThemeSelection.selection
- const [_, baseTheme, slotNo] = selection.split (':')
+ const [, baseTheme, slotNo] = selection.split (':')
const nextThemeSlots = {
...draftThemeSlots,
[selection]: savedThemeSlots[selection]
@@ -894,7 +895,7 @@ const SettingPage: FC = ({ user, setUser }) => {
return
const selection = displayedThemeSelection.selection
- const [_, baseTheme, slotNo] = selection.split (':')
+ const [, baseTheme, slotNo] = selection.split (':')
themeSlots = {
...baseState.themeSlots,
[selection]: savedThemeSlots[selection]
diff --git a/frontend/src/pages/wiki/WikiDetailPage.tsx b/frontend/src/pages/wiki/WikiDetailPage.tsx
index e082e56..5b4421f 100644
--- a/frontend/src/pages/wiki/WikiDetailPage.tsx
+++ b/frontend/src/pages/wiki/WikiDetailPage.tsx
@@ -1,8 +1,9 @@
import { useQuery } from '@tanstack/react-query'
import { useEffect, useMemo } from 'react'
import { Helmet } from 'react-helmet-async'
-import { useLocation, useNavigate, useParams } from 'react-router-dom'
+import { useLocation, useParams } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import PostList from '@/components/PostList'
import PrefetchLink from '@/components/PrefetchLink'
import TagLink from '@/components/TagLink'
@@ -24,11 +25,12 @@ import type { Tag } from '@/types'
const WikiDetailPage: FC = () => {
+ const locale = useLocale ()
const params = useParams ()
const title = params.title ?? ''
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const defaultTag = useMemo (() => ({ name: title, category: 'general' } as Tag), [title])
@@ -37,8 +39,8 @@ const WikiDetailPage: FC = () => {
const { data: wikiPage, isLoading: loading, isSuccess, isFetching, error } = useQuery ({
enabled: Boolean (title) && !(/^\d+$/.test (title)),
- queryKey: wikiKeys.show (title, { version }),
- queryFn: () => fetchWikiPageByTitle (title, { version }) })
+ queryKey: wikiKeys.show (title, { version }, locale),
+ queryFn: () => fetchWikiPageByTitle (title, { version }, locale) })
const missingWiki = isSuccess && !(isFetching) && wikiPage == null
const { data: titleIndex, isPending: lookupPending,
@@ -63,8 +65,8 @@ const WikiDetailPage: FC = () => {
const { data: tag, isPending: tagPending,
isFetching: tagFetching, error: tagError } = useQuery ({
enabled: Boolean (effectiveTitle),
- queryKey: tagsKeys.show (effectiveTitle),
- queryFn: () => fetchTagByName (effectiveTitle) })
+ queryKey: tagsKeys.show (effectiveTitle, locale),
+ queryFn: () => fetchTagByName (effectiveTitle, locale) })
const keys = {
tags: effectiveTitle, match: 'all', page: 1, limit: 8, url: '', title: '',
@@ -73,8 +75,8 @@ const WikiDetailPage: FC = () => {
order: 'original_created_at:desc' } as const
const { data } = useQuery ({
enabled: Boolean (effectiveTitle) && !(version),
- queryKey: postsKeys.index (keys),
- queryFn: () => fetchPosts (keys) })
+ queryKey: postsKeys.index (keys, locale),
+ queryFn: () => fetchPosts (keys, locale) })
const posts = data?.posts || []
useEffect (() => {
@@ -97,7 +99,7 @@ const WikiDetailPage: FC = () => {
void (async () => {
try
{
- const data = await fetchWikiPage (title, { })
+ const data = await fetchWikiPage (title, { }, locale)
if (active)
navigate (`/wiki/${ encodeURIComponent (data.title) }`, { replace: true })
}
@@ -110,7 +112,7 @@ const WikiDetailPage: FC = () => {
return () => {
active = false
}
- }, [title, navigate])
+ }, [title, navigate, locale])
const displayError = error ?? (missingWiki ? lookupError ?? tagError : null)
if (displayError != null)
diff --git a/frontend/src/pages/wiki/WikiDiffPage.tsx b/frontend/src/pages/wiki/WikiDiffPage.tsx
index 5206f2e..b30533e 100644
--- a/frontend/src/pages/wiki/WikiDiffPage.tsx
+++ b/frontend/src/pages/wiki/WikiDiffPage.tsx
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation, useParams } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
import { SITE_TITLE } from '@/config'
@@ -14,6 +15,7 @@ import type { WikiPageDiff } from '@/types'
const WikiDiffPage: FC = () => {
+ const locale = useLocale ()
const { id } = useParams ()
const location = useLocation ()
@@ -29,9 +31,9 @@ const WikiDiffPage: FC = () => {
useEffect (() => {
void (async () => {
- setDiff (await apiGet (`/wiki/${ id }/diff`, { params: { from, to } }))
+ setDiff (await apiGet (`/wiki/${ id }/diff`, { locale, params: { from, to } }))
}) ()
- }, [from, id, to])
+ }, [from, id, to, locale])
return (
diff --git a/frontend/src/pages/wiki/WikiEditPage.tsx b/frontend/src/pages/wiki/WikiEditPage.tsx
index 5b95db9..ef41c70 100644
--- a/frontend/src/pages/wiki/WikiEditPage.tsx
+++ b/frontend/src/pages/wiki/WikiEditPage.tsx
@@ -3,8 +3,9 @@ import MarkdownIt from 'markdown-it'
import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import MdEditor from 'react-markdown-editor-lite'
-import { useParams, useNavigate } from 'react-router-dom'
+import { useParams } from 'react-router-dom'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import FieldError from '@/components/common/FieldError'
import FormField from '@/components/common/FormField'
import MainArea from '@/components/layout/MainArea'
@@ -36,11 +37,12 @@ type WikiFormField = 'title' | 'body'
const WikiEditPage: FC = ({ user }) => {
+ const locale = useLocale ()
const editable = canEditContent (user)
const { id } = useParams ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const qc = useQueryClient ()
@@ -60,8 +62,8 @@ const WikiEditPage: FC = ({ user }) => {
try
{
await apiPut (`/wiki/${ id }`, formData,
- { headers: { 'Content-Type': 'multipart/form-data' } })
- qc.setQueryData (wikiKeys.show (title, { }),
+ { locale, headers: { 'Content-Type': 'multipart/form-data' } })
+ qc.setQueryData (wikiKeys.show (title, { }, locale),
(prev: WikiPage) => ({ ...prev, title, body }))
qc.invalidateQueries ({ queryKey: wikiKeys.root })
toast ({ title: '投稿成功!' })
@@ -80,12 +82,12 @@ const WikiEditPage: FC = ({ user }) => {
void (async () => {
setLoading (true)
- const data = await apiGet (`/wiki/${ id }`)
+ const data = await apiGet (`/wiki/${ id }`, { locale })
setTitle (data.title)
setBody (data.body)
setLoading (false)
}) ()
- }, [editable, id])
+ }, [editable, id, locale])
if (!(editable))
return
diff --git a/frontend/src/pages/wiki/WikiHistoryPage.tsx b/frontend/src/pages/wiki/WikiHistoryPage.tsx
index 0affe21..2d072e7 100644
--- a/frontend/src/pages/wiki/WikiHistoryPage.tsx
+++ b/frontend/src/pages/wiki/WikiHistoryPage.tsx
@@ -4,6 +4,7 @@ import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
import { useLocation } from 'react-router-dom'
+import { useLocale } from '@/lib/useLocale'
import PrefetchLink from '@/components/PrefetchLink'
import PageTitle from '@/components/common/PageTitle'
import MainArea from '@/components/layout/MainArea'
@@ -15,6 +16,7 @@ import type { WikiPageChange } from '@/types'
const WikiHistoryPage: FC = () => {
+ const locale = useLocale ()
const [changes, setChanges] = useState ([])
const location = useLocation ()
@@ -23,9 +25,9 @@ const WikiHistoryPage: FC = () => {
useEffect (() => {
void (async () => {
- setChanges (await apiGet ('/wiki/changes', { params: id ? { id } : { } }))
+ setChanges (await apiGet ('/wiki/changes', { locale, params: id ? { id } : { } }))
}) ()
- }, [id, location.search])
+ }, [id, location.search, locale])
return (
diff --git a/frontend/src/pages/wiki/WikiNewPage.tsx b/frontend/src/pages/wiki/WikiNewPage.tsx
index 60ee6a9..7b107fa 100644
--- a/frontend/src/pages/wiki/WikiNewPage.tsx
+++ b/frontend/src/pages/wiki/WikiNewPage.tsx
@@ -3,9 +3,10 @@ import MarkdownIt from 'markdown-it'
import { useState } from 'react'
import { Helmet } from 'react-helmet-async'
import MdEditor from 'react-markdown-editor-lite'
-import { useLocation, useNavigate } from 'react-router-dom'
+import { useLocation } from 'react-router-dom'
import 'react-markdown-editor-lite/lib/index.css'
+import { useLocale, useLocaleNavigate } from '@/lib/useLocale'
import FieldError from '@/components/common/FieldError'
import FormField from '@/components/common/FormField'
import MainArea from '@/components/layout/MainArea'
@@ -35,10 +36,11 @@ type WikiFormField = 'title' | 'body'
const WikiNewPage: FC = ({ user }) => {
+ const locale = useLocale ()
const editable = canEditContent (user)
const location = useLocation ()
- const navigate = useNavigate ()
+ const navigate = useLocaleNavigate ()
const qc = useQueryClient ()
const query = new URLSearchParams (location.search)
@@ -59,9 +61,9 @@ const WikiNewPage: FC = ({ user }) => {
try
{
const data = await apiPost ('/wiki', formData,
- { headers: { 'Content-Type': 'multipart/form-data' } })
+ { locale, headers: { 'Content-Type': 'multipart/form-data' } })
await qc.cancelQueries ({ queryKey: wikiKeys.root })
- qc.setQueryData (wikiKeys.show (data.title, { }), data)
+ qc.setQueryData (wikiKeys.show (data.title, { }, locale), data)
await Promise.all ([
qc.invalidateQueries ({ queryKey: wikiKeys.root }),
qc.invalidateQueries ({ queryKey: tagsKeys.root })])
diff --git a/frontend/src/pages/wiki/WikiSearchPage.tsx b/frontend/src/pages/wiki/WikiSearchPage.tsx
index 3bb9465..97dc047 100644
--- a/frontend/src/pages/wiki/WikiSearchPage.tsx
+++ b/frontend/src/pages/wiki/WikiSearchPage.tsx
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'
import { Helmet } from 'react-helmet-async'
+import { useLocale } from '@/lib/useLocale'
import PrefetchLink from '@/components/PrefetchLink'
import FormField from '@/components/common/FormField'
import PageTitle from '@/components/common/PageTitle'
@@ -15,12 +16,13 @@ import type { WikiPage } from '@/types'
const WikiSearchPage: FC = () => {
+ const locale = useLocale ()
const [title, setTitle] = useState ('')
const [text, setText] = useState ('')
const [results, setResults] = useState ([])
const search = async () => {
- setResults (await apiGet ('/wiki', { params: { title } }))
+ setResults (await apiGet ('/wiki', { locale, params: { title } }))
}
const handleSearch = (ev: FormEvent) => {
@@ -30,9 +32,9 @@ const WikiSearchPage: FC = () => {
useEffect (() => {
void (async () => {
- setResults (await apiGet ('/wiki', { params: { title: '' } }))
+ setResults (await apiGet ('/wiki', { locale, params: { title: '' } }))
}) ()
- }, [])
+ }, [locale])
return (
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index f1d6e9f..8dcd703 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -16,7 +16,7 @@ if (typeof originalTransform === 'function')
function (code, id)
{
return (/[?&](raw|url)(?:&|$)/.test (id)
- ? null
+ ? Promise.resolve (undefined)
: originalTransform.call (this, code, id))
}
}