diff options
author | Simon Schampijer <simon@schampijer.de> | 2010-09-29 14:15:59 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2010-09-29 14:15:59 (GMT) |
commit | 106b9fba686081bfa8c4d9b9d9d5fe78fa75dc1f (patch) | |
tree | cba367158814ff6c787d9aa23b905e460bbdeec3 /src/sugar/util.py | |
parent | 5326ebf53c476ff0749f7c47d8812c424c7d67c5 (diff) |
Do not break if the string contains no conversion specifier #2354
Diffstat (limited to 'src/sugar/util.py')
-rw-r--r-- | src/sugar/util.py | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/sugar/util.py b/src/sugar/util.py index b947c0a..3625f21 100644 --- a/src/sugar/util.py +++ b/src/sugar/util.py @@ -271,10 +271,17 @@ def timestamp_to_elapsed_string(timestamp, max_levels=2): if key in _i18n_timestamps_cache: time_period += _i18n_timestamps_cache[key] else: - translation = gettext.dngettext('sugar-toolkit', - name_singular, - name_plural, - elapsed_units) % elapsed_units + tmp = gettext.dngettext('sugar-toolkit', + name_singular, + name_plural, + elapsed_units) + # FIXME: This is a hack so we don't crash when a translation + # doesn't contain the expected number of placeholders (#2354) + try: + translation = tmp % elapsed_units + except TypeError: + translation = tmp + _i18n_timestamps_cache[key] = translation time_period += translation |