fix: language support issue in public-profile

This commit is contained in:
RaktimaNXG
2024-08-10 16:23:10 +05:30
parent aa4d3c039b
commit 69837b0515
5 changed files with 146 additions and 8 deletions
+113
View File
@@ -69,6 +69,7 @@
"clean-webpack-plugin": "^4.0.0",
"commitizen": "^4.3.0",
"concurrently": "^8.2.2",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"daisyui": "^4.12.10",
"dotenv": "^16.4.5",
@@ -76,6 +77,7 @@
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.34.3",
"json-minimizer-webpack-plugin": "^5.0.0",
"lint-staged": "^15.2.8",
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.41",
@@ -5548,6 +5550,18 @@
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.51.tgz",
"integrity": "sha512-1P1OROm/rdubP5aFDSZQILU0vrLCJ4fvHt6EoqHEM+2D/G5MK3bIaymUKLit8Js9gbns5UyJnkP/TZROLw4tUA=="
},
"node_modules/@sindresorhus/merge-streams": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/@sindresorhus/merge-streams/-/merge-streams-2.3.0.tgz",
"integrity": "sha512-LtoMMhxAlorcGhmFYI+LhPgbPZCkgP6ra1YL604EeF6U98pLlQ3iWIGMdWSC+vWmPBWBNgmDBAhnAobLROJmwg==",
"dev": true,
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/@sinonjs/commons": {
"version": "1.8.6",
"resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.6.tgz",
@@ -8953,6 +8967,74 @@
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
"integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
},
"node_modules/copy-webpack-plugin": {
"version": "12.0.2",
"resolved": "https://registry.npmjs.org/copy-webpack-plugin/-/copy-webpack-plugin-12.0.2.tgz",
"integrity": "sha512-SNwdBeHyII+rWvee/bTnAYyO8vfVdcSTud4EIb6jcZ8inLeWucJE0DnxXQBjlQ5zlteuuvooGQy3LIyGxhvlOA==",
"dev": true,
"dependencies": {
"fast-glob": "^3.3.2",
"glob-parent": "^6.0.1",
"globby": "^14.0.0",
"normalize-path": "^3.0.0",
"schema-utils": "^4.2.0",
"serialize-javascript": "^6.0.2"
},
"engines": {
"node": ">= 18.12.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^5.1.0"
}
},
"node_modules/copy-webpack-plugin/node_modules/globby": {
"version": "14.0.2",
"resolved": "https://registry.npmjs.org/globby/-/globby-14.0.2.tgz",
"integrity": "sha512-s3Fq41ZVh7vbbe2PN3nrW7yC7U7MFVc5c98/iTl9c2GawNMKx/J648KQRW6WKkuU8GIbbh2IXfIRQjOZnXcTnw==",
"dev": true,
"dependencies": {
"@sindresorhus/merge-streams": "^2.1.0",
"fast-glob": "^3.3.2",
"ignore": "^5.2.4",
"path-type": "^5.0.0",
"slash": "^5.1.0",
"unicorn-magic": "^0.1.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/copy-webpack-plugin/node_modules/path-type": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-5.0.0.tgz",
"integrity": "sha512-5HviZNaZcfqP95rwpv+1HDgUamezbqdSYTyzjTvwtJSnIH+3vnbmWsItli8OFEndS984VT55M3jduxZbX351gg==",
"dev": true,
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/copy-webpack-plugin/node_modules/slash": {
"version": "5.1.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-5.1.0.tgz",
"integrity": "sha512-ZA6oR3T/pEyuqwMgAKT0/hAv8oAXckzbkmR0UkUosQ+Mc4RxGoJkRmwHgHufaenlyAgE1Mxgpdcrf75y6XcnDg==",
"dev": true,
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/core-js": {
"version": "2.6.12",
"resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz",
@@ -16160,6 +16242,25 @@
"resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz",
"integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ=="
},
"node_modules/json-minimizer-webpack-plugin": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/json-minimizer-webpack-plugin/-/json-minimizer-webpack-plugin-5.0.0.tgz",
"integrity": "sha512-GT/SZolN2p405EMGjMTBvAVi2+y035p1tSOuLpWbp5QTMl080OHx4DEGXfUH6vbnGw5Z/QKfBe+KpP9Dj0qLmA==",
"dev": true,
"dependencies": {
"schema-utils": "^4.2.0"
},
"engines": {
"node": ">= 18.12.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/webpack"
},
"peerDependencies": {
"webpack": "^5.1.0"
}
},
"node_modules/json-parse-even-better-errors": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz",
@@ -24498,6 +24599,18 @@
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
"integrity": "sha512-NUcwaKxUxWrZLpDG+z/xZaCgQITkA/Dv4V/T6bw7VON6l1Xz/VnrBqrYjZQ12TamKHzITTfOEIYUj48y2KXImA=="
},
"node_modules/unicorn-magic": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/unicorn-magic/-/unicorn-magic-0.1.0.tgz",
"integrity": "sha512-lRfVq8fE8gz6QMBuDM6a+LO3IAzTi05H6gCVaUpir2E1Rwpo4ZUog45KpNXKC/Mn3Yb9UDuHumeFTo9iV/D9FQ==",
"dev": true,
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/unique-string": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/unique-string/-/unique-string-2.0.0.tgz",
+2
View File
@@ -101,6 +101,7 @@
"clean-webpack-plugin": "^4.0.0",
"commitizen": "^4.3.0",
"concurrently": "^8.2.2",
"copy-webpack-plugin": "^12.0.2",
"css-loader": "^7.1.2",
"daisyui": "^4.12.10",
"dotenv": "^16.4.5",
@@ -108,6 +109,7 @@
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-react": "^7.34.3",
"json-minimizer-webpack-plugin": "^5.0.0",
"lint-staged": "^15.2.8",
"mini-css-extract-plugin": "^2.9.0",
"postcss": "^8.4.41",
+4 -2
View File
@@ -6,11 +6,13 @@ import { isPublicProduction, isPublicStaging } from "./constant/const";
//handle path to support language on public profile
const backendPath = isPublicStaging
? "https://staging-app.opensignlabs.com/locales/{{lng}}/{{ns}}.json"
? "https://staging-app.opensignlabs.com/static/locales/{{lng}}/{{ns}}.json"
: isPublicProduction
? "https://app.opensignlabs.com/locales/{{lng}}/{{ns}}.json"
? "https://app.opensignlabs.com/static/locales/{{lng}}/{{ns}}.json"
: "/locales/{{lng}}/{{ns}}.json";
//"http://localhost:3000/static/locales/{{lng}}/{{ns}}.json"
i18n
.use(Backend)
.use(LanguageDetector) // Use LanguageDetector directly without creating an instance
+5 -2
View File
@@ -27,9 +27,12 @@ const PublicScriptFileWrapper = ({ initialProps }) => {
};
const appId = isPublicStaging ? "opensign" : "legadranaxn";
//"opensign"
const serverUrl = isPublicStaging
? "https://staging-app.opensignlabs.com/api/app"
: "https://app.opensignlabs.com/api/app";
// "https://staging-app.opensignlabs.com/api/app"
localStorage.setItem("baseUrl", `${serverUrl}/`);
localStorage.setItem("parseAppId", appId);
@@ -47,8 +50,8 @@ document.head.appendChild(link);
//add the Tailwind CSS file
const tailwindCssLink = document.createElement("link");
tailwindCssLink.href =
// "https://app.opensignlabs.com/static/js/public-template.bundle.css"; // css bundle file
tailwindCssLink.rel = "stylesheet";
"https://app.opensignlabs.com/static/js/public-template.bundle.css"; // css bundle file
tailwindCssLink.rel = "stylesheet";
document.head.appendChild(tailwindCssLink);
// Create a root and render the wrapper component with initial props
const root = ReactDOM.createRoot(document.getElementById("script-component"));
+22 -4
View File
@@ -3,13 +3,14 @@ const Dotenv = require("dotenv-webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin"); //used to clean directory
const TerserPlugin = require("terser-webpack-plugin"); //used to minify and optimize JavaScript files
const MiniCssExtractPlugin = require("mini-css-extract-plugin"); //used to extract css file into separate files
const CopyPlugin = require("copy-webpack-plugin"); // CopyPlugin is a Webpack plugin used to copy files and directories from a source location to a destination location during the build process.
const JsonMinimizerPlugin = require("json-minimizer-webpack-plugin"); //It helps reduce the size of your JSON files by removing unnecessary whitespace, comments, and other redundant data.
const isProduction = process.env.NODE_ENV;
module.exports = {
mode: isProduction ? "production" : "development",
entry: "./src/script/PublicTemplate.js",
output: {
path: path.resolve(__dirname, "public", "static", "js"),
path: path.resolve(__dirname, "public/static/js"),
filename: "public-template.bundle.js",
libraryTarget: "umd",
umdNamedDefine: true,
@@ -46,6 +47,14 @@ module.exports = {
}
}
]
},
{
test: /\.json$/i,
include: path.resolve(__dirname, "public/locales"),
type: "asset/resource",
generator: {
filename: "locales/[path][name][ext]"
}
}
]
},
@@ -61,11 +70,20 @@ module.exports = {
filename: "public-template.bundle.css"
})
]
: [])
: []),
new CopyPlugin({
patterns: [
{
context: path.resolve(__dirname, "public/locales"),
from: "**/*.json",
to: path.resolve(__dirname, "public/static/locales/[path][name][ext]")
}
]
})
],
optimization: {
minimize: isProduction ? true : false,
minimizer: [new TerserPlugin()]
minimizer: [new TerserPlugin(), new JsonMinimizerPlugin()]
},
devtool: isProduction ? "source-map" : "inline-source-map"
};