mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-07 16:40:05 +00:00
[i18n] Translate node input/output label and tooltip (#1860)
* [i18n] Translate node input/output labels * nit * Impl actual translation * Remove outputs where name is the type * Pick outputs key * Translate outputs * Properly persist label * Translate input tooltips * Translate single node * Translate first node * Translate 10 nodes * Exclude input name translation * Update test expectations [skip ci] * nit --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -61,7 +61,8 @@ import { type IBaseWidget } from '@comfyorg/litegraph/dist/types/widgets'
|
||||
import { workflowService } from '@/services/workflowService'
|
||||
import { useWidgetStore } from '@/stores/widgetStore'
|
||||
import { deserialiseAndCreate } from '@/extensions/core/vintageClipboard'
|
||||
import { st } from '@/i18n'
|
||||
import { st, t, te } from '@/i18n'
|
||||
import { normalizeI18nKey } from '@/utils/formatUtil'
|
||||
|
||||
export const ANIM_PREVIEW_WIDGET = '$$comfy_animation_preview'
|
||||
|
||||
@@ -1932,9 +1933,16 @@ export class ComfyApp {
|
||||
}
|
||||
} else {
|
||||
// Node connection inputs
|
||||
const inputOptions = inputIsRequired
|
||||
const shapeOptions = inputIsRequired
|
||||
? {}
|
||||
: { shape: LiteGraph.SlotShape.HollowCircle }
|
||||
const inputOptions = {
|
||||
...shapeOptions,
|
||||
label: st(
|
||||
`nodeDefs.${normalizeI18nKey(nodeData.name)}.inputs.${normalizeI18nKey(inputName)}.name`,
|
||||
inputName
|
||||
)
|
||||
}
|
||||
this.addInput(inputName, type, inputOptions)
|
||||
widgetCreated = false
|
||||
}
|
||||
@@ -1964,9 +1972,15 @@ export class ComfyApp {
|
||||
if (output instanceof Array) output = 'COMBO'
|
||||
const outputName = nodeData['output_name'][o] || output
|
||||
const outputIsList = nodeData['output_is_list'][o]
|
||||
const outputOptions = outputIsList
|
||||
const shapeOptions = outputIsList
|
||||
? { shape: LiteGraph.GRID_SHAPE }
|
||||
: {}
|
||||
const nameKey = `nodeDefs.${normalizeI18nKey(nodeData.name)}.outputs.${o}.name`
|
||||
const typeKey = `dataTypes.${normalizeI18nKey(output)}`
|
||||
const outputOptions = {
|
||||
...shapeOptions,
|
||||
label: te(nameKey) ? t(nameKey) : st(typeKey, outputName)
|
||||
}
|
||||
this.addOutput(outputName, output, outputOptions)
|
||||
}
|
||||
|
||||
@@ -1980,7 +1994,7 @@ export class ComfyApp {
|
||||
}
|
||||
|
||||
configure(data: any) {
|
||||
// Keep 'name', 'type', and 'shape' information from the original node definition.
|
||||
// Keep 'name', 'type', 'shape', and 'label' information from the original node definition.
|
||||
const merge = (
|
||||
current: Record<string, any>,
|
||||
incoming: Record<string, any>
|
||||
@@ -1991,7 +2005,7 @@ export class ComfyApp {
|
||||
this.inputs.push(current as INodeInputSlot)
|
||||
return incoming
|
||||
}
|
||||
for (const key of ['name', 'type', 'shape']) {
|
||||
for (const key of ['name', 'type', 'shape', 'label']) {
|
||||
if (current[key] !== undefined) {
|
||||
result[key] = current[key]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user