[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [54428] trunk/blender: Actually, UI scripts should not use directly pgettext, but rather the iface or tooltip variants.

Bastien Montagne montagne29 at wanadoo.fr
Sun Feb 10 11:29:39 CET 2013


Revision: 54428
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=54428
Author:   mont29
Date:     2013-02-10 10:29:38 +0000 (Sun, 10 Feb 2013)
Log Message:
-----------
Actually, UI scripts should not use directly pgettext, but rather the iface or tooltip variants. Added those to bpy.app.translations, and used pgettext_iface.

(Did not add those when I created that module, because I did not thought we would actually need them in usual UI code, but turned out I was wrong).

Also made some optimizations in those py gettext funcs, when i18n is disabled at build time, no need to do pyobject -> cstring -> pyobject conversions!.

Modified Paths:
--------------
    trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
    trunk/blender/release/scripts/startup/bl_ui/properties_material.py
    trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
    trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py
    trunk/blender/release/scripts/startup/bl_ui/space_clip.py
    trunk/blender/release/scripts/startup/bl_ui/space_image.py
    trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
    trunk/blender/release/scripts/startup/bl_ui/space_text.py
    trunk/blender/release/scripts/startup/bl_ui/space_userpref.py
    trunk/blender/release/scripts/startup/bl_ui/space_userpref_keymap.py
    trunk/blender/source/blender/python/intern/bpy_app_translations.c

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_data_modifier.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -19,10 +19,9 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Panel
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 class ModifierButtonsPanel():
     bl_space_type = 'PROPERTIES'
     bl_region_type = 'WINDOW'
@@ -267,7 +266,7 @@
             layout.prop(md, "angle_limit")
             layout.prop(md, "use_dissolve_boundaries")
 
-        layout.label(text=_("Face Count: %d") % md.face_count, translate=False)
+        layout.label(text=iface_("Face Count: %d") % md.face_count, translate=False)
 
     def DISPLACE(self, layout, ob, md):
         has_texture = (md.texture is not None)

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_material.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_material.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_material.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -20,10 +20,9 @@
 import bpy
 from bpy.types import Menu, Panel, UIList
 from rna_prop_ui import PropertyPanel
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 def active_node_mat(mat):
     # TODO, 2.4x has a pipeline section, for 2.5 we need to communicate
     # which settings from node-materials are used
@@ -82,7 +81,7 @@
             if ma and not context.scene.render.use_shading_nodes:
                 manode = ma.active_node_material
                 if manode:
-                    layout.label(text=_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode))
+                    layout.label(text=iface_("Node %s") % manode.name, translate=False, icon_value=layout.icon(manode))
                 elif ma.use_nodes:
                     layout.label(text="Node <none>")
                 else:

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_particle.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_particle.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -20,9 +20,8 @@
 import bpy
 from bpy.types import Panel
 from rna_prop_ui import PropertyPanel
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
-
 from bl_ui.properties_physics_common import (point_cache_ui,
                                              effector_weights_ui,
                                              basic_force_field_settings_ui,
@@ -150,7 +149,7 @@
             #row.label(text="Render")
 
             if part.is_fluid:
-                layout.label(text=_("%d fluid particles for this frame") % part.count, translate=False)
+                layout.label(text=iface_("%d fluid particles for this frame") % part.count, translate=False)
                 return
 
             row = col.row()

Modified: trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/properties_physics_fluid.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -19,10 +19,9 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Panel, Menu
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 class FLUID_MT_presets(Menu):
     bl_label = "Fluid Presets"
     preset_subdir = "fluid"
@@ -66,7 +65,7 @@
 
         if fluid.type == 'DOMAIN':
             # odd formatting here so translation script can extract string
-            layout.operator("fluid.bake", text=_("Bake (Req. Memory: %s)") % fluid.memory_estimate,
+            layout.operator("fluid.bake", text=iface_("Bake (Req. Memory: %s)") % fluid.memory_estimate,
                             translate=False, icon='MOD_FLUIDSIM')
             split = layout.split()
 

Modified: trunk/blender/release/scripts/startup/bl_ui/space_clip.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/space_clip.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -20,10 +20,9 @@
 
 import bpy
 from bpy.types import Panel, Header, Menu, UIList
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 class CLIP_UL_tracking_objects(UIList):
     def draw_item(self, context, layout, data, item, icon,
                   active_data, active_propname, index):
@@ -913,9 +912,11 @@
 
             ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
 
-            text = _("Zoom %d:%d")
+            text = iface_("Zoom %d:%d")
             for a, b in ratios:
-                layout.operator("clip.view_zoom_ratio", text=text % (a, b), translate=False).ratio = a / b
+                layout.operator("clip.view_zoom_ratio",
+                                text=text % (a, b),
+                                translate=False).ratio = a / b
         else:
             if sc.view == 'GRAPH':
                 layout.operator_context = 'INVOKE_REGION_PREVIEW'

Modified: trunk/blender/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_image.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/space_image.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -20,10 +20,9 @@
 import bpy
 from bpy.types import Header, Menu, Panel
 from bl_ui.properties_paint_common import UnifiedPaintPanel, brush_texture_settings
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 class ImagePaintPanel(UnifiedPaintPanel):
     bl_space_type = 'IMAGE_EDITOR'
     bl_region_type = 'UI'
@@ -73,7 +72,7 @@
         ratios = ((1, 8), (1, 4), (1, 2), (1, 1), (2, 1), (4, 1), (8, 1))
 
         for a, b in ratios:
-            layout.operator("image.view_zoom_ratio", text=_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
+            layout.operator("image.view_zoom_ratio", text=iface_("Zoom %d:%d") % (a, b), translate=False).ratio = a / b
 
         layout.separator()
 

Modified: trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/space_sequencer.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -19,10 +19,9 @@
 # <pep8 compliant>
 import bpy
 from bpy.types import Header, Menu, Panel
+from bpy.app.translations import pgettext_iface as iface_
 
-from bpy.app.translations import pgettext as _
 
-
 def act_strip(context):
     try:
         return context.scene.sequence_editor.active_strip
@@ -424,13 +423,15 @@
 
         col = layout.column(align=True)
         row = col.row()
-        row.label(text=_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration), translate=False)
+        row.label(text=iface_("Final Length: %s") % bpy.utils.smpte_from_frame(strip.frame_final_duration),
+                  translate=False)
         row = col.row()
         row.active = (frame_current >= strip.frame_start and frame_current <= strip.frame_start + strip.frame_duration)
-        row.label(text=_("Playhead: %d") % (frame_current - strip.frame_start), translate=False)
+        row.label(text=iface_("Playhead: %d") % (frame_current - strip.frame_start), translate=False)
 
-        col.label(text=_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end), translate=False)
-        col.label(text=_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False)
+        col.label(text=iface_("Frame Offset %d:%d") % (strip.frame_offset_start, strip.frame_offset_end),
+                  translate=False)
+        col.label(text=iface_("Frame Still %d:%d") % (strip.frame_still_start, strip.frame_still_end), translate=False)
 
         elem = False
 
@@ -440,7 +441,7 @@
             elem = strip.elements[0]
 
         if elem and elem.orig_width > 0 and elem.orig_height > 0:
-            col.label(text=_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False)
+            col.label(text=iface_("Original Dimension: %dx%d") % (elem.orig_width, elem.orig_height), translate=False)
         else:
             col.label(text="Original Dimension: None")
 
@@ -717,7 +718,7 @@
         if scene:
             sta = scene.frame_start
             end = scene.frame_end
-            layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
+            layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
 
 
 class SEQUENCER_PT_mask(SequencerButtonsPanel, Panel):
@@ -746,7 +747,7 @@
         if mask:
             sta = mask.frame_start
             end = mask.frame_end
-            layout.label(text=_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
+            layout.label(text=iface_("Original frame range: %d-%d (%d)") % (sta, end, end - sta + 1), translate=False)
 
 
 class SEQUENCER_PT_filter(SequencerButtonsPanel, Panel):

Modified: trunk/blender/release/scripts/startup/bl_ui/space_text.py
===================================================================
--- trunk/blender/release/scripts/startup/bl_ui/space_text.py	2013-02-10 10:17:59 UTC (rev 54427)
+++ trunk/blender/release/scripts/startup/bl_ui/space_text.py	2013-02-10 10:29:38 UTC (rev 54428)
@@ -19,10 +19,9 @@
 # <pep8-80 compliant>
 import bpy

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list