i18n: do not translate obect mode enum and transform orientation enum if UI translati...
authorSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Sep 2011 10:32:53 +0000 (10:32 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 19 Sep 2011 10:32:53 +0000 (10:32 +0000)
release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/space_view3d/view3d_header.c
source/blender/editors/transform/transform_orientations.c

index d1009a0..fa64e24 100644 (file)
@@ -483,10 +483,9 @@ class USERPREF_PT_system(Panel):
 
         column.prop(system, "use_international_fonts")
         if system.use_international_fonts:
-            column.label(text=_("Select Language:"))
-            column.prop(system, "language", text="")
-            column.label(text="Translate:")
+            column.prop(system, "language")
             row = column.row()
+            row.label(text="Translate:")
             row.prop(system, "use_translate_interface", text="Interface")
             row.prop(system, "use_translate_tooltips", text="Tooltips")
 
index 0e36e05..0664009 100644 (file)
@@ -2686,7 +2686,7 @@ static uiBut *ui_def_but_operator(uiBlock *block, int type, const char *opname,
                tip= ot->description;
 
 #ifdef INTERNATIONAL
-               if((U.transopts&USER_DOTRANSLATE) && (U.transopts|USER_TR_TOOLTIPS))
+               if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_TOOLTIPS))
                        tip= BLF_gettext(tip);
 #endif
        }
index e673add..208babe 100644 (file)
@@ -343,6 +343,7 @@ static void ui_tooltip_region_free_cb(ARegion *ar)
        ar->regiondata= NULL;
 }
 
+#define U_(msgid) (((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_TOOLTIPS))?BLF_gettext(msgid):(msgid))
 ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 {
        uiStyle *style= UI_GetStyle();
@@ -403,7 +404,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                prop= (but->opptr)? but->opptr->data: NULL;
 
                if(WM_key_event_operator_string(C, but->optype->idname, but->opcontext, prop, buf, sizeof(buf))) {
-                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), _("Shortcut: %s"), buf);
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Shortcut: %s")), buf);
                        data->color[data->totline]= 0x888888;
                        data->totline++;
                }
@@ -413,7 +414,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                /* full string */
                ui_get_but_string(but, buf, sizeof(buf));
                if(buf[0]) {
-                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Value: %s", buf);
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Value: %s")), buf);
                        data->color[data->totline]= 0x888888;
                        data->totline++;
                }
@@ -425,7 +426,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                if (unit_type == PROP_UNIT_ROTATION) {
                        if (RNA_property_type(but->rnaprop) == PROP_FLOAT) {
                                float value= RNA_property_array_check(but->rnaprop) ? RNA_property_float_get_index(&but->rnapoin, but->rnaprop, but->rnaindex) : RNA_property_float_get(&but->rnapoin, but->rnaprop);
-                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Radians: %f", value);
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Radians: %f")), value);
                                data->color[data->totline]= 0x888888;
                                data->totline++;
                        }
@@ -434,7 +435,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                if(but->flag & UI_BUT_DRIVEN) {
                        if(ui_but_anim_expression_get(but, buf, sizeof(buf))) {
                                /* expression */
-                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Expression: %s", buf);
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Expression: %s")), buf);
                                data->color[data->totline]= 0x888888;
                                data->totline++;
                        }
@@ -442,7 +443,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 
                /* rna info */
                if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
-                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s.%s", RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Python: %s.%s")), RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
                        data->color[data->totline]= 0x888888;
                        data->totline++;
                }
@@ -450,7 +451,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                if(but->rnapoin.id.data) {
                        ID *id= but->rnapoin.id.data;
                        if(id->lib && id->lib->name) {
-                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Library: %s", id->lib->name);
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Library: %s")), id->lib->name);
                                data->color[data->totline]= 0x888888;
                                data->totline++;
                        }
@@ -465,7 +466,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 
                /* operator info */
                if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
-                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", str);
+                       BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Python: %s")), str);
                        data->color[data->totline]= 0x888888;
                        data->totline++;
                }
