From 181119d1e23054e8ce16ff21c50f4ec08439125e Mon Sep 17 00:00:00 2001 From: Lukas Kalbertodt Date: Tue, 12 Sep 2023 14:42:42 +0200 Subject: [PATCH] Update `i18next` to 23 --- frontend/package-lock.json | 22 +++++++++++----------- frontend/package.json | 4 ++-- frontend/src/util/err.tsx | 12 ++++-------- 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 9999a2ecc..084acb56b 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -22,7 +22,7 @@ "focus-trap-react": "^10.2.1", "graphql": "^16.8.0", "hls.js": "^1.4.12", - "i18next": "^22.5.1", + "i18next": "^23.5.1", "i18next-browser-languagedetector": "^7.1.0", "paella-basic-plugins": "1.31.2", "paella-core": "1.41.0", @@ -33,7 +33,7 @@ "react-beforeunload": "^2.6.0", "react-dom": "^18.2.0", "react-hook-form": "^7.46.1", - "react-i18next": "^12.3.1", + "react-i18next": "^13.2.2", "react-icons": "^4.11.0", "react-markdown": "^8.0.7", "react-merge-refs": "^2.0.2", @@ -5611,9 +5611,9 @@ } }, "node_modules/i18next": { - "version": "22.5.1", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-22.5.1.tgz", - "integrity": "sha512-8TGPgM3pAD+VRsMtUMNknRz3kzqwp/gPALrWMsDnmC1mKqJwpWyooQRLMcbTwq8z8YwSmuj+ZYvc+xCuEpkssA==", + "version": "23.5.1", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.5.1.tgz", + "integrity": "sha512-JelYzcaCoFDaa+Ysbfz2JsGAKkrHiMG6S61+HLBUEIPaF40WMwW9hCPymlQGrP+wWawKxKPuSuD71WZscCsWHg==", "funding": [ { "type": "individual", @@ -5629,7 +5629,7 @@ } ], "dependencies": { - "@babel/runtime": "^7.20.6" + "@babel/runtime": "^7.22.5" } }, "node_modules/i18next-browser-languagedetector": { @@ -7724,15 +7724,15 @@ } }, "node_modules/react-i18next": { - "version": "12.3.1", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-12.3.1.tgz", - "integrity": "sha512-5v8E2XjZDFzK7K87eSwC7AJcAkcLt5xYZ4+yTPDAW1i7C93oOY1dnr4BaQM7un4Hm+GmghuiPvevWwlca5PwDA==", + "version": "13.2.2", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-13.2.2.tgz", + "integrity": "sha512-+nFUkbRByFwnrfDcYqvzBuaeZb+nACHx+fAWN/pZMddWOCJH5hoc21+Sa/N/Lqi6ne6/9wC/qRGOoQhJa6IkEQ==", "dependencies": { - "@babel/runtime": "^7.20.6", + "@babel/runtime": "^7.22.5", "html-parse-stringify": "^3.0.1" }, "peerDependencies": { - "i18next": ">= 19.0.0", + "i18next": ">= 23.2.3", "react": ">= 16.8.0" }, "peerDependenciesMeta": { diff --git a/frontend/package.json b/frontend/package.json index f88f3c4d7..349aaf3cc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -38,7 +38,7 @@ "focus-trap-react": "^10.2.1", "graphql": "^16.8.0", "hls.js": "^1.4.12", - "i18next": "^22.5.1", + "i18next": "^23.5.1", "i18next-browser-languagedetector": "^7.1.0", "paella-basic-plugins": "1.31.2", "paella-core": "1.41.0", @@ -49,7 +49,7 @@ "react-beforeunload": "^2.6.0", "react-dom": "^18.2.0", "react-hook-form": "^7.46.1", - "react-i18next": "^12.3.1", + "react-i18next": "^13.2.2", "react-icons": "^4.11.0", "react-markdown": "^8.0.7", "react-merge-refs": "^2.0.2", diff --git a/frontend/src/util/err.tsx b/frontend/src/util/err.tsx index 22f7b041a..c38531a20 100644 --- a/frontend/src/util/err.tsx +++ b/frontend/src/util/err.tsx @@ -1,4 +1,4 @@ -import { i18n, TFuncKey } from "i18next"; +import { i18n, ParseKeys } from "i18next"; import React from "react"; import { ReactNode } from "react"; import { useTranslation } from "react-i18next"; @@ -73,13 +73,9 @@ export const errorDisplayInfo = (error: unknown, i18n: i18n): ErrorDisplayInfo = // Use a message fitting to the exact error key, if it is present. const translationKey = err.key ? `api-remote-errors.${err.key}` : null; if (translationKey && i18n.exists(translationKey)) { - const msg = t(translationKey as TFuncKey); - - // It could still refer to an object, which would be a bug. - if (typeof msg === "string") { - causes.add(msg); - continue; - } + const msg = t(translationKey as ParseKeys); + causes.add(msg); + continue; } // Otherwise, derive an error message from the error kind. We