Fix: Missing translations from operator descriptions

The strings in the `get_description` functions for operators need
translation, they are not found by the translation system automatically,
and there is no translation applied afterwards either (as far as I could
tell). Some used `N_` before, but most did nothing.

Differential Revision: https://developer.blender.org/D14011
This commit is contained in:
Hans Goudey 2022-02-04 07:31:53 -06:00
parent 623ff64a27
commit 7099d5b661
11 changed files with 47 additions and 35 deletions

View File

@ -21,6 +21,7 @@ set(INC
../../blenkernel
../../blenlib
../../blenloader
../../blentranslation
../../makesdna
../../makesrna
../../windowmanager

View File

@ -39,6 +39,8 @@
/* XXX needs access to the file list, should all be done via the asset system in future. */
#include "ED_fileselect.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -342,8 +344,8 @@ static bool asset_clear_poll(bContext *C)
IDVecStats ctx_stats = asset_operation_get_id_vec_stats_from_context(C);
if (!ctx_stats.has_asset) {
const char *msg_single = "Data-block is not marked as asset";
const char *msg_multiple = "No data-block selected that is marked as asset";
const char *msg_single = TIP_("Data-block is not marked as asset");
const char *msg_multiple = TIP_("No data-block selected that is marked as asset");
CTX_wm_operator_poll_msg_set(C, ctx_stats.is_single ? msg_single : msg_multiple);
return false;
}
@ -365,8 +367,8 @@ static char *asset_clear_get_description(struct bContext *UNUSED(C),
}
return BLI_strdup(
"Delete all asset metadata, turning the selected asset data-blocks back into normal "
"data-blocks, and set Fake User to ensure the data-blocks will still be saved");
TIP_("Delete all asset metadata, turning the selected asset data-blocks back into normal "
"data-blocks, and set Fake User to ensure the data-blocks will still be saved"));
}
static void ASSET_OT_clear(wmOperatorType *ot)

View File

