I18n: write messages of the vertex group lock operator explicitly #104484

Closed
Damien Picard wants to merge 1 commits from pioverfour:dp_improve_lock_vertex_group into blender-v3.5-release

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
1 changed files with 44 additions and 36 deletions

View File

@ -3446,55 +3446,63 @@ static char *vertex_group_lock_description(bContext * /*C*/,
int action = RNA_enum_get(params, "action");
int mask = RNA_enum_get(params, "mask");
const char *action_str, *target_str;
/* NOTE: constructing the following string literals can be done in a less verbose way,
pioverfour marked this conversation as resolved
Review

It would be good to include a comment, adding context to why strings are handled this way, otherwise someone who stumbles on the code might this as an opportunity to de-duplicate text.

/* NOTE: constructing the following string literals can be done in a less verbose way,
 * however the resulting strings can't be usefully translated, (via `TIP_`). */`
It would be good to include a comment, adding context to why strings are handled this way, otherwise someone who stumbles on the code might this as an opportunity to de-duplicate text. ``` /* NOTE: constructing the following string literals can be done in a less verbose way, * however the resulting strings can't be usefully translated, (via `TIP_`). */`
* however the resulting strings can't be usefully translated, (via `TIP_`). */
switch (action) {
case VGROUP_LOCK:
action_str = TIP_("Lock");
switch (mask) {
case VGROUP_MASK_ALL:
return BLI_strdup(TIP_("Lock all vertex groups of the active object"));
pioverfour marked this conversation as resolved
Review

I'd suggest putting the return directly in the switch cases and removing the break lines like

case VGROUP_MASK_ALL:
          return BLI_strdup(TIP_("Lock all vertex groups of the active object"));
case ...:

That would make the duplication here more manageable (and just take up less screen space!)

I'd suggest putting the `return` directly in the switch cases and removing the `break` lines like ``` case VGROUP_MASK_ALL: return BLI_strdup(TIP_("Lock all vertex groups of the active object")); case ...: ``` That would make the duplication here more manageable (and just take up less screen space!)
Review

You’re right, it’s much more legible!

You’re right, it’s much more legible!
case VGROUP_MASK_SELECTED:
return BLI_strdup(TIP_("Lock selected vertex groups of the active object"));
case VGROUP_MASK_UNSELECTED:
return BLI_strdup(TIP_("Lock unselected vertex groups of the active object"));
case VGROUP_MASK_INVERT_UNSELECTED:
return BLI_strdup(
TIP_("Lock selected and unlock unselected vertex groups of the active object"));
}
break;
case VGROUP_UNLOCK:
action_str = TIP_("Unlock");
switch (mask) {
case VGROUP_MASK_ALL:
return BLI_strdup(TIP_("Unlock all vertex groups of the active object"));
case VGROUP_MASK_SELECTED:
return BLI_strdup(TIP_("Unlock selected vertex groups of the active object"));
case VGROUP_MASK_UNSELECTED:
return BLI_strdup(TIP_("Unlock unselected vertex groups of the active object"));
case VGROUP_MASK_INVERT_UNSELECTED:
return BLI_strdup(
TIP_("Unlock selected and lock unselected vertex groups of the active object"));
}
break;
case VGROUP_TOGGLE:
action_str = TIP_("Toggle locks of");
switch (mask) {
case VGROUP_MASK_ALL:
return BLI_strdup(TIP_("Toggle locks of all vertex groups of the active object"));
case VGROUP_MASK_SELECTED:
return BLI_strdup(TIP_("Toggle locks of selected vertex groups of the active object"));
case VGROUP_MASK_UNSELECTED:
return BLI_strdup(TIP_("Toggle locks of unselected vertex groups of the active object"));
case VGROUP_MASK_INVERT_UNSELECTED:
return BLI_strdup(TIP_(
"Toggle locks of all and invert unselected vertex groups of the active object"));
}
break;
case VGROUP_INVERT:
action_str = TIP_("Invert locks of");
break;
default:
return nullptr;
}
switch (mask) {
case VGROUP_MASK_ALL:
target_str = TIP_("all");
break;
case VGROUP_MASK_SELECTED:
target_str = TIP_("selected");
break;
case VGROUP_MASK_UNSELECTED:
target_str = TIP_("unselected");
break;
case VGROUP_MASK_INVERT_UNSELECTED:
switch (action) {
case VGROUP_INVERT:
target_str = TIP_("selected");
break;
case VGROUP_LOCK:
target_str = TIP_("selected and unlock unselected");
break;
case VGROUP_UNLOCK:
target_str = TIP_("selected and lock unselected");
break;
default:
target_str = TIP_("all and invert unselected");
switch (mask) {
case VGROUP_MASK_ALL:
return BLI_strdup(TIP_("Invert locks of all vertex groups of the active object"));
case VGROUP_MASK_SELECTED:
case VGROUP_MASK_INVERT_UNSELECTED:
return BLI_strdup(TIP_("Invert locks of selected vertex groups of the active object"));
case VGROUP_MASK_UNSELECTED:
return BLI_strdup(TIP_("Invert locks of unselected vertex groups of the active object"));
}
break;
default:
return nullptr;
}
return BLI_sprintfN(TIP_("%s %s vertex groups of the active object"), action_str, target_str);
return nullptr;
}
void OBJECT_OT_vertex_group_lock(wmOperatorType *ot)