From a52ba773478e1e2b3c569e5c0f9e21179b490f12 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Thu, 13 Jul 2023 10:17:59 +0300 Subject: [PATCH] Translateable art tags feature --- app/features/art/routes/art.new.tsx | 19 +++++++++++-------- app/features/art/routes/art.tsx | 8 ++++---- app/routes/u.$identifier/art.tsx | 4 +++- public/locales/en/art.json | 11 ++++++++++- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/app/features/art/routes/art.new.tsx b/app/features/art/routes/art.new.tsx index e99845342..37177d90e 100644 --- a/app/features/art/routes/art.new.tsx +++ b/app/features/art/routes/art.new.tsx @@ -271,6 +271,7 @@ function Description() { // note: not handling edge case where a tag was added by another user while this // user was adding a new art with the same tag -> will crash function Tags() { + const { t } = useTranslation(["art", "common"]); const data = useLoaderData(); const [creationMode, setCreationMode] = React.useState(false); const [tags, setTags] = React.useState<{ name?: string; id?: number }[]>( @@ -314,29 +315,31 @@ function Tags() { return (
{creationMode ? (
) : (
- Can't find an existing tag?{" "} + {t("art:forms.tags.cantFindExisting")}{" "}
)} {tags.length >= ART.TAGS_MAX_LENGTH ? ( -
Max tags reached
+
+ {t("art:forms.tags.maxReached")} +
) : creationMode ? (
setNewTagValue(e.target.value)} @@ -347,7 +350,7 @@ function Tags() { }} />
) : ( @@ -359,7 +362,7 @@ function Tags() { value: String(t.id), }))} inputName="tags" - placeholder="Search existing tags" + placeholder={t("art:forms.tags.searchExisting.placeholder")} initialValue={null} onChange={(selection) => { if (!selection) return; diff --git a/app/features/art/routes/art.tsx b/app/features/art/routes/art.tsx index 0ecd2f0e8..d529e02cb 100644 --- a/app/features/art/routes/art.tsx +++ b/app/features/art/routes/art.tsx @@ -70,7 +70,7 @@ export const loader = async ({ request }: LoaderArgs) => { }; export default function ArtPage() { - const { t } = useTranslation(["art"]); + const { t } = useTranslation(["art", "common"]); const data = useLoaderData(); const [searchParams, setSearchParams] = useSearchParams(); @@ -106,7 +106,7 @@ export default function ArtPage() { value: String(t.id), }))} inputName="tags" - placeholder="Filter by tag" + placeholder={t("art:filterByTag")} initialValue={null} onChange={(selection) => { if (!selection) return; @@ -120,7 +120,7 @@ export default function ArtPage() {
{filteredTag ? (
- Showing results filtered by #{filteredTag}{" "} + {t("art:filteringByTag", { tag: filteredTag })}
) : null} diff --git a/app/routes/u.$identifier/art.tsx b/app/routes/u.$identifier/art.tsx index 5aefa0f9a..7d4a4578e 100644 --- a/app/routes/u.$identifier/art.tsx +++ b/app/routes/u.$identifier/art.tsx @@ -136,7 +136,9 @@ export default function UserArtPage() { } className="w-max" > - + {data.tagCounts.map(([tag, count]) => (