From 885441e75804a92d4c2270fd006f3e71fc460d7b Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Wed, 20 Mar 2013 18:42:09 +0000 Subject: I18n users request: add the ability to use a translated name for newly added/created objects or other datablocks. This simply adds a third "translation type" (in addition to iface and tip), "new data", with relevant user settings flag and helper funcs/macros (and py api). Currently implemented name translation when adding new objects, as well as modifiers and constraints, will add the others (cd layers, scenes, perhaps nodes [though I think they do not need this], etc.) later. --- source/blender/blenkernel/intern/constraint.c | 6 ++++-- source/blender/blenkernel/intern/modifier.c | 2 +- source/blender/blenkernel/intern/object.c | 26 ++++++++++++++------------ source/blender/blenkernel/intern/particle.c | 14 +++++++++----- 4 files changed, 28 insertions(+), 20 deletions(-) (limited to 'source/blender/blenkernel/intern') diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 3430c2ea7a1..dc47ff40863 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -43,6 +43,8 @@ #include "BLI_kdopbvh.h" #include "BLI_utildefines.h" +#include "BLF_translation.h" + #include "DNA_armature_types.h" #include "DNA_camera_types.h" #include "DNA_constraint_types.h" @@ -4353,12 +4355,12 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) cti->new_data(con->data); /* if no name is provided, use the type of the constraint as the name */ - newName = (name && name[0]) ? name : cti->name; + newName = (name && name[0]) ? name : DATA_(cti->name); } else { /* if no name is provided, use the generic "Const" name */ /* NOTE: any constraint type that gets here really shouldn't get added... */ - newName = (name && name[0]) ? name : "Const"; + newName = (name && name[0]) ? name : DATA_("Const"); } /* copy the name */ diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c index b0566a6495f..9b8101cdad4 100644 --- a/source/blender/blenkernel/intern/modifier.c +++ b/source/blender/blenkernel/intern/modifier.c @@ -95,7 +95,7 @@ ModifierData *modifier_new(int type) ModifierData *md = MEM_callocN(mti->structSize, mti->structName); /* note, this name must be made unique later */ - BLI_strncpy(md->name, mti->name, sizeof(md->name)); + BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name)); md->type = type; md->mode = eModifierMode_Realtime | eModifierMode_Render | eModifierMode_Expanded; diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c index c93da151463..55ec5db419d 100644 --- a/source/blender/blenkernel/intern/object.c +++ b/source/blender/blenkernel/intern/object.c @@ -65,6 +65,8 @@ #include "BLI_utildefines.h" #include "BLI_linklist.h" +#include "BLF_translation.h" + #include "BKE_pbvh.h" #include "BKE_main.h" #include "BKE_global.h" @@ -855,20 +857,20 @@ void *BKE_object_obdata_add_from_type(int type) static const char *get_obdata_defname(int type) { switch (type) { - case OB_MESH: return "Mesh"; - case OB_CURVE: return "Curve"; - case OB_SURF: return "Surf"; - case OB_FONT: return "Text"; - case OB_MBALL: return "Mball"; - case OB_CAMERA: return "Camera"; - case OB_LAMP: return "Lamp"; - case OB_LATTICE: return "Lattice"; - case OB_ARMATURE: return "Armature"; - case OB_SPEAKER: return "Speaker"; - case OB_EMPTY: return "Empty"; + case OB_MESH: return DATA_("Mesh"); + case OB_CURVE: return DATA_("Curve"); + case OB_SURF: return DATA_("Surf"); + case OB_FONT: return DATA_("Text"); + case OB_MBALL: return DATA_("Mball"); + case OB_CAMERA: return DATA_("Camera"); + case OB_LAMP: return DATA_("Lamp"); + case OB_LATTICE: return DATA_("Lattice"); + case OB_ARMATURE: return DATA_("Armature"); + case OB_SPEAKER: return DATA_("Speaker"); + case OB_EMPTY: return DATA_("Empty"); default: printf("get_obdata_defname: Internal error, bad type: %d\n", type); - return "Empty"; + return DATA_("Empty"); } } diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index f90fde983aa..d9dabf24ba0 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -56,6 +56,8 @@ #include "BLI_threads.h" #include "BLI_linklist.h" +#include "BLF_translation.h" + #include "BKE_anim.h" #include "BKE_animsys.h" @@ -3488,17 +3490,19 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n psys->pointcache = BKE_ptcache_add(&psys->ptcaches); BLI_addtail(&ob->particlesystem, psys); - psys->part = psys_new_settings("ParticleSettings", NULL); + psys->part = psys_new_settings(DATA_("ParticleSettings"), NULL); if (BLI_countlist(&ob->particlesystem) > 1) - BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + BLI_snprintf(psys->name, sizeof(psys->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); else - strcpy(psys->name, "ParticleSystem"); + strcpy(psys->name, DATA_("ParticleSystem")); md = modifier_new(eModifierType_ParticleSystem); - if (name) BLI_strncpy_utf8(md->name, name, sizeof(md->name)); - else BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem)); + if (name) + BLI_strncpy_utf8(md->name, name, sizeof(md->name)); + else + BLI_snprintf(md->name, sizeof(md->name), DATA_("ParticleSystem %i"), BLI_countlist(&ob->particlesystem)); modifier_unique_name(&ob->modifiers, md); psmd = (ParticleSystemModifierData *) md; -- cgit v1.2.3