I18n: make new bones and bone collections' names translatable
Newly created bones and bone collections get a default name. Like other types of data, these names should be translated if the user enabled the translation of new data in the preferences. This commit adds the appropriate `DATA_()` macro: - when creating a new armature; - when creating a new bone; - when creating a new bone collection through `ANIM_bonecoll_new()`; - when ensuring that a new bone collection has a unique name; - when renaming a bone collection; - in the bone collection tests, to check that new bones have the expected translated name. It also sets the default value of the bone name in the `ARMATURE_OT_bone_primitive_add()` operator to a null string instead of "Bone", so that the default name may be chosen while checking for unique names, since an empty string will default to the translation. Pull Request: https://projects.blender.org/blender/blender/pulls/113171
This commit is contained in:
parent
72542321b0
commit
730bb2ee3e
|
@ -7,6 +7,7 @@ set(INC
|
|||
intern
|
||||
|
||||
../blenkernel
|
||||
../blentranslation
|
||||
../editors/include
|
||||
)
|
||||
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#include "BLI_string_utils.h"
|
||||
#include "BLI_utildefines.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "DNA_armature_types.h"
|
||||
|
||||
#include "BLI_math_bits.h"
|
||||
|
@ -47,7 +49,7 @@ BoneCollection *ANIM_bonecoll_new(const char *name)
|
|||
{
|
||||
if (name == nullptr || name[0] == '\0') {
|
||||
/* Use a default name if no name was given. */
|
||||
name = bonecoll_default_name;
|
||||
name = DATA_(bonecoll_default_name);
|
||||
}
|
||||
|
||||
/* Note: the collection name may change after the collection is added to an
|
||||
|
@ -112,7 +114,7 @@ static void bonecoll_ensure_name_unique(bArmature *armature, BoneCollection *bco
|
|||
{
|
||||
BLI_uniquename(&armature->collections,
|
||||
bcoll,
|
||||
bonecoll_default_name,
|
||||
DATA_(bonecoll_default_name),
|
||||
'.',
|
||||
offsetof(BoneCollection, name),
|
||||
sizeof(bcoll->name));
|
||||
|
@ -247,7 +249,7 @@ void ANIM_armature_bonecoll_name_set(bArmature *armature, BoneCollection *bcoll,
|
|||
if (name[0] == '\0') {
|
||||
/* Refuse to have nameless collections. The name of the active collection is stored in DNA, and
|
||||
* an empty string means 'no active collection'. */
|
||||
STRNCPY(bcoll->name, bonecoll_default_name);
|
||||
STRNCPY(bcoll->name, DATA_(bonecoll_default_name));
|
||||
}
|
||||
else {
|
||||
STRNCPY_UTF8(bcoll->name, name);
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "BLI_string.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "ANIM_bone_collections.h"
|
||||
|
||||
#include "testing/testing.h"
|
||||
|
@ -24,13 +26,13 @@ TEST(ANIM_bone_collections, bonecoll_default_name)
|
|||
{
|
||||
{
|
||||
BoneCollection *bcoll = ANIM_bonecoll_new("");
|
||||
EXPECT_EQ("Bones", std::string(bcoll->name));
|
||||
EXPECT_EQ(DATA_("Bones"), std::string(bcoll->name));
|
||||
ANIM_bonecoll_free(bcoll);
|
||||
}
|
||||
|
||||
{
|
||||
BoneCollection *bcoll = ANIM_bonecoll_new(nullptr);
|
||||
EXPECT_EQ("Bones", std::string(bcoll->name));
|
||||
EXPECT_EQ(DATA_("Bones"), std::string(bcoll->name));
|
||||
ANIM_bonecoll_free(bcoll);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
#include "BLI_math_vector.h"
|
||||
#include "BLI_string_utils.h"
|
||||
|
||||
#include "BLT_translation.h"
|
||||
|
||||
#include "BKE_action.h"
|
||||
#include "BKE_armature.h"
|
||||
#include "BKE_constraint.h"
|
||||
|
@ -95,7 +97,7 @@ EditBone *ED_armature_ebone_add_primitive(Object *obedit_arm, float length, bool
|
|||
ED_armature_edit_deselect_all(obedit_arm);
|
||||
|
||||
/* Create a bone */
|
||||
bone = ED_armature_ebone_add(arm, "Bone");
|
||||
bone = ED_armature_ebone_add(arm, DATA_("Bone"));
|
||||
|
||||
arm->act_edbone = bone;
|
||||
|
||||
|
@ -268,7 +270,7 @@ EditBone *add_points_bone(Object *obedit, float head[3], float tail[3])
|
|||
{
|
||||
EditBone *ebo;
|
||||
|
||||
ebo = ED_armature_ebone_add(static_cast<bArmature *>(obedit->data), "Bone");
|
||||
ebo = ED_armature_ebone_add(static_cast<bArmature *>(obedit->data), DATA_("Bone"));
|
||||
|
||||
copy_v3_v3(ebo->head, head);
|
||||
copy_v3_v3(ebo->tail, tail);
|
||||
|
@ -1695,7 +1697,7 @@ void ARMATURE_OT_bone_primitive_add(wmOperatorType *ot)
|
|||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
RNA_def_string(ot->srna, "name", "Bone", MAXBONENAME, "Name", "Name of the newly created bone");
|
||||
RNA_def_string(ot->srna, "name", nullptr, MAXBONENAME, "Name", "Name of the newly created bone");
|
||||
}
|
||||
|
||||
/* ********************** Subdivide *******************************/
|
||||
|
|
Loading…
Reference in New Issue