[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [41159] trunk/blender/source/blender: Cleaning i18n code.

Bastien Montagne montagne29 at wanadoo.fr
Thu Oct 20 22:38:26 CEST 2011


Revision: 41159
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=41159
Author:   mont29
Date:     2011-10-20 20:38:26 +0000 (Thu, 20 Oct 2011)
Log Message:
-----------
Cleaning i18n code.

Previous state:
Right now, there are "memories" of the "old" (less than a month!) translation way:
* A few remaining calls to BLF_gettext() (only UI_translate_do_iface and UI_translate_do_tooltip should be used).
* The _() macro still also calls BLF_gettext()!

New state:
Here are the changes made by the patch:
* Removing the no more needed _() macro.
* Removing most N_() and _() calls, only keeping the few needed ones (i.e. strings that are in no other way findable by xgettext and/or update_msg script).
* Defining in UI_interface.h IFACE_() and TIP_() macros (resp. for UI_translate_do_iface and UI_translate_do_tooltip).
* Replacing all calls to BLF_gettext by relevant IFACE_ or TIP_ one.
* Replacing all calls to UI_translate_do_iface by IFACE_.
* Replacing all calls to UI_translate_do_tooltip by TIP_.

All this somewhat clarifies and simplifies the code.
On the bf-translations scripts side, this only implies adding IFACE_ and TIP_ as detection markers for xgettext.
It also allows to reduce POTFILES.in quite notably (only 20 files remaining in it).

Please also have a look at those pages:
* Coder POV: http://wiki.blender.org/index.php/Dev:2.5/Source/Interface/Internationalization
* Translator POV: http://wiki.blender.org/index.php/Dev:2.5/Doc/How_to/Translate_Blender

Modified Paths:
--------------
    trunk/blender/source/blender/blenfont/BLF_translation.h
    trunk/blender/source/blender/editors/armature/poselib.c
    trunk/blender/source/blender/editors/include/UI_interface.h
    trunk/blender/source/blender/editors/interface/interface.c
    trunk/blender/source/blender/editors/interface/interface_layout.c
    trunk/blender/source/blender/editors/interface/interface_panel.c
    trunk/blender/source/blender/editors/interface/interface_regions.c
    trunk/blender/source/blender/editors/interface/interface_templates.c
    trunk/blender/source/blender/editors/interface/interface_utils.c
    trunk/blender/source/blender/editors/screen/area.c
    trunk/blender/source/blender/editors/space_buttons/buttons_header.c
    trunk/blender/source/blender/editors/space_file/file_draw.c
    trunk/blender/source/blender/editors/space_file/file_panels.c
    trunk/blender/source/blender/editors/space_graph/graph_buttons.c
    trunk/blender/source/blender/editors/space_info/space_info.c
    trunk/blender/source/blender/editors/space_nla/nla_buttons.c
    trunk/blender/source/blender/editors/space_node/node_header.c
    trunk/blender/source/blender/editors/space_view3d/view3d_header.c
    trunk/blender/source/blender/editors/space_view3d/view3d_toolbar.c
    trunk/blender/source/blender/editors/transform/transform_orientations.c
    trunk/blender/source/blender/makesrna/intern/rna_userdef.c
    trunk/blender/source/blender/python/intern/bpy_rna.c
    trunk/blender/source/blender/windowmanager/intern/wm_files.c
    trunk/blender/source/blender/windowmanager/intern/wm_operators.c
    trunk/blender/source/blender/windowmanager/intern/wm_window.c

Modified: trunk/blender/source/blender/blenfont/BLF_translation.h
===================================================================
--- trunk/blender/source/blender/blenfont/BLF_translation.h	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/blenfont/BLF_translation.h	2011-10-20 20:38:26 UTC (rev 41159)
@@ -60,7 +60,8 @@
 
 void BLF_lang_encoding(const char *str);
 
-#define _(msgid) BLF_gettext(msgid)
+/*#define _(msgid) BLF_gettext(msgid)*/
+/* The "translation-marker" macro. */
 #define N_(msgid) msgid
 
 #endif /* BLF_TRANSLATION_H */

Modified: trunk/blender/source/blender/editors/armature/poselib.c
===================================================================
--- trunk/blender/source/blender/editors/armature/poselib.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/armature/poselib.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -409,15 +409,15 @@
 	uiLayoutSetOperatorContext(layout, WM_OP_EXEC_DEFAULT);
 	
 	/* add new (adds to the first unoccupied frame) */
-	uiItemIntO(layout, UI_translate_do_iface(N_("Add New")), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
+	uiItemIntO(layout, IFACE_("Add New"), ICON_NONE, "POSELIB_OT_pose_add", "frame", poselib_get_free_index(ob->poselib));
 	
 	/* check if we have any choices to add a new pose in any other way */
 	if ((ob->poselib) && (ob->poselib->markers.first)) {
 		/* add new (on current frame) */
-		uiItemIntO(layout, UI_translate_do_iface(N_("Add New (Current Frame)")), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA);
+		uiItemIntO(layout, IFACE_("Add New (Current Frame)"), ICON_NONE, "POSELIB_OT_pose_add", "frame", CFRA);
 		
 		/* replace existing - submenu */
-		uiItemMenuF(layout, UI_translate_do_iface(N_("Replace Existing...")), 0, poselib_add_menu_invoke__replacemenu, NULL);
+		uiItemMenuF(layout, IFACE_("Replace Existing..."), 0, poselib_add_menu_invoke__replacemenu, NULL);
 	}
 	
 	uiPupMenuEnd(C, pup);

Modified: trunk/blender/source/blender/editors/include/UI_interface.h
===================================================================
--- trunk/blender/source/blender/editors/include/UI_interface.h	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/include/UI_interface.h	2011-10-20 20:38:26 UTC (rev 41159)
@@ -813,5 +813,9 @@
 const char *UI_translate_do_iface(const char *msgid);
 const char *UI_translate_do_tooltip(const char *msgid);
 
+/* Those macros should be used everywhere in UI code. */
+#define IFACE_(msgid) UI_translate_do_iface(msgid)
+#define TIP_(msgid) UI_translate_do_tooltip(msgid)
+
 #endif /*  UI_INTERFACE_H */
 

Modified: trunk/blender/source/blender/editors/interface/interface.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/interface/interface.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -2773,10 +2773,7 @@
 	if ((!tip || tip[0]=='\0') && ot && ot->description) {
 		tip= ot->description;
 
-#ifdef WITH_INTERNATIONAL
-		if(UI_translate_tooltips())
-			tip= BLF_gettext(tip);
-#endif
+		tip = TIP_(tip);
 	}
 
 	but= ui_def_but(block, type, -1, str, x1, y1, x2, y2, NULL, 0, 0, 0, 0, tip);

Modified: trunk/blender/source/blender/editors/interface/interface_layout.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_layout.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/interface/interface_layout.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -637,11 +637,7 @@
 	}
 
 	if(!name) {
-		name= ot->name;
-
-#ifdef WITH_INTERNATIONAL
-		name= UI_translate_do_iface(name);
-#endif
+		name= IFACE_(ot->name);
 	}
 
 	if(layout->root->type == UI_LAYOUT_MENU && !icon)
@@ -1430,11 +1426,7 @@
 	}
 
 	if(!name) {
-		name= mt->label;
-
-#ifdef WITH_INTERNATIONAL
-		name= UI_translate_do_iface(name);
-#endif
+		name= IFACE_(mt->label);
 	}
 
 	if(layout->root->type == UI_LAYOUT_MENU && !icon)
