mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-03-10 23:50:00 +00:00
Translate core setting name & tooltip (#1765)
* lazy eval default value * Add setting translation * Adjust hooks * Add all translations * nit * Normalized setting id * Update locales * Fallback * Locale => Language * Locale => Language * Update translations
This commit is contained in:
32
scripts/update-setting-locale.ts
Normal file
32
scripts/update-setting-locale.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import fs from 'fs'
|
||||
import { CORE_SETTINGS } from '../src/constants/coreSettings'
|
||||
|
||||
interface SettingLocale {
|
||||
name: string
|
||||
tooltip?: string
|
||||
}
|
||||
|
||||
const extractLocaleStrings = (): Record<string, SettingLocale> => {
|
||||
return Object.fromEntries(
|
||||
CORE_SETTINGS.sort((a, b) => a.id.localeCompare(b.id)).map((setting) => [
|
||||
// '.' is not allowed in JSON keys, so we replace it with '_'
|
||||
setting.id.replace(/\./g, '_'),
|
||||
{
|
||||
name: setting.name,
|
||||
tooltip: setting.tooltip
|
||||
}
|
||||
])
|
||||
)
|
||||
}
|
||||
|
||||
const main = () => {
|
||||
const localeStrings = extractLocaleStrings()
|
||||
const localePath = './src/locales/en.json'
|
||||
const globalLocale = JSON.parse(fs.readFileSync(localePath, 'utf-8'))
|
||||
fs.writeFileSync(
|
||||
localePath,
|
||||
JSON.stringify({ ...globalLocale, settingsDialog: localeStrings }, null, 2)
|
||||
)
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user