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

Side by Side Diff: chrome/common/l10n_util.cc

Issue 18863: Review request: fix issue 6099 -- bad display of multi-line English message in pop ups (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months 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
« no previous file with comments | « chrome/common/l10n_util.h ('k') | chrome/common/l10n_util_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #include "chrome/common/l10n_util.h" 7 #include "chrome/common/l10n_util.h"
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 // Check only for Arabic and Hebrew languages now. 495 // Check only for Arabic and Hebrew languages now.
496 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) { 496 if (strcmp(lang, "ar") == 0 || strcmp(lang, "he") == 0) {
497 g_text_direction = RIGHT_TO_LEFT; 497 g_text_direction = RIGHT_TO_LEFT;
498 } else { 498 } else {
499 g_text_direction = LEFT_TO_RIGHT; 499 g_text_direction = LEFT_TO_RIGHT;
500 } 500 }
501 } 501 }
502 return g_text_direction; 502 return g_text_direction;
503 } 503 }
504 504
505 TextDirection GetFirstStrongCharacterDirection(const std::wstring& text) {
506 #if defined(WCHAR_T_IS_UTF32)
507 string16 text_utf16 = WideToUTF16(text);
508 const UChar* string = text_utf16.c_str();
509 #else
510 const UChar* string = text.c_str();
511 #endif
512 size_t length = text.length();
513 size_t position = 0;
514 while (position < length) {
515 UChar32 character;
516 size_t next_position = position;
517 U16_NEXT(string, next_position, length, character);
518
519 // Now that we have the character, we use ICU in order to query for the
520 // appropriate Unicode BiDi character type.
521 int32_t property = u_getIntPropertyValue(character, UCHAR_BIDI_CLASS);
522 if ((property == U_RIGHT_TO_LEFT) ||
523 (property == U_RIGHT_TO_LEFT_ARABIC) ||
524 (property == U_RIGHT_TO_LEFT_EMBEDDING) ||
525 (property == U_RIGHT_TO_LEFT_OVERRIDE)) {
526 return RIGHT_TO_LEFT;
527 } else if ((property == U_LEFT_TO_RIGHT) ||
528 (property == U_LEFT_TO_RIGHT_EMBEDDING) ||
529 (property == U_LEFT_TO_RIGHT_OVERRIDE)) {
530 return LEFT_TO_RIGHT;
531 }
532
533 position = next_position;
534 }
535
536 return LEFT_TO_RIGHT;
537 }
538
505 bool AdjustStringForLocaleDirection(const std::wstring& text, 539 bool AdjustStringForLocaleDirection(const std::wstring& text,
506 std::wstring* localized_text) { 540 std::wstring* localized_text) {
507 if (GetTextDirection() == LEFT_TO_RIGHT || text.length() == 0) 541 if (GetTextDirection() == LEFT_TO_RIGHT || text.length() == 0)
508 return false; 542 return false;
509 543
510 // Marking the string as LTR if the locale is RTL and the string does not 544 // Marking the string as LTR if the locale is RTL and the string does not
511 // contain strong RTL characters. Otherwise, mark the string as RTL. 545 // contain strong RTL characters. Otherwise, mark the string as RTL.
512 *localized_text = text; 546 *localized_text = text;
513 bool has_rtl_chars = StringContainsStrongRTLChars(text); 547 bool has_rtl_chars = StringContainsStrongRTLChars(text);
514 if (!has_rtl_chars) 548 if (!has_rtl_chars)
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
724 } 758 }
725 759
726 void BiDiLineIterator::GetLogicalRun(int start, 760 void BiDiLineIterator::GetLogicalRun(int start,
727 int* end, 761 int* end,
728 UBiDiLevel* level) { 762 UBiDiLevel* level) {
729 DCHECK(bidi_ != NULL); 763 DCHECK(bidi_ != NULL);
730 ubidi_getLogicalRun(bidi_, start, end, level); 764 ubidi_getLogicalRun(bidi_, start, end, level);
731 } 765 }
732 766
733 } 767 }
OLDNEW
« no previous file with comments | « chrome/common/l10n_util.h ('k') | chrome/common/l10n_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698