diff --git a/package-lock.json b/package-lock.json index ecbc6c6a8..5db40d4a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1342,6 +1342,156 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", "optional": true }, + "node_modules/@next/env": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/env/-/env-14.0.4.tgz", + "integrity": "sha512-irQnbMLbUNQpP1wcE5NstJtbuA/69kRfzBrpAD7Gsn8zm/CY6YQYc3HQBz8QPxwISG26tIm5afvvVbu508oBeQ==", + "peer": true + }, + "node_modules/@next/swc-darwin-arm64": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-14.0.4.tgz", + "integrity": "sha512-mF05E/5uPthWzyYDyptcwHptucf/jj09i2SXBPwNzbgBNc+XnwzrL0U6BmPjQeOL+FiB+iG1gwBeq7mlDjSRPg==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-darwin-x64": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-14.0.4.tgz", + "integrity": "sha512-IZQ3C7Bx0k2rYtrZZxKKiusMTM9WWcK5ajyhOZkYYTCc8xytmwSzR1skU7qLgVT/EY9xtXDG0WhY6fyujnI3rw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-gnu": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-14.0.4.tgz", + "integrity": "sha512-VwwZKrBQo/MGb1VOrxJ6LrKvbpo7UbROuyMRvQKTFKhNaXjUmKTu7wxVkIuCARAfiI8JpaWAnKR+D6tzpCcM4w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-arm64-musl": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-14.0.4.tgz", + "integrity": "sha512-8QftwPEW37XxXoAwsn+nXlodKWHfpMaSvt81W43Wh8dv0gkheD+30ezWMcFGHLI71KiWmHK5PSQbTQGUiidvLQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-gnu": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-14.0.4.tgz", + "integrity": "sha512-/s/Pme3VKfZAfISlYVq2hzFS8AcAIOTnoKupc/j4WlvF6GQ0VouS2Q2KEgPuO1eMBwakWPB1aYFIA4VNVh667A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-linux-x64-musl": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-14.0.4.tgz", + "integrity": "sha512-m8z/6Fyal4L9Bnlxde5g2Mfa1Z7dasMQyhEhskDATpqr+Y0mjOBZcXQ7G5U+vgL22cI4T7MfvgtrM2jdopqWaw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-arm64-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-14.0.4.tgz", + "integrity": "sha512-7Wv4PRiWIAWbm5XrGz3D8HUkCVDMMz9igffZG4NB1p4u1KoItwx9qjATHz88kwCEal/HXmbShucaslXCQXUM5w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-ia32-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-14.0.4.tgz", + "integrity": "sha512-zLeNEAPULsl0phfGb4kdzF/cAVIfaC7hY+kt0/d+y9mzcZHsMS3hAS829WbJ31DkSlVKQeHEjZHIdhN+Pg7Gyg==", + "cpu": [ + "ia32" + ], + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/@next/swc-win32-x64-msvc": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-14.0.4.tgz", + "integrity": "sha512-yEh2+R8qDlDCjxVpzOTEpBLQTEFAcP2A8fUFLaWNap9GitYKkKv1//y2S6XY6zsR4rCOPRpU7plYDR+az2n30A==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 10" + } + }, "node_modules/@pdf-lib/standard-fonts": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@pdf-lib/standard-fonts/-/standard-fonts-1.0.0.tgz", @@ -2022,6 +2172,15 @@ "@types/send": "*" } }, + "node_modules/@types/hoist-non-react-statics": { + "version": "3.3.5", + "resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.5.tgz", + "integrity": "sha512-SbcrWzkKBw2cdwRTwQAswfpB9g9LJWfjtUeW/jvNwbhC8cpmmNYVePa+ncbUe0rGTQ7G3Ff6mYUN2VMfLVr+Sg==", + "dependencies": { + "@types/react": "*", + "hoist-non-react-statics": "^3.3.0" + } + }, "node_modules/@types/http-errors": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/http-errors/-/http-errors-2.0.4.tgz", @@ -2606,7 +2765,6 @@ "version": "1.0.30001554", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001554.tgz", "integrity": "sha512-A2E3U//MBwbJVzebddm1YfNp7Nud5Ip+IPn4BozBmn4KqVX7AvluoIDFWjsv5OkGnKUXQVmMSoMKLa3ScCblcQ==", - "dev": true, "funding": [ { "type": "opencollective", @@ -2711,6 +2869,12 @@ "resolved": "https://registry.npmjs.org/classnames/-/classnames-2.3.2.tgz", "integrity": "sha512-CSbhY4cFEJRe6/GQzIk5qXZ4Jeg5pcsP7b5peFSDpffpe1cqjASH/n9UTjBwOp6XpMSTwQ8Za2K5V02ueA7Tmw==" }, + "node_modules/client-only": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/client-only/-/client-only-0.0.1.tgz", + "integrity": "sha512-IV3Ou0jSMzZrd3pZ48nLkT9DA7Ag1pnPzaiQhpW7c3RbcqqzvzzVu+L8gfqMp/8IM2MQtSiqaCxrrcfu8I8rMA==", + "peer": true + }, "node_modules/cliui": { "version": "8.0.1", "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", @@ -2905,6 +3069,16 @@ "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" }, + "node_modules/core-js": { + "version": "3.35.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.35.0.tgz", + "integrity": "sha512-ntakECeqg81KqMueeGJ79Q5ZgQNR+6eaE8sxGCx62zMbAIj65q+uYvatToew3m6eAGdU4gNZwpZ34NMe4GYswg==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/core-util-is": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.3.tgz", @@ -3466,6 +3640,12 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "peer": true + }, "node_modules/globals": { "version": "11.12.0", "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", @@ -3555,6 +3735,14 @@ "node": ">= 0.4" } }, + "node_modules/hoist-non-react-statics": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz", + "integrity": "sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==", + "dependencies": { + "react-is": "^16.7.0" + } + }, "node_modules/html-parse-stringify": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/html-parse-stringify/-/html-parse-stringify-3.0.1.tgz", @@ -3615,9 +3803,9 @@ "optional": true }, "node_modules/i18next": { - "version": "23.6.0", - "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.6.0.tgz", - "integrity": "sha512-z0Cxr0MGkt+kli306WS4nNNM++9cgt2b2VCMprY92j+AIab/oclgPxdwtTZVLP1zn5t5uo8M6uLsZmYrcjr3HA==", + "version": "23.7.12", + "resolved": "https://registry.npmjs.org/i18next/-/i18next-23.7.12.tgz", + "integrity": "sha512-BZcAvh5M/s2CDrbxNFT8kscfzCYW607wnc4wnQ11HaHDJlS46P/0+P++nmgnc5CIjSQ1DfHAM9RE+hIyALvI7g==", "funding": [ { "type": "individual", @@ -3633,7 +3821,7 @@ } ], "dependencies": { - "@babel/runtime": "^7.22.5" + "@babel/runtime": "^7.23.2" } }, "node_modules/i18next-browser-languagedetector": { @@ -3644,6 +3832,19 @@ "@babel/runtime": "^7.19.4" } }, + "node_modules/i18next-fs-backend": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/i18next-fs-backend/-/i18next-fs-backend-2.3.1.tgz", + "integrity": "sha512-tvfXskmG/9o+TJ5Fxu54sSO5OkY6d+uMn+K6JiUGLJrwxAVfer+8V3nU8jq3ts9Pe5lXJv4b1N7foIjJ8Iy2Gg==" + }, + "node_modules/i18next-resources-to-backend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/i18next-resources-to-backend/-/i18next-resources-to-backend-1.2.0.tgz", + "integrity": "sha512-8f1l03s+QxDmCfpSXCh9V+AFcxAwIp0UaroWuyOx+hmmv8484GcELHs+lnu54FrNij8cDBEXvEwhzZoXsKcVpg==", + "dependencies": { + "@babel/runtime": "^7.23.2" + } + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -4458,11 +4659,108 @@ "resolved": "https://registry.npmjs.org/new-array/-/new-array-1.0.0.tgz", "integrity": "sha512-K5AyFYbuHZ4e/ti52y7k18q8UHsS78FlRd85w2Fmsd6AkuLipDihPflKC0p3PN5i8II7+uHxo+CtkLiJDfmS5A==" }, + "node_modules/next": { + "version": "14.0.4", + "resolved": "https://registry.npmjs.org/next/-/next-14.0.4.tgz", + "integrity": "sha512-qbwypnM7327SadwFtxXnQdGiKpkuhaRLE2uq62/nRul9cj9KhQ5LhHmlziTNqUidZotw/Q1I9OjirBROdUJNgA==", + "peer": true, + "dependencies": { + "@next/env": "14.0.4", + "@swc/helpers": "0.5.2", + "busboy": "1.6.0", + "caniuse-lite": "^1.0.30001406", + "graceful-fs": "^4.2.11", + "postcss": "8.4.31", + "styled-jsx": "5.1.1", + "watchpack": "2.4.0" + }, + "bin": { + "next": "dist/bin/next" + }, + "engines": { + "node": ">=18.17.0" + }, + "optionalDependencies": { + "@next/swc-darwin-arm64": "14.0.4", + "@next/swc-darwin-x64": "14.0.4", + "@next/swc-linux-arm64-gnu": "14.0.4", + "@next/swc-linux-arm64-musl": "14.0.4", + "@next/swc-linux-x64-gnu": "14.0.4", + "@next/swc-linux-x64-musl": "14.0.4", + "@next/swc-win32-arm64-msvc": "14.0.4", + "@next/swc-win32-ia32-msvc": "14.0.4", + "@next/swc-win32-x64-msvc": "14.0.4" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.1.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "sass": "^1.3.0" + }, + "peerDependenciesMeta": { + "@opentelemetry/api": { + "optional": true + }, + "sass": { + "optional": true + } + } + }, + "node_modules/next-i18next": { + "version": "15.1.1", + "resolved": "https://registry.npmjs.org/next-i18next/-/next-i18next-15.1.1.tgz", + "integrity": "sha512-IueFofP7Z9G41VjSPX/LdKhjYDDXq/iLAUFap7Rcz/MlsjLQMC7aktzBslhKH6GBYLOXsuhAO98goBFQBdhelg==", + "funding": [ + { + "type": "individual", + "url": "https://locize.com/i18next.html" + }, + { + "type": "individual", + "url": "https://www.i18next.com/how-to/faq#i18next-is-awesome.-how-can-i-support-the-project" + }, + { + "type": "individual", + "url": "https://locize.com" + } + ], + "dependencies": { + "@babel/runtime": "^7.23.2", + "@types/hoist-non-react-statics": "^3.3.4", + "core-js": "^3", + "hoist-non-react-statics": "^3.3.2", + "i18next-fs-backend": "^2.3.1" + }, + "engines": { + "node": ">=14" + }, + "peerDependencies": { + "i18next": "^23.7.7", + "next": ">= 12.0.0", + "react": ">= 17.0.2", + "react-i18next": "^13.5.0" + } + }, "node_modules/next-power-of-two": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/next-power-of-two/-/next-power-of-two-1.0.0.tgz", "integrity": "sha512-+z6QY1SxkDk6CQJAeaIZKmcNubBCRP7J8DMQUBglz/sSkNsZoJ1kULjqk9skNPPplzs4i9PFhYrvNDdtQleF/A==" }, + "node_modules/next/node_modules/@swc/helpers": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.2.tgz", + "integrity": "sha512-E4KcWTpoLHqwPHLxidpOqQbcrZVgi0rsmmZXUle1jXmJfuIf/UWpczUJ7MZZ5tlxytgJXyp0w4PGkkeLiuIdZw==", + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/next/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "peer": true + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -4757,16 +5055,6 @@ "react": ">=0.14.0" } }, - "node_modules/prop-types-extra/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, - "node_modules/prop-types/node_modules/react-is": { - "version": "16.13.1", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", - "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" - }, "node_modules/proxy-addr": { "version": "2.0.7", "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", @@ -4873,9 +5161,9 @@ } }, "node_modules/react-i18next": { - "version": "13.3.1", - "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-13.3.1.tgz", - "integrity": "sha512-JAtYREK879JXaN9GdzfBI4yJeo/XyLeXWUsRABvYXiFUakhZJ40l+kaTo+i+A/3cKIED41kS/HAbZ5BzFtq/Og==", + "version": "13.5.0", + "resolved": "https://registry.npmjs.org/react-i18next/-/react-i18next-13.5.0.tgz", + "integrity": "sha512-CFJ5NDGJ2MUyBohEHxljOq/39NQ972rh1ajnadG9BjTk+UXbHLq4z5DKEbEQBDoIhUmmbuS/fIMJKo6VOax1HA==", "dependencies": { "@babel/runtime": "^7.22.5", "html-parse-stringify": "^3.0.1" @@ -4901,6 +5189,11 @@ "react": "*" } }, + "node_modules/react-is": { + "version": "16.13.1", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", + "integrity": "sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==" + }, "node_modules/react-lifecycles-compat": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz", @@ -5386,6 +5679,29 @@ "node": ">=4" } }, + "node_modules/styled-jsx": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/styled-jsx/-/styled-jsx-5.1.1.tgz", + "integrity": "sha512-pW7uC1l4mBZ8ugbiZrcIsiIvVx1UmTfw7UkC3Um2tmfUq9Bhk8IiyEIPl6F8agHgjzku6j0xQEZbfA5uSgSaCw==", + "peer": true, + "dependencies": { + "client-only": "0.0.1" + }, + "engines": { + "node": ">= 12.0.0" + }, + "peerDependencies": { + "react": ">= 16.8.0 || 17.x.x || ^18.0.0-0" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "babel-plugin-macros": { + "optional": true + } + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", @@ -5915,6 +6231,19 @@ "loose-envify": "^1.0.0" } }, + "node_modules/watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "peer": true, + "dependencies": { + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/web-worker-manager": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/web-worker-manager/-/web-worker-manager-0.2.0.tgz", @@ -6046,6 +6375,9 @@ "pkgroll": "^2.0.1", "ts-node-dev": "^2.0.0", "typescript": "^5.2.2" + }, + "optionalDependencies": { + "canvas": "^2.11.2" } }, "server-node/node_modules/@esbuild/win32-x64": { @@ -6075,7 +6407,9 @@ "version": "0.0.0", "license": "ISC", "dependencies": { + "i18next-resources-to-backend": "^1.2.0", "image-js": "^0.35.5", + "next-i18next": "^15.1.1", "pdf-lib": "^1.17.1", "pdfjs-dist": "^4.0.269" } diff --git a/server-node/package.json b/server-node/package.json index 1348da6a0..007387f5b 100644 --- a/server-node/package.json +++ b/server-node/package.json @@ -2,7 +2,7 @@ "name": "@stirling-pdf/server-node", "version": "0.0.0", "description": "", - "//": "start pkgroll config", + "//": "end pkgroll config", "type": "module", "exports": "./dist/index.js", "imports": { @@ -14,8 +14,7 @@ "files": [ "/shared-operations/src/wasm/pdfcpu/pdfcpu.wasm" ], - "//": "end pkgroll config", - "scripts": { + "scripts": { "build": "pkgroll", "start": "node ./dist/index.js", "dev": "npx tsx watch src/index.ts" diff --git a/server-node/src/index.ts b/server-node/src/index.ts index a154074d3..6b60b9faf 100644 --- a/server-node/src/index.ts +++ b/server-node/src/index.ts @@ -1,3 +1,5 @@ +import "@stirling-pdf/shared-operations/src/locales/i18next.config"; + import express from 'express'; const app = express(); const PORT = 8000; diff --git a/shared-operations/package.json b/shared-operations/package.json index 25675ebfb..8e8f38c8c 100644 --- a/shared-operations/package.json +++ b/shared-operations/package.json @@ -12,7 +12,9 @@ "author": "", "license": "ISC", "dependencies": { + "i18next-resources-to-backend": "^1.2.0", "image-js": "^0.35.5", + "next-i18next": "^15.1.1", "pdf-lib": "^1.17.1", "pdfjs-dist": "^4.0.269" } diff --git a/shared-operations/src/functions/impose.ts b/shared-operations/src/functions/impose.ts index bb7a1c62a..eeb3bac4f 100644 --- a/shared-operations/src/functions/impose.ts +++ b/shared-operations/src/functions/impose.ts @@ -7,38 +7,8 @@ import * as pdfcpuWrapper from "#pdfcpu"; // This is updated by tsconfig.json/pa import Joi from "joi"; import { JoiPDFFileSchema } from "../wrappers/PdfFileJoi"; - -// TODO: This will be replaced by a real translator -const translationObject = { - operators: { - nup: { - friendlyName: "PDF-Imposition / PDF-N-Up", - description: "Put multiple pages of the input document into a single page of the output document.", - values: { - nup: { - friendlyName: "Page Format", - description: "The Page Size of the ouput document. Append L or P to force Landscape or Portrait." - }, - format: { - friendlyName: "N-Up-Value", - description: "How many pages should be in one output page" - } - } - } - }, - inputs: { - pdfFile: { - name: "PDF-File(s)", - description: "This operator takes a PDF-File(s) as input" - } - }, - outputs: { - pdfFile: { - name: "PDF-File(s)", - description: "This operator outputs PDF-File(s)" - } - } -} +import i18next from 'i18next'; +i18next.loadNamespaces('impose', (err, t) => { if (err) throw err; }); export class Impose extends Operator { static type: string = "impose"; @@ -47,10 +17,10 @@ export class Impose extends Operator { * Validation & Localisation */ - protected static inputSchema = JoiPDFFileSchema.label(translationObject.inputs.pdfFile.name).description(translationObject.inputs.pdfFile.description); + protected static inputSchema = JoiPDFFileSchema.label(i18next.t('inputs.pdffile.name')).description(i18next.t('inputs.pdffile.description')); protected static valueSchema = Joi.object({ nup: Joi.number().integer().valid(2, 3, 4, 8, 9, 12, 16).required() - .label(translationObject.operators.nup.values.nup.friendlyName).description(translationObject.operators.nup.values.nup.description) + .label(i18next.t('values.nup.friendlyName', { ns: 'impose' })).description(i18next.t('values.nup.description', { ns: 'impose' })) .example("3").example("4"), format: Joi.string().valid(...[ // ISO 216:1975 A @@ -92,16 +62,16 @@ export class Impose extends Operator { "JIS-B7", "JIS-B8", "JIS-B9", "JIS-B10", "JIS-B11", "JIS-B12", "Shirokuban4", "Shirokuban5", "Shirokuban6", "Kiku4", "Kiku5", "AB", "B40", "Shikisen" ].flatMap(size => [size, size + "P", size + "L"])).required() - .label(translationObject.operators.nup.values.format.friendlyName).description(translationObject.operators.nup.values.format.description) + .label(i18next.t('values.format.friendlyName', { ns: 'impose' })).description(i18next.t('values.format.description', { ns: 'impose' })) .example("A4").example("A3L") }); - protected static outputSchema = JoiPDFFileSchema.label(translationObject.outputs.pdfFile.name).description(translationObject.outputs.pdfFile.description); + protected static outputSchema = JoiPDFFileSchema.label(i18next.t('outputs.pdffile.name')).description(i18next.t('outputs.pdffile.description')); static schema = Joi.object({ input: Impose.inputSchema, values: Impose.valueSchema.required(), output: Impose.outputSchema - }).label(translationObject.operators.nup.friendlyName).description(translationObject.operators.nup.description); + }).label(i18next.t('friendlyName', { ns: 'impose' })).description(i18next.t('description', { ns: 'impose' })); /** diff --git a/shared-operations/src/locales/common/en.json b/shared-operations/src/locales/common/en.json new file mode 100644 index 000000000..d782a3057 --- /dev/null +++ b/shared-operations/src/locales/common/en.json @@ -0,0 +1,14 @@ +{ + "inputs": { + "pdffile": { + "name": "PDF-File(s)", + "description": "This operator takes a PDF-File(s) as input" + } + }, + "outputs": { + "pdffile": { + "name": "PDF-File(s)", + "description": "This operator outputs PDF-File(s)" + } + } +} \ No newline at end of file diff --git a/shared-operations/src/locales/i18next.config.ts b/shared-operations/src/locales/i18next.config.ts new file mode 100644 index 000000000..de1afa14d --- /dev/null +++ b/shared-operations/src/locales/i18next.config.ts @@ -0,0 +1,14 @@ +import i18next from "i18next" +import resourcesToBackend from 'i18next-resources-to-backend'; + +i18next + .use(resourcesToBackend((language, namespace) => import(`./${namespace}/${language}.json`))) + .init({ + // debug: true, + ns: ['common'], // Preload this namespace, no need to add the others + defaultNS: 'common', + fallbackLng: 'en', + interpolation: { + escapeValue: false, + } + }); \ No newline at end of file diff --git a/shared-operations/src/locales/impose/en.json b/shared-operations/src/locales/impose/en.json new file mode 100644 index 000000000..717be9641 --- /dev/null +++ b/shared-operations/src/locales/impose/en.json @@ -0,0 +1,14 @@ +{ + "friendlyName": "PDF-Imposition / PDF-N-Up", + "description": "Put multiple pages of the input document into a single page of the output document.", + "values": { + "nup": { + "friendlyName": "Page Format", + "description": "The Page Size of the ouput document. Append L or P to force Landscape or Portrait." + }, + "format": { + "friendlyName": "N-Up-Value", + "description": "How many pages should be in one output page" + } + } +} \ No newline at end of file diff --git a/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js b/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js index 60a9f4cd7..007cc60d5 100644 --- a/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js +++ b/shared-operations/src/wasm/pdfcpu/pdfcpu-wrapper.server.js @@ -1,7 +1,7 @@ import { WasmFs } from '@wasmer/wasmfs'; import path from "path"; -let nodeWasmLocation = "../shared-operations/src/wasm/pdfcpu/"; +let nodeWasmLocation = "../shared-operations/src/wasm/pdfcpu/"; // TODO: Replace with __dirname let fs; const wasmfs = new WasmFs(); diff --git a/shared-operations/src/wasm/pdfcpu/wasm_exec.js b/shared-operations/src/wasm/pdfcpu/wasm_exec.js index 3817268b3..92a7bdaf3 100644 --- a/shared-operations/src/wasm/pdfcpu/wasm_exec.js +++ b/shared-operations/src/wasm/pdfcpu/wasm_exec.js @@ -12,7 +12,7 @@ // - Parcel // - Webpack - console.log("imported") + console.log("pdfcpu wasm_exec imported") if (typeof global !== "undefined") { // global already exists } else if (typeof window !== "undefined") {