diff --git a/package-lock.json b/package-lock.json index 2d2159273..3e47c2f97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,6 @@ "https-proxy-agent": "7.0.6", "i18next": "24.2.2", "i18next-fs-backend": "2.6.0", - "i18next-http-backend": "3.0.2", "image-type": "5.2.0", "ini": "5.0.0", "is-animated": "2.0.2", @@ -92,7 +91,6 @@ "serve-favicon": "2.5.0", "session-file-store": "1.5.0", "source-map-support": "0.5.21", - "split.js": "1.6.5", "stream-throttle": "0.1.3", "strip-bom": "5.0.0", "striptags": "3.2.0", @@ -168,6 +166,7 @@ "css-loader": "7.1.2", "electron": "34.3.0", "esm": "3.2.25", + "i18next-http-backend": "3.0.2", "jsdoc": "4.0.4", "lorem-ipsum": "2.0.8", "mini-css-extract-plugin": "2.9.2", @@ -178,6 +177,7 @@ "rimraf": "6.0.1", "sass": "1.85.1", "sass-loader": "16.0.5", + "split.js": "1.6.5", "supertest": "7.0.0", "swagger-jsdoc": "6.2.8", "tslib": "2.8.1", @@ -7364,6 +7364,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-4.0.0.tgz", "integrity": "sha512-e4a5N8lVvuLgAWgnCrLr2PP0YyDOTHa9H/Rj54dirp61qXnNq46m82bRhNqIA5VccJtWBvPTFRV3TtvHUKPB1g==", + "dev": true, "license": "MIT", "dependencies": { "node-fetch": "^2.6.12" @@ -9357,6 +9358,7 @@ "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", "integrity": "sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -11410,6 +11412,7 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/i18next-http-backend/-/i18next-http-backend-3.0.2.tgz", "integrity": "sha512-PdlvPnvIp4E1sYi46Ik4tBYh/v/NbYfFFgTjkwFl0is8A18s7/bx9aXqsrOax9WUbeNS6mD2oix7Z0yGGf6m5g==", + "dev": true, "license": "MIT", "dependencies": { "cross-fetch": "4.0.0" @@ -13516,6 +13519,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -13536,18 +13540,21 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, "license": "MIT" }, "node_modules/node-fetch/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/node-fetch/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, "license": "MIT", "dependencies": { "tr46": "~0.0.3", @@ -16662,6 +16669,7 @@ "version": "1.6.5", "resolved": "https://registry.npmjs.org/split.js/-/split.js-1.6.5.tgz", "integrity": "sha512-mPTnGCiS/RiuTNsVhCm9De9cCAUsrNFFviRbADdKiiV+Kk8HKp/0fWu7Kr8pi3/yBmsqLFHuXGT9UUZ+CNLwFw==", + "dev": true, "license": "MIT" }, "node_modules/sprintf-js": { diff --git a/package.json b/package.json index 28a19f008..df6569be5 100644 --- a/package.json +++ b/package.json @@ -110,7 +110,6 @@ "https-proxy-agent": "7.0.6", "i18next": "24.2.2", "i18next-fs-backend": "2.6.0", - "i18next-http-backend": "3.0.2", "image-type": "5.2.0", "ini": "5.0.0", "is-animated": "2.0.2", @@ -145,7 +144,6 @@ "serve-favicon": "2.5.0", "session-file-store": "1.5.0", "source-map-support": "0.5.21", - "split.js": "1.6.5", "stream-throttle": "0.1.3", "strip-bom": "5.0.0", "striptags": "3.2.0", @@ -218,6 +216,7 @@ "css-loader": "7.1.2", "electron": "34.3.0", "esm": "3.2.25", + "i18next-http-backend": "3.0.2", "jsdoc": "4.0.4", "lorem-ipsum": "2.0.8", "mini-css-extract-plugin": "2.9.2", @@ -228,6 +227,7 @@ "rimraf": "6.0.1", "sass": "1.85.1", "sass-loader": "16.0.5", + "split.js": "1.6.5", "supertest": "7.0.0", "swagger-jsdoc": "6.2.8", "tslib": "2.8.1", diff --git a/src/public/app/services/frontend_script_api.ts b/src/public/app/services/frontend_script_api.ts index 178b0aa59..86a793c9f 100644 --- a/src/public/app/services/frontend_script_api.ts +++ b/src/public/app/services/frontend_script_api.ts @@ -17,6 +17,7 @@ import shortcutService from "./shortcuts.js"; import dialogService from "./dialog.js"; import type FNote from "../entities/fnote.js"; import { t } from "./i18n.js"; +import dayjs from "dayjs"; import type NoteContext from "../components/note_context.js"; import type NoteDetailWidget from "../widgets/note_detail.js"; import type Component from "../components/component.js"; @@ -84,7 +85,7 @@ interface Api { * See {@link https://day.js.org} for documentation * @see https://day.js.org */ - dayjs: typeof window.dayjs; + dayjs: typeof dayjs; RightPanelWidget: typeof RightPanelWidget; NoteContextAwareWidget: typeof NoteContextAwareWidget; diff --git a/src/public/app/services/i18n.ts b/src/public/app/services/i18n.ts index 48b3be72e..449381f06 100644 --- a/src/public/app/services/i18n.ts +++ b/src/public/app/services/i18n.ts @@ -1,7 +1,6 @@ -import library_loader from "./library_loader.js"; import options from "./options.js"; - -await library_loader.requireLibrary(library_loader.I18NEXT); +import i18next from "i18next"; +import i18nextHttpBackend from "i18next-http-backend"; export async function initLocale() { const locale = (options.get("locale") as string) || "en"; @@ -17,3 +16,4 @@ export async function initLocale() { } export const t = i18next.t; +export const getCurrentLanguage = () => i18next.language; diff --git a/src/public/app/services/library_loader.ts b/src/public/app/services/library_loader.ts index 063757a59..829184155 100644 --- a/src/public/app/services/library_loader.ts +++ b/src/public/app/services/library_loader.ts @@ -72,10 +72,6 @@ const MARKJS: Library = { js: ["node_modules/mark.js/dist/jquery.mark.es6.min.js"] }; -const I18NEXT: Library = { - js: ["node_modules/i18next/i18next.min.js", "node_modules/i18next-http-backend/i18nextHttpBackend.min.js"] -}; - const HIGHLIGHT_JS: Library = { js: () => { const mimeTypes = mimeTypesService.getMimeTypes(); @@ -194,7 +190,6 @@ export default { WHEEL_ZOOM, MERMAID, MARKJS, - I18NEXT, HIGHLIGHT_JS, LEAFLET }; diff --git a/src/public/app/services/resizer.ts b/src/public/app/services/resizer.ts index d6e828047..164f82eae 100644 --- a/src/public/app/services/resizer.ts +++ b/src/public/app/services/resizer.ts @@ -1,4 +1,5 @@ import options from "./options.js"; +import Split from "split.js" let leftInstance: ReturnType | null; let rightInstance: ReturnType | null; diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.ts index 1ef429650..a37df7f74 100644 --- a/src/public/app/types.d.ts +++ b/src/public/app/types.d.ts @@ -1,7 +1,5 @@ import type FNote from "./entities/fnote"; -import type { BackendModule, i18n } from "i18next"; import type { Froca } from "./services/froca-interface"; -import type { HttpBackendOptions } from "i18next-http-backend"; import { Suggestion } from "./services/note_autocomplete.ts"; import utils from "./services/utils.ts"; import appContext from "./components/app_context.ts"; @@ -115,22 +113,12 @@ declare global { // Libraries // TODO: Replace once library loader is replaced with webpack. - var i18next: i18n; - var i18nextHttpBackend: BackendModule; var hljs: { highlightAuto(text: string); highlight(text: string, { language: string }); }; - var dayjs: {}; - var Split: (selectors: string[], config: { - sizes: [ number, number ]; - gutterSize: number; - onDragEnd: (sizes: [ number, number ]) => void; - }) => { - destroy(); - }; var renderMathInElement: (element: HTMLElement, options: { trust: boolean; }) => void; diff --git a/src/public/app/widgets/type_widgets/doc.ts b/src/public/app/widgets/type_widgets/doc.ts index 57fc7eda8..12eff71f3 100644 --- a/src/public/app/widgets/type_widgets/doc.ts +++ b/src/public/app/widgets/type_widgets/doc.ts @@ -2,6 +2,7 @@ import type { EventData } from "../../components/app_context.js"; import type FNote from "../../entities/fnote.js"; import { applySyntaxHighlight } from "../../services/syntax_highlight.js"; import TypeWidget from "./type_widget.js"; +import { getCurrentLanguage } from "../../services/i18n.js"; const TPL = `