From 6de8517bb5d376d2179229242cc0bbc8df564214 Mon Sep 17 00:00:00 2001 From: Rishi Ghan Date: Thu, 11 Apr 2024 09:58:53 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=8D=20Added=20i18n=20lib?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++ src/client/components/Search/Search.tsx | 36 ++++++++---- .../SystemSettings/SystemSettingsForm.tsx | 2 +- .../components/shared/PopoverButton.tsx | 8 ++- src/client/index.tsx | 1 + src/client/locales/en/translation.json | 4 ++ src/client/shared/utils/i18n.util.ts | 25 ++++++++ yarn.lock | 57 ++++++++++++++++++- 8 files changed, 121 insertions(+), 16 deletions(-) create mode 100644 src/client/locales/en/translation.json create mode 100644 src/client/shared/utils/i18n.util.ts diff --git a/package.json b/package.json index 4fdc1c9..fcf0a9d 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,9 @@ "focus-trap-react": "^10.2.3", "history": "^5.3.0", "html-to-text": "^8.1.0", + "i18next": "^23.11.1", + "i18next-browser-languagedetector": "^7.2.1", + "i18next-http-backend": "^2.5.0", "immer": "^10.0.3", "jsdoc": "^3.6.10", "keen-slider": "^6.8.6", @@ -58,6 +61,7 @@ "react-fast-compare": "^3.2.0", "react-final-form": "^6.5.9", "react-final-form-arrays": "^3.1.4", + "react-i18next": "^14.1.0", "react-loader-spinner": "^4.0.0", "react-modal": "^3.15.1", "react-router": "^6.9.0", diff --git a/src/client/components/Search/Search.tsx b/src/client/components/Search/Search.tsx index b1feb81..f7cb4a9 100644 --- a/src/client/components/Search/Search.tsx +++ b/src/client/components/Search/Search.tsx @@ -6,6 +6,8 @@ import { Form, Field } from "react-final-form"; import Card from "../shared/Carda"; import ellipsize from "ellipsize"; import { convert } from "html-to-text"; +import { useTranslation } from "react-i18next"; +import "../../shared/utils/i18n.util"; // Ensure you import your i18n configuration import PopoverButton from "../shared/PopoverButton"; import dayjs from "dayjs"; import { useMutation, useQuery } from "@tanstack/react-query"; @@ -23,7 +25,7 @@ export const Search = ({}: ISearchProps): ReactElement => { }; const [comicVineMetadata, setComicVineMetadata] = useState({}); const [selectedResource, setSelectedResource] = useState("volume"); - + const { t } = useTranslation(); const handleResourceChange = (value) => { setSelectedResource(value); }; @@ -293,19 +295,24 @@ export const Search = ({}: ISearchProps): ReactElement => { )} {result.start_year && <> ({result.start_year})} +
{/* issue count */} -
- - - - + {result.count_of_issues && ( +
+ + + + - - {result.count_of_issues} issues + + {t("issueWithCount", { + count: result.count_of_issues, + })} + - -
+
+ )} {/* type: TPB, one-shot, graphic novel etc. */} {!isNil(result.description) && !isUndefined(result.description) && ( @@ -351,7 +358,14 @@ export const Search = ({}: ISearchProps): ReactElement => { )}

- + {/* onClick={() => addToLibrary("comicvine", result) */}
diff --git a/src/client/components/Settings/SystemSettings/SystemSettingsForm.tsx b/src/client/components/Settings/SystemSettings/SystemSettingsForm.tsx index 8395ba7..9081822 100644 --- a/src/client/components/Settings/SystemSettings/SystemSettingsForm.tsx +++ b/src/client/components/Settings/SystemSettings/SystemSettingsForm.tsx @@ -48,7 +48,7 @@ export const SystemSettingsForm = (): ReactElement => {