Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(539)

Side by Side Diff: chrome/browser/language_combobox_model.cc

Issue 5154009: Cleanup AdjustStringForLocaleDirection() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: further fixes Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/language_combobox_model.h" 5 #include "chrome/browser/language_combobox_model.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/string_split.h" 9 #include "base/string_split.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 DCHECK(it != native_names_.end()); 83 DCHECK(it != native_names_.end());
84 84
85 // If the name is the same in the native language and local language, 85 // If the name is the same in the native language and local language,
86 // don't show it twice. 86 // don't show it twice.
87 if (it->second.native_name == locale_names_[index]) 87 if (it->second.native_name == locale_names_[index])
88 return it->second.native_name; 88 return it->second.native_name;
89 89
90 // We must add directionality formatting to both the native name and the 90 // We must add directionality formatting to both the native name and the
91 // locale name in order to avoid text rendering problems such as misplaced 91 // locale name in order to avoid text rendering problems such as misplaced
92 // parentheses or languages appearing in the wrong order. 92 // parentheses or languages appearing in the wrong order.
93 std::wstring locale_name_localized; 93 std::wstring locale_name_localized;
Avi (use Gerrit) 2010/11/23 16:07:08 This string is no longer needed. Delete.
94 std::wstring locale_name; 94 std::wstring locale_name = locale_names_[index];
95 if (base::i18n::AdjustStringForLocaleDirection(locale_names_[index], 95 base::i18n::AdjustStringForLocaleDirection(&locale_name);
96 &locale_name_localized))
97 locale_name.assign(locale_name_localized);
98 else
99 locale_name.assign(locale_names_[index]);
100 96
101 std::wstring native_name_localized; 97 std::wstring native_name = it->second.native_name;
102 std::wstring native_name; 98 base::i18n::AdjustStringForLocaleDirection(&native_name);
103 if (base::i18n::AdjustStringForLocaleDirection(it->second.native_name,
104 &native_name_localized))
105 native_name.assign(native_name_localized);
106 else
107 native_name.assign(it->second.native_name);
108 99
109 // We used to have a localizable template here, but none of translators 100 // We used to have a localizable template here, but none of translators
110 // changed the format. We also want to switch the order of locale_name 101 // changed the format. We also want to switch the order of locale_name
111 // and native_name without going back to translators. 102 // and native_name without going back to translators.
112 std::wstring formatted_item; 103 std::wstring formatted_item;
113 base::SStringPrintf(&formatted_item, L"%ls - %ls", locale_name.c_str(), 104 base::SStringPrintf(&formatted_item, L"%ls - %ls", locale_name.c_str(),
114 native_name.c_str()); 105 native_name.c_str());
115 if (base::i18n::IsRTL()) 106 if (base::i18n::IsRTL())
116 // Somehow combo box (even with LAYOUTRTL flag) doesn't get this 107 // Somehow combo box (even with LAYOUTRTL flag) doesn't get this
117 // right so we add RTL BDO (U+202E) to set the direction 108 // right so we add RTL BDO (U+202E) to set the direction
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 if (!profile_) 168 if (!profile_)
178 local_state = g_browser_process->local_state(); 169 local_state = g_browser_process->local_state();
179 else 170 else
180 local_state = profile_->GetPrefs(); 171 local_state = profile_->GetPrefs();
181 172
182 DCHECK(local_state); 173 DCHECK(local_state);
183 const std::string& current_locale = local_state->GetString(prefs.c_str()); 174 const std::string& current_locale = local_state->GetString(prefs.c_str());
184 175
185 return GetIndexFromLocale(current_locale); 176 return GetIndexFromLocale(current_locale);
186 } 177 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698