You've already forked AstralRinth
forked from didirus/AstralRinth
include moderation pkg in frontend locales (#4169)
* include moderation pkg in frontend locales * Fix moderation lib path * remove prints * feat: move moderation package into src folder * fix: lint --------- Co-authored-by: IMB11 <calum@modrinth.com> Co-authored-by: Cal H. <hendersoncal117@gmail.com>
This commit is contained in:
@@ -1,12 +1,12 @@
|
|||||||
import { promises as fs } from "fs";
|
import { promises as fs } from "fs";
|
||||||
import { pathToFileURL } from "node:url";
|
import { pathToFileURL } from "node:url";
|
||||||
import svgLoader from "vite-svg-loader";
|
|
||||||
import { resolve, basename, relative } from "pathe";
|
|
||||||
import { defineNuxtConfig } from "nuxt/config";
|
|
||||||
import { $fetch } from "ofetch";
|
|
||||||
import { globIterate } from "glob";
|
|
||||||
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
import { match as matchLocale } from "@formatjs/intl-localematcher";
|
||||||
import { consola } from "consola";
|
import { consola } from "consola";
|
||||||
|
import { globIterate } from "glob";
|
||||||
|
import { defineNuxtConfig } from "nuxt/config";
|
||||||
|
import { $fetch } from "ofetch";
|
||||||
|
import { basename, relative, resolve } from "pathe";
|
||||||
|
import svgLoader from "vite-svg-loader";
|
||||||
|
|
||||||
const STAGING_API_URL = "https://staging-api.modrinth.com/v2/";
|
const STAGING_API_URL = "https://staging-api.modrinth.com/v2/";
|
||||||
|
|
||||||
@@ -263,23 +263,29 @@ export default defineNuxtConfig({
|
|||||||
|
|
||||||
const resolveOmorphiaLocaleImport = await (async () => {
|
const resolveOmorphiaLocaleImport = await (async () => {
|
||||||
const omorphiaLocales: string[] = [];
|
const omorphiaLocales: string[] = [];
|
||||||
const omorphiaLocaleSets = new Map<string, { files: { from: string }[] }>();
|
const omorphiaLocaleSets = new Map<
|
||||||
|
string,
|
||||||
|
{ files: { from: string; format?: string }[] }
|
||||||
|
>();
|
||||||
|
|
||||||
for await (const localeDir of globIterate("node_modules/@modrinth/ui/src/locales/*", {
|
for (const pkgLocales of [`node_modules/@modrinth/**/src/locales/*`]) {
|
||||||
posix: true,
|
for await (const localeDir of globIterate(pkgLocales, {
|
||||||
})) {
|
posix: true,
|
||||||
const tag = basename(localeDir);
|
})) {
|
||||||
omorphiaLocales.push(tag);
|
const tag = basename(localeDir);
|
||||||
|
if (!omorphiaLocales.includes(tag)) {
|
||||||
|
omorphiaLocales.push(tag);
|
||||||
|
}
|
||||||
|
|
||||||
const localeFiles: { from: string; format?: string }[] = [];
|
const entry = omorphiaLocaleSets.get(tag) ?? { files: [] };
|
||||||
|
omorphiaLocaleSets.set(tag, entry);
|
||||||
|
|
||||||
omorphiaLocaleSets.set(tag, { files: localeFiles });
|
for await (const localeFile of globIterate(`${localeDir}/*`, { posix: true })) {
|
||||||
|
entry.files.push({
|
||||||
for await (const localeFile of globIterate(`${localeDir}/*`, { posix: true })) {
|
from: pathToFileURL(localeFile).toString(),
|
||||||
localeFiles.push({
|
format: "default",
|
||||||
from: pathToFileURL(localeFile).toString(),
|
});
|
||||||
format: "default",
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
"name": "@modrinth/moderation",
|
"name": "@modrinth/moderation",
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "./index.ts",
|
"main": "./src/index.ts",
|
||||||
"types": "./index.d.ts",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"lint": "eslint . && prettier --check .",
|
"lint": "eslint . && prettier --check .",
|
||||||
"fix": "eslint . --fix && prettier --write . && pnpm run intl:extract",
|
"fix": "eslint . --fix && prettier --write . && pnpm run intl:extract",
|
||||||
"intl:extract": "formatjs extract \"**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore \"node_modules/**/*\" --out-file locales/en-US/index.json --preserve-whitespace"
|
"intl:extract": "formatjs extract \"**/*.{vue,ts,tsx,js,jsx,mts,cts,mjs,cjs}\" --ignore \"**/*.d.ts\" --ignore \"node_modules/**/*\" --out-file src/locales/en-US/index.json --preserve-whitespace"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@modrinth/assets": "workspace:*",
|
"@modrinth/assets": "workspace:*",
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user