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
=== modified file 'softwarecenter/backend/reviews/__init__.py'
--- softwarecenter/backend/reviews/__init__.py 2012-03-16 19:16:21 +0000
+++ softwarecenter/backend/reviews/__init__.py 2012-04-12 14:28:24 +0000
@@ -43,7 +43,7 @@
43from softwarecenter.db.categories import get_query_for_category43from softwarecenter.db.categories import get_query_for_category
44from softwarecenter.db.database import Application, StoreDatabase44from softwarecenter.db.database import Application, StoreDatabase
45import softwarecenter.distro45import softwarecenter.distro
46from softwarecenter.i18n import get_language46from softwarecenter.i18n import get_languages
47from softwarecenter.utils import (upstream_version_compare,47from softwarecenter.utils import (upstream_version_compare,
48 uri_to_filename,48 uri_to_filename,
49 get_person_from_config,49 get_person_from_config,
@@ -254,7 +254,7 @@
254 bdb.DB_VERSION_MAJOR,254 bdb.DB_VERSION_MAJOR,
255 bdb.DB_VERSION_MINOR)255 bdb.DB_VERSION_MINOR)
256256
257 self.language = get_language()257 self.language = get_languages()[0]
258 if os.path.exists(self.REVIEW_STATS_CACHE_FILE):258 if os.path.exists(self.REVIEW_STATS_CACHE_FILE):
259 try:259 try:
260 self.REVIEW_STATS_CACHE = pickle.load(260 self.REVIEW_STATS_CACHE = pickle.load(
261261
=== modified file 'softwarecenter/i18n.py'
--- softwarecenter/i18n.py 2012-03-15 10:43:13 +0000
+++ softwarecenter/i18n.py 2012-04-12 14:28:24 +0000
@@ -48,9 +48,11 @@
48 for lang in langs[:]:48 for lang in langs[:]:
49 if "_" in lang and not lang in FULL:49 if "_" in lang and not lang in FULL:
50 langs.remove(lang)50 langs.remove(lang)
51 # fallback51 # ensure the data from get_language() part of the result too
52 if not langs:52 # (see LP: #979013)
53 return [get_language()]53 from_get_language = get_language()
54 if not from_get_language in langs:
55 langs.insert(0, from_get_language)
54 return langs56 return langs
5557
5658
5759
=== modified file 'test/test_i18n.py'
--- test/test_i18n.py 2012-02-02 10:20:17 +0000
+++ test/test_i18n.py 2012-04-12 14:28:24 +0000
@@ -42,6 +42,10 @@
42 # falls back to english42 # falls back to english
43 os.environ["LANGUAGE"] = "yxy_YYY"43 os.environ["LANGUAGE"] = "yxy_YYY"
44 self.assertEqual(get_languages(), ["en"])44 self.assertEqual(get_languages(), ["en"])
45 os.environ["LANGUAGE"] = "es_MX:es_ES:es_AR:es_ES:en"
46 os.environ["LANG"] = "es_MX.UTF-8"
47 self.assertEqual(get_languages(), ["es", "en"])
48
4549
46 def test_init_locale(self):50 def test_init_locale(self):
47 import locale51 import locale

Subscribers

People subscribed via source and target branches