Skip to content

Global Translations Types #1432

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft
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
16 changes: 15 additions & 1 deletion esbuild.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import path from "path";
import { build } from "esbuild";
import { lessLoader } from "esbuild-plugin-less";
import fs from "node:fs";
import svg from "esbuild-plugin-svg";
import fs from "fs";
import LessPluginCleanCSS from "less-plugin-clean-css";
import JSONtoTS from "json-to-ts";

const pkg = JSON.parse(fs.readFileSync("./package.json").toString());

Expand Down Expand Up @@ -33,6 +34,19 @@ let resolveMediaElement = {
};

async function main() {
// Generate translation types

const enJSONStr = fs.readFileSync("./src/locales/en-GB.json").toString();
const enJSON = JSON.parse(enJSONStr.replace(/"\$/g, '"'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the global replacement of dollar signs? This seems to have potential for side effects. If we don't want the dollar signs, should we just remove them from the files in the first place?


const defs = JSONtoTS(enJSON);
fs.writeFileSync(
"./translations.d.ts",
defs.join("\n\n").replace("RootObject", "Translations")
);

// Build UV

await build({
// Enables code splitting, similar to webpack.
splitting: true,
Expand Down
Loading