mirror of
https://github.com/docmost/docmost.git
synced 2025-11-16 22:31:13 +10:00
feat: add query translation
This commit is contained in:
5
apps/client/public/locales/en/search.json
Normal file
5
apps/client/public/locales/en/search.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Search...": "Search...",
|
||||||
|
"Start typing to search...": "Start typing to search...",
|
||||||
|
"No results found...": "No results found..."
|
||||||
|
}
|
||||||
5
apps/client/public/locales/zh/search.json
Normal file
5
apps/client/public/locales/zh/search.json
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"Search...": "搜索...",
|
||||||
|
"Start typing to search...": "开始输入以搜索...",
|
||||||
|
"No results found...": "未找到结果..."
|
||||||
|
}
|
||||||
@ -6,11 +6,13 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { useDebouncedValue } from "@mantine/hooks";
|
import { useDebouncedValue } from "@mantine/hooks";
|
||||||
import { usePageSearchQuery } from "@/features/search/queries/search-query";
|
import { usePageSearchQuery } from "@/features/search/queries/search-query";
|
||||||
import { buildPageUrl } from "@/features/page/page.utils.ts";
|
import { buildPageUrl } from "@/features/page/page.utils.ts";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
interface SearchSpotlightProps {
|
interface SearchSpotlightProps {
|
||||||
spaceId?: string;
|
spaceId?: string;
|
||||||
}
|
}
|
||||||
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
||||||
|
const { t } = useTranslation("search");
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const [query, setQuery] = useState("");
|
const [query, setQuery] = useState("");
|
||||||
const [debouncedSearchQuery] = useDebouncedValue(query, 300);
|
const [debouncedSearchQuery] = useDebouncedValue(query, 300);
|
||||||
@ -65,16 +67,16 @@ export function SearchSpotlight({ spaceId }: SearchSpotlightProps) {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Spotlight.Search
|
<Spotlight.Search
|
||||||
placeholder="Search..."
|
placeholder={t("Search...")}
|
||||||
leftSection={<IconSearch size={20} stroke={1.5} />}
|
leftSection={<IconSearch size={20} stroke={1.5} />}
|
||||||
/>
|
/>
|
||||||
<Spotlight.ActionsList>
|
<Spotlight.ActionsList>
|
||||||
{query.length === 0 && pages.length === 0 && (
|
{query.length === 0 && pages.length === 0 && (
|
||||||
<Spotlight.Empty>Start typing to search...</Spotlight.Empty>
|
<Spotlight.Empty>{t("Start typing to search...")}</Spotlight.Empty>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{query.length > 0 && pages.length === 0 && (
|
{query.length > 0 && pages.length === 0 && (
|
||||||
<Spotlight.Empty>No results found...</Spotlight.Empty>
|
<Spotlight.Empty>{t("No results found...")}</Spotlight.Empty>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{pages.length > 0 && pages}
|
{pages.length > 0 && pages}
|
||||||
|
|||||||
Reference in New Issue
Block a user