mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 03:31:58 +00:00
Revert "fix: add post-processing script to fix i18n nodeDefs array corruption" (#8736)
Reverts Comfy-Org/ComfyUI_frontend#8718
This commit is contained in:
2
.github/workflows/i18n-update-core.yaml
vendored
2
.github/workflows/i18n-update-core.yaml
vendored
@@ -43,7 +43,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
||||||
- name: Update translations
|
- name: Update translations
|
||||||
run: pnpm locale && pnpm fix-i18n-node-defs && pnpm format
|
run: pnpm locale && pnpm format
|
||||||
env:
|
env:
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
- name: Commit updated locales
|
- name: Commit updated locales
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
||||||
- name: Update translations
|
- name: Update translations
|
||||||
run: pnpm locale && pnpm fix-i18n-node-defs
|
run: pnpm locale
|
||||||
env:
|
env:
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
- name: Diff base vs updated i18n
|
- name: Diff base vs updated i18n
|
||||||
|
|||||||
2
.github/workflows/i18n-update-nodes.yaml
vendored
2
.github/workflows/i18n-update-nodes.yaml
vendored
@@ -36,7 +36,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
PLAYWRIGHT_TEST_URL: http://localhost:5173
|
||||||
- name: Update translations
|
- name: Update translations
|
||||||
run: pnpm locale && pnpm fix-i18n-node-defs
|
run: pnpm locale
|
||||||
env:
|
env:
|
||||||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||||
- name: Create Pull Request
|
- name: Create Pull Request
|
||||||
|
|||||||
@@ -23,7 +23,6 @@
|
|||||||
"dev": "nx serve",
|
"dev": "nx serve",
|
||||||
"devtools:pycheck": "python3 -m compileall -q tools/devtools",
|
"devtools:pycheck": "python3 -m compileall -q tools/devtools",
|
||||||
"format:check": "oxfmt --check",
|
"format:check": "oxfmt --check",
|
||||||
"fix-i18n-node-defs": "tsx scripts/fix-i18n-node-defs.ts",
|
|
||||||
"format": "oxfmt --write",
|
"format": "oxfmt --write",
|
||||||
"json-schema": "tsx scripts/generate-json-schema.ts",
|
"json-schema": "tsx scripts/generate-json-schema.ts",
|
||||||
"knip:no-cache": "knip",
|
"knip:no-cache": "knip",
|
||||||
|
|||||||
@@ -1,66 +0,0 @@
|
|||||||
import { readFileSync, readdirSync, writeFileSync } from 'fs'
|
|
||||||
import { join } from 'path'
|
|
||||||
|
|
||||||
const LOCALES_DIR = 'src/locales'
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert arrays with numeric indices back to objects.
|
|
||||||
* GPT-4.1 (used by @lobehub/i18n-cli) sometimes converts
|
|
||||||
* {"0": {...}, "1": {...}} objects into JSON arrays with null gaps.
|
|
||||||
*/
|
|
||||||
function fixArraysToObjects(value: unknown): Record<string, unknown> | unknown {
|
|
||||||
if (!value || typeof value !== 'object') return value
|
|
||||||
|
|
||||||
if (Array.isArray(value)) {
|
|
||||||
const obj: Record<string, unknown> = {}
|
|
||||||
for (let i = 0; i < value.length; i++) {
|
|
||||||
if (value[i] != null) {
|
|
||||||
obj[String(i)] = fixArraysToObjects(value[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return obj
|
|
||||||
}
|
|
||||||
|
|
||||||
const record = value as Record<string, unknown>
|
|
||||||
const result: Record<string, unknown> = {}
|
|
||||||
for (const key of Object.keys(record)) {
|
|
||||||
result[key] = fixArraysToObjects(record[key])
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
function run() {
|
|
||||||
const locales = readdirSync(LOCALES_DIR, { withFileTypes: true })
|
|
||||||
.filter((d) => d.isDirectory() && d.name !== 'en')
|
|
||||||
.map((d) => d.name)
|
|
||||||
|
|
||||||
let totalFixes = 0
|
|
||||||
|
|
||||||
for (const locale of locales) {
|
|
||||||
const filePath = join(LOCALES_DIR, locale, 'nodeDefs.json')
|
|
||||||
let raw: string
|
|
||||||
try {
|
|
||||||
raw = readFileSync(filePath, 'utf-8')
|
|
||||||
} catch {
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = JSON.parse(raw)
|
|
||||||
const fixed = fixArraysToObjects(data) as Record<string, unknown>
|
|
||||||
const fixedJson = JSON.stringify(fixed, null, 2) + '\n'
|
|
||||||
|
|
||||||
if (fixedJson !== raw) {
|
|
||||||
writeFileSync(filePath, fixedJson)
|
|
||||||
totalFixes++
|
|
||||||
console.warn(`Fixed: ${filePath}`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (totalFixes === 0) {
|
|
||||||
console.warn('No fixes needed')
|
|
||||||
} else {
|
|
||||||
console.warn(`Fixed ${totalFixes} file(s)`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
run()
|
|
||||||
Reference in New Issue
Block a user