Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 50 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
"focus-trap-react": "^12.0.0",
"formik": "^2.4.9",
"http-proxy-middleware": "^3.0.5",
"i18next": "25.8.11",
"i18next": "26.0.7",
"i18next-browser-languagedetector": "^8.2.1",
"i18next-http-backend": "^3.0.5",
"i18next-http-backend": "^3.0.6",
"lodash": "^4.17.23",
"react": "^19.2.4",
"react-chartjs-2": "^5.3.1",
"react-datepicker": "^8.8.0",
"react-dom": "^19.2.4",
"react-hotkeys-hook": "^5.2.4",
"react-i18next": "16.5.0",
"react-i18next": "17.0.4",
"react-icons": "^5.5.0",
"react-redux": "^9.2.0",
"react-router": "^7.13.0",
Expand Down Expand Up @@ -67,14 +67,14 @@
"@types/node": "^25.3.0",
"@types/react-dom": "^19.2.3",
"@types/uuid": "^11.0.0",
"@vitejs/plugin-react": "^6.0.1",
"eslint": "^9.39.2",
"prop-types": "^15.8.1",
"sass": "^1.97.3",
"typescript": "^5.9.3",
"typescript-eslint": "^8.56.0",
"uuid": "^13.0.0",
"vite": "^8.0.9",
"@vitejs/plugin-react": "^6.0.1",
"vitest": "^4.0.18"
}
}
34 changes: 22 additions & 12 deletions src/i18n/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import i18n from "i18next";
import i18n, { FormatterModule } from "i18next";
import { initReactI18next } from "react-i18next";

import HttpBackend, { HttpBackendOptions } from "i18next-http-backend";
Expand All @@ -23,7 +23,7 @@ import trTRTrans from "./org/opencastproject/adminui/languages/lang-tr_TR.json";
import zhCNTrans from "./org/opencastproject/adminui/languages/lang-zh_CN.json";
import zhTWTrans from "./org/opencastproject/adminui/languages/lang-zh_TW.json";
import { getCurrentLanguageInformation } from "../utils/utils";
import { format } from "date-fns/format";
import { format as dateFnsFormat } from "date-fns/format";

// Assignment of language code to translation file
// !!! If translation file of a new language is added, please add assignment here, too !!!
Expand All @@ -47,29 +47,39 @@ const resources = {
"zh-TW": { translation: zhTWTrans },
} as const;

const myFormatter: FormatterModule = {
type: "formatter",
init(_services, _i18nextOptions) {},
format(value, format, lng, _options) {
if (value instanceof Date && format && lng) {
return dateFnsFormat(value, format, {
locale: getCurrentLanguageInformation(lng)?.dateLocale,
});
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return value;
},
add(_name, _fc) { },
addCached(_name, _fc) { },
};

// Configuration of i18next
i18n
.use(HttpBackend)
.use(LanguageDetector)
.use(initReactI18next)
.use(myFormatter)
.init<HttpBackendOptions>({
resources,
fallbackLng: "en-US",
debug: false,

interpolation: {
escapeValue: false,
format: function (value, formatStr, lng) {
if (value instanceof Date && formatStr && lng) {
return format(value, formatStr, {
locale: getCurrentLanguageInformation(lng)?.dateLocale,
});
}

// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return value;
},
alwaysFormat: true,
},

react: {
useSuspense: false,
},
Expand Down
Loading