@ -1408,15 +1408,15 @@ static char *edbm_select_mode_get_description(struct bContext *UNUSED(C),
!RNA_struct_property_is_set(values, "action")) {
switch (type) {
case SCE_SELECT_VERTEX:
return BLI_strdup(
N_("Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
return BLI_strdup(TIP_(
"Vertex select - Shift-Click for multiple modes, Ctrl-Click contracts selection"));
case SCE_SELECT_EDGE:
return BLI_strdup(
N_("Edge select - Shift-Click for multiple modes, "
"Ctrl-Click expands/contracts selection depending on the current mode"));
TIP_("Edge select - Shift-Click for multiple modes, "
"Ctrl-Click expands/contracts selection depending on the current mode"));
case SCE_SELECT_FACE:
return BLI_strdup(
N_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
TIP_("Face select - Shift-Click for multiple modes, Ctrl-Click expands selection"));
}
}

View File

@ -43,6 +43,8 @@
#include "DEG_depsgraph.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@ -610,8 +612,8 @@ static char *data_transfer_get_description(bContext *UNUSED(C),
const bool reverse_transfer = RNA_boolean_get(ptr, "use_reverse_transfer");
if (reverse_transfer) {
return BLI_strdup(
"Transfer data layer(s) (weights, edge sharp, etc.) from selected meshes to active one");
return BLI_strdup(TIP_(
"Transfer data layer(s) (weights, edge sharp, etc.) from selected meshes to active one"));
}
return NULL;

View File

@ -84,6 +84,8 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
#include "RNA_enum_types.h"
@ -1521,7 +1523,7 @@ static char *modifier_apply_as_shapekey_get_description(struct bContext *UNUSED(
bool keep = RNA_boolean_get(values, "keep_modifier");
if (keep) {
return BLI_strdup("Apply modifier as a new shapekey and keep it in the stack");
return BLI_strdup(TIP_("Apply modifier as a new shapekey and keep it in the stack"));
}
return NULL;

View File

@ -64,6 +64,8 @@
#include "DEG_depsgraph_build.h"
#include "DEG_depsgraph_query.h"
#include "BLT_translation.h"
#include "DNA_armature_types.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -3427,16 +3429,16 @@ static char *vertex_group_lock_description(struct bContext *UNUSED(C),
switch (action) {
case VGROUP_LOCK:
action_str = "Lock";
action_str = TIP_("Lock");
break;
case VGROUP_UNLOCK:
action_str = "Unlock";
action_str = TIP_("Unlock");
break;
case VGROUP_TOGGLE:
action_str = "Toggle locks of";
action_str = TIP_("Toggle locks of");
break;
case VGROUP_INVERT:
action_str = "Invert locks of";
action_str = TIP_("Invert locks of");
break;
default:
return NULL;
@ -3444,34 +3446,34 @@ static char *vertex_group_lock_description(struct bContext *UNUSED(C),
switch (mask) {
case VGROUP_MASK_ALL:
target_str = "all";
target_str = TIP_("all");
break;
case VGROUP_MASK_SELECTED:
target_str = "selected";
target_str = TIP_("selected");
break;
case VGROUP_MASK_UNSELECTED:
target_str = "unselected";
target_str = TIP_("unselected");
break;
case VGROUP_MASK_INVERT_UNSELECTED:
switch (action) {
case VGROUP_INVERT:
target_str = "selected";
target_str = TIP_("selected");
break;
case VGROUP_LOCK:
target_str = "selected and unlock unselected";
target_str = TIP_("selected and unlock unselected");
break;
case VGROUP_UNLOCK:
target_str = "selected and lock unselected";
target_str = TIP_("selected and lock unselected");
break;
default:
target_str = "all and invert unselected";
target_str = TIP_("all and invert unselected");
}
break;
default:
return NULL;
}
return BLI_sprintfN("%s %s vertex groups of the active object", action_str, target_str);
return BLI_sprintfN(TIP_("%s %s vertex groups of the active object"), action_str, target_str);
}
void OBJECT_OT_vertex_group_lock(wmOperatorType *ot)

View File

@ -72,8 +72,11 @@
#include "IMB_colormanagement.h"
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
#include "RE_pipeline.h"
#include "BLT_translation.h"
#include "RNA_access.h"
#include "RNA_define.h"
@ -1326,12 +1329,12 @@ static char *screen_opengl_render_description(struct bContext *UNUSED(C),
}
if (RNA_boolean_get(ptr, "render_keyed_only")) {
return BLI_strdup(
return BLI_strdup(TIP_(
"Render the viewport for the animation range of this scene, but only render keyframes of "
"selected objects");
"selected objects"));
}
return BLI_strdup("Render the viewport for the animation range of this scene");
return BLI_strdup(TIP_("Render the viewport for the animation range of this scene"));
}
void RENDER_OT_opengl(wmOperatorType *ot)

View File

@ -658,7 +658,7 @@ static char *actkeys_paste_description(bContext *UNUSED(C),
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
return BLI_strdup("Paste keyframes from mirrored bones if they exist");
return BLI_strdup(TIP_("Paste keyframes from mirrored bones if they exist"));
}
/* Use the default description in the other cases. */

View File

@ -586,7 +586,7 @@ static char *graphkeys_paste_description(bContext *UNUSED(C),
{
/* Custom description if the 'flipped' option is used. */
if (RNA_boolean_get(ptr, "flipped")) {
return BLI_strdup("Paste keyframes from mirrored bones if they exist");
return BLI_strdup(TIP_("Paste keyframes from mirrored bones if they exist"));
}
/* Use the default description in the other cases. */

View File

@ -483,7 +483,7 @@ static char *decimate_desc(bContext *UNUSED(C), wmOperatorType *UNUSED(op), Poin
if (RNA_enum_get(ptr, "mode") == DECIM_ERROR) {
return BLI_strdup(
"Decimate F-Curves by specifying how much it can deviate from the original curve");
TIP_("Decimate F-Curves by specifying how much it can deviate from the original curve"));
}
/* Use default description. */

View File

@ -2704,7 +2704,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
BLI_stat_t stats;
if (BLI_stat(path, &stats) == -1) {
return BLI_sprintfN("%s\n\n%s", path, N_("File Not Found"));
return BLI_sprintfN("%s\n\n%s", path, TIP_("File Not Found"));
}
/* Date. */
@ -2714,7 +2714,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
BLI_filelist_entry_datetime_to_string(
NULL, (int64_t)stats.st_mtime, false, time_st, date_st, &is_today, &is_yesterday);
if (is_today || is_yesterday) {
BLI_strncpy(date_st, is_today ? N_("Today") : N_("Yesterday"), sizeof(date_st));
BLI_strncpy(date_st, is_today ? TIP_("Today") : TIP_("Yesterday"), sizeof(date_st));
}
/* Size. */
@ -2722,7 +2722,7 @@ static char *wm_open_mainfile_description(struct bContext *UNUSED(C),
BLI_filelist_entry_size_to_string(NULL, (uint64_t)stats.st_size, false, size_str);
return BLI_sprintfN(
"%s\n\n%s: %s %s\n%s: %s", path, N_("Modified"), date_st, time_st, N_("Size"), size_str);
"%s\n\n%s: %s %s\n%s: %s", path, TIP_("Modified"), date_st, time_st, TIP_("Size"), size_str);
}
/* currently fits in a pointer */
@ -3169,8 +3169,8 @@ static char *wm_save_as_mainfile_get_description(bContext *UNUSED(C),
PointerRNA *ptr)
{
if (RNA_boolean_get(ptr, "copy")) {
return BLI_strdup(
"Save the current file in the desired location but do not make the saved file active");
return BLI_strdup(TIP_(
"Save the current file in the desired location but do not make the saved file active"));
}
return NULL;
}