Skip to content

Commit

Permalink
[i18n] Translate widget label (#1883)
Browse files Browse the repository at this point in the history
* [i18n] Translate widget label

* Update locales [skip ci]

---------

Co-authored-by: github-actions <github-actions@github.com>
  • Loading branch information
huchenlei and github-actions authored Dec 12, 2024
1 parent c5f77de commit f23530a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .i18nrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ module.exports = defineConfig({
entryLocale: 'en',
output: 'src/locales',
outputLocales: ['zh', 'ru', 'ja', 'ko'],
reference: `Special names to keep untranslated: flux, photomaker, clip, vae`
reference: `Special names to keep untranslated: flux, photomaker, clip, vae, cfg`
});
14 changes: 14 additions & 0 deletions src/locales/en/nodeDefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,20 @@
}
}
},
"Mahiro": {
"display_name": "Mahiro is so cute that she deserves a better guidance function!! (。・ω・。)",
"description": "Modify the guidance to scale more on the 'direction' of the positive prompt rather than the difference between the negative prompt.",
"inputs": {
"model": {
"name": "model"
}
},
"outputs": {
"0": {
"name": "patched_model"
}
}
},
"MaskComposite": {
"display_name": "MaskComposite",
"inputs": {
Expand Down
4 changes: 2 additions & 2 deletions src/locales/ja/nodeDefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@
"display_name": "Kサンプラー",
"inputs": {
"cfg": {
"name": "設定",
"name": "cfg",
"tooltip": "Classifier-Free Guidanceスケールは、創造性とプロンプトへの遵守のバランスを取ります。値が高いほど、生成される画像はプロンプトにより近くなりますが、値が高すぎると品質に悪影響を及ぼす可能性があります。"
},
"denoise": {
Expand Down Expand Up @@ -1848,7 +1848,7 @@
"name": "ノイズ追加"
},
"cfg": {
"name": "設定"
"name": "cfg"
},
"end_at_step": {
"name": "ステップ終了"
Expand Down
4 changes: 2 additions & 2 deletions src/locales/ru/nodeDefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1795,7 +1795,7 @@
"display_name": "KSampler",
"inputs": {
"cfg": {
"name": "конфиг",
"name": "cfg",
"tooltip": "Масштаб без классификатора балансирует креативность и соблюдение запроса. Более высокие значения приводят к изображениям, более точно соответствующим запросу, однако слишком высокие значения негативно скажутся на качестве."
},
"denoise": {
Expand Down Expand Up @@ -1848,7 +1848,7 @@
"name": "добавить_шум"
},
"cfg": {
"name": "конфиг"
"name": "cfg"
},
"end_at_step": {
"name": "закончить_на_шаге"
Expand Down
10 changes: 5 additions & 5 deletions src/locales/zh/nodeDefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
"display_name": "CFG引导器",
"inputs": {
"cfg": {
"name": "配置"
"name": "cfg"
},
"model": {
"name": "模型"
Expand Down Expand Up @@ -1795,7 +1795,7 @@
"display_name": "K采样器",
"inputs": {
"cfg": {
"name": "配置",
"name": "cfg",
"tooltip": "无分类器引导比例平衡创造力和对提示的遵循。更高的值会导致图像更接近提示,但过高的值会对质量产生负面影响。"
},
"denoise": {
Expand Down Expand Up @@ -1848,7 +1848,7 @@
"name": "添加噪声"
},
"cfg": {
"name": "配置"
"name": "cfg"
},
"end_at_step": {
"name": "结束步骤"
Expand Down Expand Up @@ -3948,7 +3948,7 @@
"display_name": "PerpNeg引导器",
"inputs": {
"cfg": {
"name": "配置"
"name": "cfg"
},
"empty_conditioning": {
"name": "空条件"
Expand Down Expand Up @@ -4252,7 +4252,7 @@
"name": "添加噪声"
},
"cfg": {
"name": "配置"
"name": "cfg"
},
"latent_image": {
"name": "潜在图像"
Expand Down
9 changes: 5 additions & 4 deletions src/scripts/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,7 @@ export class ComfyApp {
const type = _inputData[0]
const options = _inputData[1] ?? {}
const inputData = [type, options]
const nameKey = `nodeDefs.${normalizeI18nKey(nodeData.name)}.inputs.${normalizeI18nKey(inputName)}.name`

const inputIsRequired = requiredInputs && inputName in requiredInputs

Expand All @@ -1931,17 +1932,17 @@ export class ComfyApp {
self.widgets[widgetType](this, inputName, inputData, app) || {}
)
}
if (config.widget) {
config.widget.label = st(nameKey, inputName)
}
} else {
// Node connection inputs
const shapeOptions = inputIsRequired
? {}
: { shape: LiteGraph.SlotShape.HollowCircle }
const inputOptions = {
...shapeOptions,
label: st(
`nodeDefs.${normalizeI18nKey(nodeData.name)}.inputs.${normalizeI18nKey(inputName)}.name`,
inputName
)
label: st(nameKey, inputName)
}
this.addInput(inputName, type, inputOptions)
widgetCreated = false
Expand Down

0 comments on commit f23530a

Please sign in to comment.