Skip to content

Fix root auto-translate mode ignored for child nodes when generating POT #108772

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timothyqiu
Copy link
Member

Fixes #108744

Currently, when trying to determine whether a node using AUTO_TRANSLATE_MODE_INHERIT should be extracted or not, if only one of the node's ancestors has an explicit auto-translate mode, then this record is unexpectedly ignored (see the idx_last > 0 below).

// If `auto_translate_mode` wasn't found, that means it is set to its default value (`AUTO_TRANSLATE_MODE_INHERIT`).
if (!auto_translate_mode_found) {
int idx_last = atr_owners.size() - 1;
if (idx_last > 0 && parent_path.begins_with(String(atr_owners[idx_last].first))) {
auto_translating = atr_owners[idx_last].second;
} else {
atr_owners.push_back(Pair(state->get_node_path(i), true));
}
}

I believe this is a copy-paste error. The if condition is copied from the block a few lines above:

int idx_last = atr_owners.size() - 1;
if (idx_last > 0 && !parent_path.begins_with(String(atr_owners[idx_last].first))) {
// Exit from the current owner nesting into the previous one.
atr_owners.remove_at(idx_last);
}

If I understand correctly, this code makes sure that the array acts as a stack, making the array only contain information about the current node's ancestor nodes. When switching tree branches, it removes the previous branch's data. Since the root node is always one of the ancestor nodes, skipping it makes sense here as an optimization.

CC @YeldhamDev

Copy link
Member

@YeldhamDev YeldhamDev left a comment

Choose a reason for hiding this comment

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

Seems correct.

@AThousandShips AThousandShips added this to the 4.5 milestone Jul 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inherit in Auto Translate Mode is always generated by POT generation.
3 participants