diff options
| author | Martin Trigaux <mat@odoo.com> | 2020-06-15 15:16:16 +0200 |
|---|---|---|
| committer | Martin Trigaux <mat@odoo.com> | 2020-06-18 13:03:34 +0200 |
| commit | 80e97e98ce76067db1079af8feeef667cfadf837 (patch) | |
| tree | e261d34e3f8458bd99011f60f508bcce2c723baf /addons/calendar | |
| parent | 4a92a183e8631512a8b018eedaf9bf4956ca85e9 (diff) | |
[IMP] *: use named placeholders in translated message
When more than one parameter is present in a message, it helps the
translation to use named placeholder. This way, the order can be
changed. It also helps the comprehension of the message.
Diffstat (limited to 'addons/calendar')
| -rw-r--r-- | addons/calendar/models/calendar_event.py | 38 | ||||
| -rw-r--r-- | addons/calendar/models/calendar_recurrence.py | 4 |
2 files changed, 26 insertions, 16 deletions
diff --git a/addons/calendar/models/calendar_event.py b/addons/calendar/models/calendar_event.py index df6347a678c..68740cae04d 100644 --- a/addons/calendar/models/calendar_event.py +++ b/addons/calendar/models/calendar_event.py @@ -135,25 +135,27 @@ class Meeting(models.Model): time_str = to_text(date.strftime(format_time)) if zallday: - display_time = _("AllDay , %s") % (date_str) + display_time = _("AllDay , %(day)s", day=date_str) elif zduration < 24: duration = date + timedelta(minutes=round(zduration*60)) duration_time = to_text(duration.strftime(format_time)) - display_time = _(u"%s at (%s To %s) (%s)") % ( - date_str, - time_str, - duration_time, - timezone, + display_time = _( + u"%(day)s at (%(start)s To %(end)s) (%(timezone)s)", + day=date_str, + start=time_str, + end=duration_time, + timezone=timezone, ) else: dd_date = to_text(date_deadline.strftime(format_date)) dd_time = to_text(date_deadline.strftime(format_time)) - display_time = _(u"%s at %s To\n %s at %s (%s)") % ( - date_str, - time_str, - dd_date, - dd_time, - timezone, + display_time = _( + u"%(date_start)s at %(time_start)s To\n %(date_end)s at %(time_end)s (%(timezone)s)", + date_start=date_str, + time_start=time_str, + date_end=dd_date, + time_end=dd_time, + timezone=timezone, ) return display_time @@ -356,12 +358,20 @@ class Meeting(models.Model): if meeting.start and meeting.stop and meeting.stop < meeting.start: raise ValidationError( _('The ending date and time cannot be earlier than the starting date and time.') + '\n' + - _("Meeting '%s' starts '%s' and ends '%s'") % (meeting.name, meeting.start, meeting.stop) + _("Meeting '%(name)s' starts '%(start_datetime)s' and ends '%(end_datetime)s'", + name=meeting.name, + start_datetime=meeting.start, + end_datetime=meeting.stop + ) ) if meeting.start_date and meeting.stop_date and meeting.stop_date < meeting.start_date: raise ValidationError( _('The ending date cannot be earlier than the starting date.') + '\n' + - _("Meeting '%s' starts '%s' and ends '%s'") % (meeting.name, meeting.start_date, meeting.stop_date) + _("Meeting '%(name)s' starts '%(start_datetime)s' and ends '%(end_datetime)s'", + name=meeting.name, + start_datetime=meeting.start, + end_datetime=meeting.stop + ) ) #################################################### diff --git a/addons/calendar/models/calendar_recurrence.py b/addons/calendar/models/calendar_recurrence.py index 73c671c611a..9dae012b6d4 100644 --- a/addons/calendar/models/calendar_recurrence.py +++ b/addons/calendar/models/calendar_recurrence.py @@ -124,7 +124,7 @@ class RecurrenceRule(models.Model): def _compute_name(self): for recurrence in self: period = dict(RRULE_TYPE_SELECTION)[recurrence.rrule_type] - every = _("Every %s %s, ") % (recurrence.interval, period) + every = _("Every %(count)s %(period)s, ", count=recurrence.interval, period=period) if recurrence.end_type == 'count': end = _("for %s events", recurrence.count) @@ -140,7 +140,7 @@ class RecurrenceRule(models.Model): elif recurrence.rrule_type == 'monthly': if recurrence.month_by == 'day': weekday_label = dict(BYDAY_SELECTION)[recurrence.byday] - on = _("on the %(position)s %(weekday)s, ") % {'position': recurrence.byday, 'weekday': weekday_label} + on = _("on the %(position)s %(weekday)s, ", position=recurrence.byday, weekday=weekday_label) else: on = _("day %s, ", recurrence.day) else: |