@@ -2808,7 +2800,7 @@
 		empty= uiDefAutoButsRNA(layout, &ptr, check_prop, label_align) == 0;
 
 		if(empty && (flag & UI_LAYOUT_OP_SHOW_EMPTY)) {
-			uiItemL(layout, UI_translate_do_iface(N_("No Properties")), ICON_NONE);
+			uiItemL(layout, IFACE_("No Properties"), ICON_NONE);
 		}
 	}
 	

Modified: trunk/blender/source/blender/editors/interface/interface_panel.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_panel.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/interface/interface_panel.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -442,12 +442,8 @@
 	Panel *panel= block->panel;
 	rcti hrect;
 	int  pnl_icons;
-	const char *activename= panel->drawname[0]?panel->drawname:panel->panelname;
+	const char *activename= IFACE_(panel->drawname[0] ? panel->drawname : panel->panelname);
 
-#ifdef WITH_INTERNATIONAL
-	activename= UI_translate_do_iface(activename);
-#endif
-
 	/* + 0.001f to avoid flirting with float inaccuracy */
 	if(panel->control & UI_PNL_CLOSE) pnl_icons=(panel->labelofs+2*PNL_ICON+5)/block->aspect + 0.001f;
 	else pnl_icons= (panel->labelofs+PNL_ICON+5)/block->aspect + 0.001f;

Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -349,7 +349,6 @@
 	ar->regiondata= NULL;
 }
 
