Merge lp:~mvo/software-center/lp979013 into lp:software-center

Proposed by Michael Vogt on 2012-04-12
Status: Merged
Merged at revision: 2968
Proposed branch: lp:~mvo/software-center/lp979013
Merge into: lp:software-center
Diff against target: 55 lines (+11/-5)
3 files modified
softwarecenter/backend/reviews/__init__.py (+2/-2)
softwarecenter/i18n.py (+5/-3)
test/test_i18n.py (+4/-0)
To merge this branch: bzr merge lp:~mvo/software-center/lp979013
Reviewer Review Type Date Requested Status
Gary Lasker (community) 2012-04-12 Approve on 2012-04-13
Review via email: mp+101743@code.launchpad.net

Description of the change

This branch fixes the bug in the review display for the language environment:
LANGUAGE=es_MX:es_ES:es_AR:es_ES:en
(and similar environments that have only language_REGION and a generic fallback in the LANGUAGE environment).

To test:
$ LANGUAGE=es_MX:es_ES:es_AR:es_ES:en ./software-center gparted
and verify that the reviews loaded are in spanish, that the review language combobox says "espanol" instead of "ingles".

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

Very clever fix. :) Thanks for the test case above, and for the updated unit test!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'softwarecenter/backend/reviews/__init__.py'
2--- softwarecenter/backend/reviews/__init__.py 2012-03-16 19:16:21 +0000
3+++ softwarecenter/backend/reviews/__init__.py 2012-04-12 14:28:24 +0000
4@@ -43,7 +43,7 @@
5 from softwarecenter.db.categories import get_query_for_category
6 from softwarecenter.db.database import Application, StoreDatabase
7 import softwarecenter.distro
8-from softwarecenter.i18n import get_language
9+from softwarecenter.i18n import get_languages
10 from softwarecenter.utils import (upstream_version_compare,
11 uri_to_filename,
12 get_person_from_config,
13@@ -254,7 +254,7 @@
14 bdb.DB_VERSION_MAJOR,
15 bdb.DB_VERSION_MINOR)
16
17- self.language = get_language()
18+ self.language = get_languages()[0]
19 if os.path.exists(self.REVIEW_STATS_CACHE_FILE):
20 try:
21 self.REVIEW_STATS_CACHE = pickle.load(
22
23=== modified file 'softwarecenter/i18n.py'
24--- softwarecenter/i18n.py 2012-03-15 10:43:13 +0000
25+++ softwarecenter/i18n.py 2012-04-12 14:28:24 +0000
26@@ -48,9 +48,11 @@
27 for lang in langs[:]:
28 if "_" in lang and not lang in FULL:
29 langs.remove(lang)
30- # fallback
31- if not langs:
32- return [get_language()]
33+ # ensure the data from get_language() part of the result too
34+ # (see LP: #979013)
35+ from_get_language = get_language()
36+ if not from_get_language in langs:
37+ langs.insert(0, from_get_language)
38 return langs
39
40
41
42=== modified file 'test/test_i18n.py'
43--- test/test_i18n.py 2012-02-02 10:20:17 +0000
44+++ test/test_i18n.py 2012-04-12 14:28:24 +0000
45@@ -42,6 +42,10 @@
46 # falls back to english
47 os.environ["LANGUAGE"] = "yxy_YYY"
48 self.assertEqual(get_languages(), ["en"])
49+ os.environ["LANGUAGE"] = "es_MX:es_ES:es_AR:es_ES:en"
50+ os.environ["LANG"] = "es_MX.UTF-8"
51+ self.assertEqual(get_languages(), ["es", "en"])
52+
53
54 def test_init_locale(self):
55 import locale

Subscribers

People subscribed via source and target branches