Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/rpms/sugar-toolkit/sugar-toolkit-2-4-Do-not-break-if-the-string-contains-no-conversion-specifier-2354.patch
blob: 6a2545a355045cca5c7166edc21e760194902c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From patchwork Sat Jan 15 17:07:17 2011
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: [sugar-toolkit,
	2/4] Do not break if the string contains no conversion specifier #2354
Date: Sat, 15 Jan 2011 22:07:17 -0000
From: Aleksey Lim <alsroot@member.fsf.org>
X-Patchwork-Id: 574
Message-Id: <1295111239-22177-3-git-send-email-alsroot@member.fsf.org>
To: dextrose@lists.sugarlabs.org

From: Simon Schampijer <simon@schampijer.de>

---
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