-#define TIP_(msgid) UI_translate_do_tooltip(msgid)
 ARegion *ui_tooltip_create(bContext *C, ARegion *butregion, uiBut *but)
 {
 	uiStyle *style= UI_GetStyle();
@@ -410,7 +409,7 @@
 		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]), TIP_(N_("Shortcut: %s")), buf);
+			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Shortcut: %s"), buf);
 			data->color[data->totline]= 0x888888;
 			data->totline++;
 		}
@@ -420,7 +419,7 @@
 		/* full string */
 		ui_get_but_string(but, buf, sizeof(buf));
 		if(buf[0]) {
-			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_(N_("Value: %s")), buf);
+			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Value: %s"), buf);
 			data->color[data->totline]= 0x888888;
 			data->totline++;
 		}
@@ -432,7 +431,7 @@
 		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]), TIP_(N_("Radians: %f")), value);
+				BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Radians: %f"), value);
 				data->color[data->totline]= 0x888888;
 				data->totline++;
 			}
@@ -441,7 +440,7 @@
 		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]), TIP_(N_("Expression: %s")), buf);
+				BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Expression: %s"), buf);
 				data->color[data->totline]= 0x888888;
 				data->totline++;
 			}
@@ -449,7 +448,7 @@
 
 		/* rna info */
 		if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
-			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_(N_("Python: %s.%s")), RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
+			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s.%s"), RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
 			data->color[data->totline]= 0x888888;
 			data->totline++;
 		}
@@ -457,7 +456,7 @@
 		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]), TIP_(N_("Library: %s")), id->lib->name);
+				BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Library: %s"), id->lib->name);
 				data->color[data->totline]= 0x888888;
 				data->totline++;
 			}
@@ -472,7 +471,7 @@
 
 		/* operator info */
 		if ((U.flag & USER_TOOLTIPS_PYTHON) == 0) {
-			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_(N_("Python: %s")), str);
+			BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), str);
 			data->color[data->totline]= 0x888888;
 			data->totline++;
 		}
@@ -486,7 +485,7 @@
 			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]), TIP_(N_("Disabled: %s")), poll_msg);
+				BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Disabled: %s"), poll_msg);
 				data->color[data->totline]= 0x6666ff; /* alert */
 				data->totline++;			
 			}
@@ -496,7 +495,7 @@
 		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]), TIP_(N_("Python: %s")), mt->idname);
+				BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]), TIP_("Python: %s"), mt->idname);
 				data->color[data->totline]= 0x888888;
 				data->totline++;
 			}
@@ -615,7 +614,6 @@
 
 	return ar;
 }
-#undef TIP_
 
 void ui_tooltip_free(bContext *C, ARegion *ar)
 {

Modified: trunk/blender/source/blender/editors/interface/interface_templates.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_templates.c	2011-10-20 20:24:04 UTC (rev 41158)
+++ trunk/blender/source/blender/editors/interface/interface_templates.c	2011-10-20 20:38:26 UTC (rev 41159)
@@ -357,7 +357,7 @@
 	if(flag & UI_ID_PREVIEWS) {
 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list