@@ -479,7 +480,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                        WM_operator_poll_context(C, but->optype, but->opcontext);
                        poll_msg= CTX_wm_operator_poll_msg_get(C);
                        if(poll_msg) {
-                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Disabled: %s", poll_msg);
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Disabled: %s")), poll_msg);
                                data->color[data->totline]= 0x6666ff; /* alert */
                                data->totline++;                        
                        }
@@ -489,7 +490,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
                if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
                        if(but->menu_create_func && WM_menutype_contains((MenuType *)but->poin)) {
                                MenuType *mt= (MenuType *)but->poin;
-                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), "Python: %s", mt->idname);
+                               BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), U_(N_("Python: %s")), mt->idname);
                                data->color[data->totline]= 0x888888;
                                data->totline++;
                        }
@@ -608,6 +609,7 @@ ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 
        return ar;
 }
+#undef U_
 
 void ui_tooltip_free(bContext *C, ARegion *ar)
 {
index 86f2af5..221bf8e 100644 (file)
@@ -271,16 +271,29 @@ void VIEW3D_OT_layers(wmOperatorType *ot)
        RNA_def_boolean(ot->srna, "toggle", 1, "Toggle", "Toggle the layer");
 }
 
+static int modeselect_addmode(char *str, const char *title, int id, int icon)
+{
+       static char formatstr[] = "|%s %%x%d %%i%d";
+
+       if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_IFACE))
+               return sprintf(str, formatstr, BLF_gettext(title), id, icon);
+       else
+               return sprintf(str, formatstr, title, id, icon);
+}
+
 static char *view3d_modeselect_pup(Scene *scene)
 {
        Object *ob= OBACT;
        static char string[256];
-       static char formatstr[] = "|%s %%x%d %%i%d";
+       const char *title= N_("Mode: %%t");
        char *str = string;
 
-       str += sprintf(str, _("Mode: %%t"));
+       if(U.transopts&USER_TR_IFACE)
+               title= BLF_gettext(title);
+
+       sprintf(str, title);
        
-       str += sprintf(str, formatstr, _("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA);
+       str += modeselect_addmode(str, N_("Object Mode"), OB_MODE_OBJECT, ICON_OBJECT_DATA);
        
        if(ob==NULL || ob->data==NULL) return string;
        if(ob->id.lib) return string;
@@ -291,31 +304,31 @@ static char *view3d_modeselect_pup(Scene *scene)
                        || (ob->type == OB_CURVE) || (ob->type == OB_SURF) || (ob->type == OB_FONT)
                        || (ob->type == OB_MBALL) || (ob->type == OB_LATTICE))) {
                        
-                       str += sprintf(str, formatstr, _("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
+                       str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
                }
                else if (ob->type == OB_ARMATURE) {
                        if (ob->mode & OB_MODE_POSE)
-                               str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
+                               str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT|OB_MODE_POSE, ICON_EDITMODE_HLT);
                        else
-                               str += sprintf(str, formatstr, "Edit Mode", OB_MODE_EDIT, ICON_EDITMODE_HLT);
+                               str += modeselect_addmode(str, N_("Edit Mode"), OB_MODE_EDIT, ICON_EDITMODE_HLT);
                }
 
                if (ob->type == OB_MESH) {
 
-                       str += sprintf(str, formatstr, _("Sculpt Mode"), OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
-                       str += sprintf(str, formatstr, _("Vertex Paint"), OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
-                       str += sprintf(str, formatstr, _("Texture Paint"), OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
-                       str += sprintf(str, formatstr, _("Weight Paint"), OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
+                       str += modeselect_addmode(str, N_("Sculpt Mode"), OB_MODE_SCULPT, ICON_SCULPTMODE_HLT);
+                       str += modeselect_addmode(str, N_("Vertex Paint"), OB_MODE_VERTEX_PAINT, ICON_VPAINT_HLT);
+                       str += modeselect_addmode(str, N_("Texture Paint"), OB_MODE_TEXTURE_PAINT, ICON_TPAINT_HLT);
+                       str += modeselect_addmode(str, N_("Weight Paint"), OB_MODE_WEIGHT_PAINT, ICON_WPAINT_HLT);
                }
        }
                
        /* if active object is an armature */
        if (ob->type==OB_ARMATURE) {
-               str += sprintf(str, formatstr, _("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT);
+               str += modeselect_addmode(str, N_("Pose Mode"), OB_MODE_POSE, ICON_POSE_HLT);
        }
 
        if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) {
-               str += sprintf(str, formatstr, _("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
+               str += modeselect_addmode(str, N_("Particle Mode"), OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
        }
        (void)str;
        return (string);
@@ -457,6 +470,7 @@ void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C)
        }
 }
 
+#define TIP_(msgid) (((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_TOOLTIPS))?BLF_gettext(msgid):(msgid))
 void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 {
        bScreen *screen= CTX_wm_screen(C);
@@ -490,7 +504,7 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
 
        uiBlockBeginAlign(block);
        uiDefIconTextButS(block, MENU, B_MODESELECT, object_mode_icon(v3d->modeselect), view3d_modeselect_pup(scene) , 
-                         0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, _("Mode"));
+                         0,0,126 * dpi_fac, UI_UNIT_Y, &(v3d->modeselect), 0, 0, 0, 0, TIP_(N_("Mode")));
        uiBlockEndAlign(block);
        
        /* Draw type */
@@ -516,11 +530,11 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                block= uiLayoutGetBlock(row);
                
                if(v3d->twflag & V3D_USE_MANIPULATOR) {
-                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, _("Translate manipulator mode"));
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_TRANSLATE, B_MAN_TRANS, ICON_MAN_TRANS, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_(N_("Translate manipulator mode")));
                        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
-                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, _("Rotate manipulator mode"));
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_ROTATE, B_MAN_ROT, ICON_MAN_ROT, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_(N_("Rotate manipulator mode")));
                        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
-                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, _("Scale manipulator mode"));
+                       but= uiDefIconButBitC(block, TOG, V3D_MANIP_SCALE, B_MAN_SCALE, ICON_MAN_SCALE, 0,0,UI_UNIT_X,UI_UNIT_Y, &v3d->twtype, 1.0, 0.0, 0, 0, TIP_(N_("Scale manipulator mode")));
                        uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
                }
                        
@@ -528,8 +542,8 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
                        v3d->twmode = 0;
                }
                        
