Skip to content

Commit 2c67140

Browse files
Add translations to search locations box
1 parent 1c3da97 commit 2c67140

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

client/src/components/ui/search-location.tsx

+15-11
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useTranslations } from "@/i18n";
12
import { PropsWithChildren } from "react";
23

34
type SearchResultListProps = PropsWithChildren & {
@@ -43,16 +44,19 @@ const SearchResultItem = <T,>({ option, onOptionClick, children }: SearchResultI
4344
);
4445
};
4546

46-
const SearchResultItemNotFound = ({ children }: PropsWithChildren) => (
47-
<li
48-
role="option"
49-
aria-selected="false"
50-
tabIndex={0}
51-
className="flex gap-2 rounded px-2 py-2 text-sm opacity-70"
52-
>
53-
{children}
54-
<span className="line-clamp-2">No results</span>
55-
</li>
56-
);
47+
const SearchResultItemNotFound = ({ children }: PropsWithChildren) => {
48+
const t = useTranslations();
49+
return (
50+
<li
51+
role="option"
52+
aria-selected="false"
53+
tabIndex={0}
54+
className="flex gap-2 rounded px-2 py-2 text-sm opacity-70"
55+
>
56+
{children}
57+
<span className="line-clamp-2">{t("No results")}</span>
58+
</li>
59+
);
60+
};
5761

5862
export { SearchResultList, SearchResultItem, SearchResultItemNotFound };

client/src/containers/map/search-location/index.tsx

+6-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
SearchResultList,
99
} from "@/components/ui/search-location";
1010
import { useOpenStreetMapsLocations } from "@/hooks/openstreetmaps";
11+
import { useTranslations } from "@/i18n";
1112
import { cn } from "@/lib/utils";
1213
import { PopoverClose } from "@radix-ui/react-popover";
1314
import { ChevronRightIcon, MapIcon, MapPinIcon, SearchIcon, XIcon } from "lucide-react";
@@ -27,6 +28,8 @@ type SearchLocationProps = {
2728
onOpenChange: (open: boolean) => void;
2829
};
2930
const SearchLocation = ({ onOpenChange }: SearchLocationProps) => {
31+
const t = useTranslations();
32+
3033
const [open, setOpen] = useState(true);
3134
const [locationSearch, setLocationSearch] = useState("");
3235

@@ -118,7 +121,6 @@ const SearchLocation = ({ onOpenChange }: SearchLocationProps) => {
118121
</PopoverTrigger>
119122
<PopoverContent
120123
align={!debouncedSearch.length ? "center" : "start"}
121-
// alignOffset={20}
122124
sideOffset={20}
123125
side="left"
124126
className={cn(
@@ -133,7 +135,7 @@ const SearchLocation = ({ onOpenChange }: SearchLocationProps) => {
133135
onChange={handleSearchChange}
134136
type="text"
135137
value={locationSearch}
136-
placeholder="Search"
138+
placeholder={t("Search")}
137139
className="w-full border-2 border-background bg-background p-2 px-9 text-sm leading-none text-foreground placeholder:text-sm placeholder:font-light placeholder:text-popover-foreground/50 focus-visible:outline-global"
138140
/>
139141
{locationSearch.length >= 1 && (
@@ -152,7 +154,7 @@ const SearchLocation = ({ onOpenChange }: SearchLocationProps) => {
152154
</div>
153155

154156
{!!debouncedSearch.length && (
155-
<SearchResultList title="Locations">
157+
<SearchResultList title={t("Locations")}>
156158
{!!locationOptions?.length ? (
157159
locationOptions.map((option) => (
158160
<SearchResultItem
@@ -172,7 +174,7 @@ const SearchLocation = ({ onOpenChange }: SearchLocationProps) => {
172174
)}
173175

174176
{!!debouncedSearch?.length && (
175-
<SearchResultList title="Rangelands stories">
177+
<SearchResultList title={t("Rangelands stories")}>
176178
{storiesOptions?.length ? (
177179
storiesOptions.map((option) => (
178180
<SearchResultItem

0 commit comments

Comments
 (0)