Merge lp:~mvo/software-center/lp872760-for-5.2 into lp:software-center/5.2

Proposed by Michael Vogt
Status: Merged
Merged at revision: 3022
Proposed branch: lp:~mvo/software-center/lp872760-for-5.2
Merge into: lp:software-center/5.2
Diff against target: 81 lines (+28/-5)
3 files modified
softwarecenter/db/categories.py (+1/-1)
softwarecenter/ui/gtk3/models/appstore2.py (+10/-2)
test/gtk3/test_appstore2.py (+17/-2)
To merge this branch: bzr merge lp:~mvo/software-center/lp872760-for-5.2
Reviewer Review Type Date Requested Status
Gary Lasker (community) Approve
Review via email: mp+105454@code.launchpad.net

Description of the change

This is a fix based on the nice work of Robert Roth for bug #872760 that does not need a string change.
It also adds a regression test.

To post a comment you must log in.
Gary Lasker (gary-lasker) wrote :

This looks good. Cool unit test. Thanks, mvo!

review: Approve
Gary Lasker (gary-lasker) wrote :

Merged into the 5.2 branch with a couple of minor pyflakes fixes and I removed a leftover print from the unit test. Thanks again Michael!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/db/categories.py'
2--- softwarecenter/db/categories.py 2012-03-20 10:28:51 +0000
3+++ softwarecenter/db/categories.py 2012-05-11 08:55:22 +0000
4@@ -532,7 +532,7 @@
5 'SportsGame': 'Games;Sports',
6 '3DGraphics': 'Graphics;3D Graphics',
7 'VectorGraphics': 'Graphics;Drawing',
8-'RasterGraphics': 'Graphics;Painting',
9+'RasterGraphics': 'Graphics;Painting & Editing',
10 'Photography': 'Graphics;Photography',
11 'Publishing': 'Graphics;Publishing',
12 'Scanning': 'Graphics;Scanning & OCR',
13
14=== modified file 'softwarecenter/ui/gtk3/models/appstore2.py'
15--- softwarecenter/ui/gtk3/models/appstore2.py 2012-05-01 00:18:23 +0000
16+++ softwarecenter/ui/gtk3/models/appstore2.py 2012-05-11 08:55:22 +0000
17@@ -33,6 +33,7 @@
18 SimpleFileDownloader,
19 split_icon_ext,
20 utf8,
21+ unescape,
22 )
23 from softwarecenter.backend import get_install_backend
24 from softwarecenter.backend.reviews import get_review_loader
25@@ -248,8 +249,15 @@
26 for cat in self.all_categories:
27 if cat.untranslated_name == catname:
28 return cat.name
29- # else just use plain gettext
30- return _(catname)
31+ # try normal translation first
32+ translated_catname = _(catname)
33+ if translated_catname == catname:
34+ # if no normal translation is found, try to find a escaped
35+ # translation (LP: #872760)
36+ translated_catname = _(GObject.markup_escape_text(catname))
37+ # the parent expect the string unescaped
38+ translated_catname = unescape(translated_catname)
39+ return translated_catname
40
41 def get_categories(self, doc):
42 categories = doc.get_value(XapianValues.CATEGORIES).split(';') or []
43
44=== modified file 'test/gtk3/test_appstore2.py'
45--- test/gtk3/test_appstore2.py 2012-01-16 14:42:49 +0000
46+++ test/gtk3/test_appstore2.py 2012-05-11 08:55:22 +0000
47@@ -1,10 +1,11 @@
48 #!/usr/bin/python
49
50+import os
51 import unittest
52 import xapian
53
54-from gi.repository import Gtk
55-
56+from gi.repository import Gtk, GObject
57+from mock import patch
58
59 from testutils import setup_test_env
60 setup_test_env()
61@@ -24,6 +25,20 @@
62 self.icons = get_test_gtk3_icon_cache()
63 self.db = get_test_db()
64
65+ def test_lp872760(self):
66+ def monkey_(s):
67+ translations = {
68+ "Painting & Editing" : "translation for Painting & "
69+ "Editing",
70+ }
71+ return translations.get(s, s)
72+ with patch("softwarecenter.ui.gtk3.models.appstore2._", new=monkey_):
73+ model = AppListStore(self.db, self.cache, self.icons)
74+ untranslated = "Painting & Editing"
75+ translated = model._category_translate(untranslated)
76+ print translated
77+ self.assertNotEqual(untranslated, translated)
78+
79 def test_app_store(self):
80 # get a enquire object
81 enquirer = AppEnquire(self.cache, self.db)

Subscribers

People subscribed via source and target branches