-               str_menu = BIF_menustringTransformOrientation(C, _("Orientation"));
-               but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, _("Transform Orientation"));
+               str_menu = BIF_menustringTransformOrientation(C, N_("Orientation"));
+               but= uiDefButC(block, MENU, B_MAN_MODE, str_menu,0,0,70 * dpi_fac, UI_UNIT_Y, &v3d->twmode, 0, 0, 0, 0, TIP_(N_("Transform Orientation")));
                uiButClearFlag(but, UI_BUT_UNDO); /* skip undo on screen buttons */
                MEM_freeN((void *)str_menu);
        }
@@ -549,4 +563,4 @@ void uiTemplateHeader3D(uiLayout *layout, struct bContext *C)
        
        uiTemplateEditModeSelection(layout, C);
 }
-
+#undef TIP_
index 68bf7d1..d25e330 100644 (file)
@@ -408,12 +408,16 @@ EnumPropertyItem *BIF_enumTransformOrientation(bContext *C)
 }
 
 const char * BIF_menustringTransformOrientation(const bContext *C, const char *title) {
-       const char* menu = _("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
+       const char* menu = N_("%t|Global%x0|Local%x1|Gimbal%x4|Normal%x2|View%x3");
        ListBase *transform_spaces = &CTX_data_scene(C)->transform_spaces;
        TransformOrientation *ts;
        int i = V3D_MANIP_CUSTOM;
        char *str_menu, *p;
        
+       if((U.transopts&USER_DOTRANSLATE) && (U.transopts&USER_TR_IFACE)) {
+               title= BLF_gettext(title);
+               menu= BLF_gettext(menu);
+       }
        
        str_menu = MEM_callocN(strlen(menu) + strlen(title) + 1 + 40 * BIF_countTransformOrientation(C), _("UserTransSpace from matrix"));
        p = str_menu;