Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[i18n] Impl i18n context menu translation #2394

Conversation

KarryCharon
Copy link
Collaborator

@KarryCharon KarryCharon commented Feb 2, 2025

This PR has enhanced the right mouse click context menu translation.
image

┆Issue is synchronized with this Notion page by Unito

Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you run npm run format to format the code?

Copy link
Member

@huchenlei huchenlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might want to convert this translation to a core extension right now, just to avoid introducing more complexity in app.ts.

if (!values) return;
// Convert {w.name} to input
// Convert {w.name} to widget
var reInput = /Convert (.*) to input/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer const/let over var.

var twgt = st("graphCanvasMenu. to widget", " to widget");
for (var i = 0; i < values.length; i++) {
var value = values[i];
// 这里对应 从 slot 拖拽弹出的菜单, 但翻译后 菜单不能正常工作
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove commented code.

function translateMenus(values, options)
{
if (!values) return;
// Convert {w.name} to input
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Remove commented code.

src/locales/zh/main.json Show resolved Hide resolved
const OriginalContextMenu = LiteGraph.ContextMenu;
LiteGraph.ContextMenu = function (values, options) {
if (options.hasOwnProperty("title")) {
options.title = st(`nodeDefs.${normalizeI18nKey(options.title)}.display_name`, options.title);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before:
image
After:
image

I think this is an acceptable change. We can update the playwright test expectations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N.B. For some nodes, this will be a more significant change, as their type / display name differ more than just by spaces.

I use the context menu as a quick shorcut to find the actual node type ID - I have seen some Discord users talk about it also.

I think this is a good change though - we should surface the backend node type in some other way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants