Official add-ons: fix printf-style format translation for i18n
Following up to D15615, I noticed that many messages are either properly extracted, but not translated due to the use of printf-style formatting in strings, or not extracted at all. Using the pgettext function explicitly before formatting fixes that. Since the affected messages are already extracted, no additional work is needed from translators. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D16373
This commit is contained in:
parent
61ff4faf8c
commit
27ee432965
|
@ -20,6 +20,7 @@ import typing
|
|||
import bpy
|
||||
from bpy.types import AddonPreferences, Operator, PropertyGroup
|
||||
from bpy.props import PointerProperty, StringProperty
|
||||
from bpy.app.translations import pgettext_tip as tip_
|
||||
|
||||
if 'communication' in locals():
|
||||
import importlib
|
||||
|
@ -209,29 +210,29 @@ class BlenderIdPreferences(AddonPreferences):
|
|||
else:
|
||||
time_left = expiry - now
|
||||
if time_left.days > 14:
|
||||
exp_str = 'on {:%Y-%m-%d}'.format(expiry)
|
||||
exp_str = tip_('on {:%Y-%m-%d}').format(expiry)
|
||||
elif time_left.days > 1:
|
||||
exp_str = 'in %i days.' % time_left.days
|
||||
exp_str = tip_('in %i days.') % time_left.days
|
||||
elif time_left.seconds >= 7200:
|
||||
exp_str = 'in %i hours.' % round(time_left.seconds / 3600)
|
||||
exp_str = tip_('in %i hours.') % round(time_left.seconds / 3600)
|
||||
elif time_left.seconds >= 120:
|
||||
exp_str = 'in %i minutes.' % round(time_left.seconds / 60)
|
||||
exp_str = tip_('in %i minutes.') % round(time_left.seconds / 60)
|
||||
else:
|
||||
exp_str = 'within seconds'
|
||||
exp_str = tip_('within seconds')
|
||||
|
||||
endpoint = communication.blender_id_endpoint()
|
||||
if endpoint == communication.BLENDER_ID_ENDPOINT:
|
||||
msg = 'You are logged in as %s.' % active_profile.username
|
||||
msg = tip_('You are logged in as %s.') % active_profile.username
|
||||
else:
|
||||
msg = 'You are logged in as %s at %s.' % (active_profile.username, endpoint)
|
||||
msg = tip_('You are logged in as %s at %s.') % (active_profile.username, endpoint)
|
||||
|
||||
col = layout.column(align=True)
|
||||
col.label(text=msg, icon='WORLD_DATA')
|
||||
if time_left.days < 14:
|
||||
col.label(text='Your token will expire %s. Please log out and log in again '
|
||||
'to refresh it.' % exp_str, icon='PREVIEW_RANGE')
|
||||
col.label(text=tip_('Your token will expire %s. Please log out and log in again '
|
||||
'to refresh it.') % exp_str, icon='PREVIEW_RANGE')
|
||||
else:
|
||||
col.label(text='Your authentication token expires %s.' % exp_str,
|
||||
col.label(text=tip_('Your authentication token expires %s.') % exp_str,
|
||||
icon='BLANK1')
|
||||
|
||||
row = layout.row().split(factor=0.8)
|
||||
|
@ -286,7 +287,7 @@ class BlenderIdLogin(BlenderIdMixin, Operator):
|
|||
addon_prefs.blender_id_username,
|
||||
{}
|
||||
)
|
||||
addon_prefs.ok_message = 'Logged in'
|
||||
addon_prefs.ok_message = tip_('Logged in')
|
||||
else:
|
||||
addon_prefs.error_message = auth_result.error_message
|
||||
if BlenderIdProfile.user_id:
|
||||
|
@ -306,9 +307,9 @@ class BlenderIdValidate(BlenderIdMixin, Operator):
|
|||
|
||||
err = validate_token()
|
||||
if err is None:
|
||||
addon_prefs.ok_message = 'Authentication token is valid.'
|
||||
addon_prefs.ok_message = tip_('Authentication token is valid.')
|
||||
else:
|
||||
addon_prefs.error_message = '%s; you probably want to log out and log in again.' % err
|
||||
addon_prefs.error_message = tip_('%s; you probably want to log out and log in again.') % err
|
||||
|
||||
BlenderIdProfile.read_json()
|
||||
|
||||
|
@ -328,7 +329,7 @@ class BlenderIdLogout(BlenderIdMixin, Operator):
|
|||
profiles.logout(BlenderIdProfile.user_id)
|
||||
BlenderIdProfile.read_json()
|
||||
|
||||
addon_prefs.ok_message = 'You have been logged out.'
|
||||
addon_prefs.ok_message = tip_('You have been logged out.')
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
from math import radians, ceil
|
||||
|
||||
import bpy
|
||||
from bpy.app.translations import pgettext_tip as tip_
|
||||
from mathutils import Vector, Euler, Matrix
|
||||
|
||||
|
||||
|
@ -714,7 +715,7 @@ def load(
|
|||
)
|
||||
|
||||
else:
|
||||
report({'ERROR'}, "Invalid target %r (must be 'ARMATURE' or 'OBJECT')" % target)
|
||||
report({'ERROR'}, tip_("Invalid target %r (must be 'ARMATURE' or 'OBJECT')") % target)
|
||||
return {'CANCELLED'}
|
||||
|
||||
print('Done in %.4f\n' % (time.time() - t1))
|
||||
|
|
|
@ -6,6 +6,7 @@ from math import cos, sin, tan, atan2, pi, ceil
|
|||
|
||||
import bpy
|
||||
from mathutils import Vector, Matrix
|
||||
from bpy.app.translations import pgettext_tip as tip_
|
||||
|
||||
from . import svg_colors
|
||||
from .svg_util import (units,
|
||||
|
@ -1892,7 +1893,7 @@ def load(operator, context, filepath=""):
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
operator.report({'WARNING'}, "Unable to parse XML, %s:%s for file %r" % (type(e).__name__, e, filepath))
|
||||
operator.report({'WARNING'}, tip_("Unable to parse XML, %s:%s for file %r") % (type(e).__name__, e, filepath))
|
||||
return {'CANCELLED'}
|
||||
|
||||
return {'FINISHED'}
|
||||
|
|
|
@ -23,6 +23,7 @@ from math import pi
|
|||
|
||||
import bpy
|
||||
from bpy.types import Operator
|
||||
from bpy.app.translations import pgettext_tip as tip_
|
||||
from mathutils import Vector
|
||||
|
||||
from bpy.props import (
|
||||
|
@ -833,7 +834,7 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
|
|||
|
||||
engine = context.scene.render.engine
|
||||
if engine not in ('CYCLES', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'):
|
||||
box.label(text="%s is not supported" % engine, icon='ERROR')
|
||||
box.label(text=tip_("%s is not supported") % engine, icon='ERROR')
|
||||
|
||||
box.prop(self, "overwrite_material")
|
||||
layout = self.layout
|
||||
|
@ -900,11 +901,11 @@ class IMPORT_IMAGE_OT_to_plane(Operator, AddObjectHelper):
|
|||
engine = context.scene.render.engine
|
||||
if engine not in {'CYCLES', 'BLENDER_EEVEE'}:
|
||||
if engine != 'BLENDER_WORKBENCH':
|
||||
self.report({'ERROR'}, "Cannot generate materials for unknown %s render engine" % engine)
|
||||
self.report({'ERROR'}, tip_("Cannot generate materials for unknown %s render engine") % engine)
|
||||
return {'CANCELLED'}
|
||||
else:
|
||||
self.report({'WARNING'},
|
||||
"Generating Cycles/EEVEE compatible material, but won't be visible with %s engine" % engine)
|
||||
tip_("Generating Cycles/EEVEE compatible material, but won't be visible with %s engine") % engine)
|
||||
|
||||
# Open file browser
|
||||
context.window_manager.fileselect_add(self)
|
||||
|
|
|
@ -23,6 +23,7 @@ if "bpy" in locals():
|
|||
import bpy
|
||||
import bpy_extras
|
||||
from bpy_extras import node_shader_utils
|
||||
from bpy.app.translations import pgettext_tip as tip_
|
||||
from mathutils import Vector, Matrix
|
||||
|
||||
from . import encode_bin, data_types, fbx_utils
|
||||
|
@ -1067,8 +1068,8 @@ def fbx_data_mesh_elements(root, me_obj, scene_data, done_meshes):
|
|||
del t_lt
|
||||
scene_data.settings.report(
|
||||
{'WARNING'},
|
||||
"Mesh '%s' has polygons with more than 4 vertices, "
|
||||
"cannot compute/export tangent space for it" % me.name)
|
||||
tip_("Mesh '%s' has polygons with more than 4 vertices, "
|
||||
"cannot compute/export tangent space for it") % me.name)
|
||||
else:
|
||||
del t_lt
|
||||
t_ln = array.array(data_types.ARRAY_FLOAT64, (0.0,)) * len(me.loops) * 3
|
||||
|
|
|
@ -2404,7 +2404,7 @@ def load(operator, context, filepath="",
|
|||
is_ascii = False
|
||||
|
||||
if is_ascii:
|
||||
operator.report({'ERROR'}, "ASCII FBX files are not supported %r" % filepath)
|
||||
operator.report({'ERROR'}, tip_("ASCII FBX files are not supported %r") % filepath)
|
||||
return {'CANCELLED'}
|
||||
del is_ascii
|
||||
# End ascii detection.
|
||||
|
@ -2415,11 +2415,11 @@ def load(operator, context, filepath="",
|
|||
import traceback
|
||||
traceback.print_exc()
|
||||
|
||||
operator.report({'ERROR'}, "Couldn't open file %r (%s)" % (filepath, e))
|
||||
operator.report({'ERROR'}, tip_("Couldn't open file %r (%s)") % (filepath, e))
|
||||
return {'CANCELLED'}
|
||||
|
||||
if version < 7100:
|
||||
operator.report({'ERROR'}, "Version %r unsupported, must be %r or later" % (version, 7100))
|
||||
operator.report({'ERROR'}, tip_("Version %r unsupported, must be %r or later") % (version, 7100))
|
||||
return {'CANCELLED'}
|
||||
|
||||
print("FBX version: %r" % version)
|
||||
|
@ -2454,7 +2454,7 @@ def load(operator, context, filepath="",
|
|||
fbx_settings = elem_find_first(elem_root, b'GlobalSettings')
|
||||
fbx_settings_props = elem_find_first(fbx_settings, b'Properties70')
|
||||
if fbx_settings is None or fbx_settings_props is None:
|
||||
operator.report({'ERROR'}, "No 'GlobalSettings' found in file %r" % filepath)
|
||||
operator.report({'ERROR'}, tip_("No 'GlobalSettings' found in file %r") % filepath)
|
||||
return {'CANCELLED'}
|
||||
|
||||
# FBX default base unit seems to be the centimeter, while raw Blender Unit is equivalent to the meter...
|
||||
|
@ -2521,10 +2521,10 @@ def load(operator, context, filepath="",
|
|||
fbx_connections = elem_find_first(elem_root, b'Connections')
|
||||
|
||||
if fbx_nodes is None:
|
||||
operator.report({'ERROR'}, "No 'Objects' found in file %r" % filepath)
|
||||
operator.report({'ERROR'}, tip_("No 'Objects' found in file %r") % filepath)
|
||||
return {'CANCELLED'}
|
||||
if fbx_connections is None:
|
||||
operator.report({'ERROR'}, "No 'Connections' found in file %r" % filepath)
|
||||
operator.report({'ERROR'}, tip_("No 'Connections' found in file %r") % filepath)
|
||||
return {'CANCELLED'}
|
||||
|
||||
# ----
|
||||
|
|
Loading…
Reference in New Issue