summaryrefslogtreecommitdiffstats
path: root/chrome/common/l10n_util.cc
diff options
context:
space:
mode:
authorfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 17:16:26 +0000
committerfinnur@google.com <finnur@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-31 17:16:26 +0000
commit45003a76537ada4d727e0b33f28961a72938c9e7 (patch)
tree93d62dd7633fe2165d65c0548c8bcde2006b35db /chrome/common/l10n_util.cc
parent153d44b69e23ac6e1ca2efa64ef5544f08cb8c71 (diff)
downloadchromium_src-45003a76537ada4d727e0b33f28961a72938c9e7.zip
chromium_src-45003a76537ada4d727e0b33f28961a72938c9e7.tar.gz
chromium_src-45003a76537ada4d727e0b33f28961a72938c9e7.tar.bz2
Fix RTL issues in the About box (bug 3756).
I used the BiDiLineIterator, which I moved out of the AutocompletePopup and into the l10n_util file. I also added a wrapper function around ubidi_getLogicalRun. Review URL: http://codereview.chromium.org/8727 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4294 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common/l10n_util.cc')
-rw-r--r--chrome/common/l10n_util.cc47
1 files changed, 45 insertions, 2 deletions
diff --git a/chrome/common/l10n_util.cc b/chrome/common/l10n_util.cc
index 5c6e74b..199d937 100644
--- a/chrome/common/l10n_util.cc
+++ b/chrome/common/l10n_util.cc
@@ -125,7 +125,7 @@ bool IsDuplicateName(const std::string& locale_name) {
// Skip all 'es_RR'. Currently, we use 'es' for es-ES (Spanish in Spain).
// 'es-419' (Spanish in Latin America) is not available in ICU so that it
// has to be added manually in GetAvailableLocales().
- if (LowerCaseEqualsASCII(locale_name.substr(0,3), "es_"))
+ if (LowerCaseEqualsASCII(locale_name.substr(0, 3), "es_"))
return true;
for (int i = 0; i < arraysize(kDuplicateNames); ++i) {
if (_stricmp(kDuplicateNames[i], locale_name.c_str()) == 0)
@@ -185,7 +185,7 @@ bool CheckAndResolveLocale(const std::wstring& locale,
}
// Google updater uses no, iw and en for our nb, he, and en-US.
- // We need to map them to our codes.
+ // We need to map them to our codes.
struct {
const char* source;
const wchar_t* dest;} alias_map[] = {
@@ -572,5 +572,48 @@ const std::vector<std::wstring>& GetAvailableLocales() {
return locales;
}
+BiDiLineIterator::~BiDiLineIterator() {
+ if (bidi_) {
+ ubidi_close(bidi_);
+ bidi_ = NULL;
+ }
}
+UBool BiDiLineIterator::Open(const std::wstring& text,
+ bool right_to_left,
+ bool url) {
+ DCHECK(bidi_ == NULL);
+ UErrorCode error = U_ZERO_ERROR;
+ bidi_ = ubidi_openSized(static_cast<int>(text.length()), 0, &error);
+ if (U_FAILURE(error))
+ return false;
+ if (right_to_left && url)
+ ubidi_setReorderingMode(bidi_, UBIDI_REORDER_RUNS_ONLY);
+ ubidi_setPara(bidi_, text.data(), static_cast<int>(text.length()),
+ right_to_left ? UBIDI_DEFAULT_RTL : UBIDI_DEFAULT_LTR,
+ NULL, &error);
+ return U_SUCCESS(error);
+}
+
+int BiDiLineIterator::CountRuns() {
+ DCHECK(bidi_ != NULL);
+ UErrorCode error = U_ZERO_ERROR;
+ const int runs = ubidi_countRuns(bidi_, &error);
+ return U_SUCCESS(error) ? runs : 0;
+}
+
+UBiDiDirection BiDiLineIterator::GetVisualRun(int index,
+ int* start,
+ int* length) {
+ DCHECK(bidi_ != NULL);
+ return ubidi_getVisualRun(bidi_, index, start, length);
+}
+
+void BiDiLineIterator::GetLogicalRun(int start,
+ int* end,
+ UBiDiLevel* level) {
+ DCHECK(bidi_ != NULL);
+ ubidi_getLogicalRun(bidi_, start, end, level);
+}
+
+}