Merge lp:~attente/ubuntu-system-settings/lp1236772 into lp:ubuntu-system-settings

Proposed by William Hua
Status: Merged
Approved by: Łukasz Zemczak
Approved revision: 467
Merged at revision: 468
Proposed branch: lp:~attente/ubuntu-system-settings/lp1236772
Merge into: lp:ubuntu-system-settings
Diff against target: 58 lines (+12/-9)
1 file modified
plugins/language/language-plugin.cpp (+12/-9)
To merge this branch: bzr merge lp:~attente/ubuntu-system-settings/lp1236772
Reviewer Review Type Date Requested Status
Łukasz Zemczak Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+191659@code.launchpad.net

Commit message

Update formats locale too. (LP: #1236772)

Description of the change

Update formats locale too. (LP: #1236772)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Łukasz Zemczak (sil2100) wrote :

The change looks nice, I see the values changing on the system as mentioned in specs and bug #1236772. I'm not sure if this merge is good for the later refactoring that has been done here, but those changes make sense in overall. So if no one minds, I'm approving this one.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/language/language-plugin.cpp'
2--- plugins/language/language-plugin.cpp 2013-10-16 23:17:30 +0000
3+++ plugins/language/language-plugin.cpp 2013-10-17 14:56:44 +0000
4@@ -158,7 +158,9 @@
5 }
6
7 if (m_nextCurrentLanguage != m_currentLanguage) {
8- act_user_set_language(user, qPrintable(languageCodes()[m_nextCurrentLanguage]));
9+ QString languageCode(languageCodes()[m_nextCurrentLanguage]);
10+ act_user_set_language(user, qPrintable(languageCode.left(languageCode.indexOf('.'))));
11+ act_user_set_formats_locale(user, qPrintable(languageCode));
12 m_currentLanguage = m_nextCurrentLanguage;
13 Q_EMIT currentLanguageChanged();
14 }
15@@ -442,10 +444,10 @@
16
17 QString localeOutput(localeProcess.readAllStandardOutput());
18 QStringList localeNames(localeOutput.split(QRegExp("\\s+")));
19- QSet<QString> languageNames;
20+ QHash<QString, QString> nameCodes;
21
22 for (QStringList::const_iterator i(localeNames.begin()); i != localeNames.end(); ++i) {
23- QString localeName(i->left(i->indexOf('.')));
24+ QString localeName(i->left(i->indexOf('.')).trimmed());
25 QLocale locale(localeName);
26 QString languageName(locale.nativeLanguageName().trimmed().toCaseFolded());
27
28@@ -454,14 +456,14 @@
29 QString genericName(genericLocale.nativeLanguageName().trimmed().toCaseFolded());
30
31 if (genericName == languageName) {
32- if (!languageNames.contains(genericName)) {
33+ if (!nameCodes.contains(genericName)) {
34 *m_languageLocales += genericLocale;
35- languageNames += genericName;
36+ nameCodes.insert(genericName, i->trimmed());
37 }
38 } else {
39- if (!languageNames.contains(languageName)) {
40+ if (!nameCodes.contains(languageName)) {
41 *m_languageLocales += locale;
42- languageNames += languageName;
43+ nameCodes.insert(languageName, i->trimmed());
44 }
45 }
46 }
47@@ -471,9 +473,10 @@
48
49 for (int i(0); i < m_languageLocales->length(); i++) {
50 *m_languageNames += (*m_languageLocales)[i].nativeLanguageName().trimmed();
51- *m_languageCodes += (*m_languageLocales)[i].name().trimmed();
52+ *m_languageCodes += nameCodes[(*m_languageNames)[i].toCaseFolded()];
53 (*m_nameIndices)[(*m_languageNames)[i]] = i;
54- (*m_codeIndices)[(*m_languageCodes)[i]] = i;
55+ QString languageCode((*m_languageCodes)[i]);
56+ (*m_codeIndices)[languageCode.left(languageCode.indexOf('.'))] = i;
57 }
58 }
59

Subscribers

People subscribed via source and target branches