diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:30:31 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 16:30:31 +0000 |
commit | e4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1 (patch) | |
tree | a67fd0c447659c2f86d5b1bea61645e4010fc3f1 | |
parent | eb3793b3c41f06476975821a24e630d86b46a374 (diff) | |
download | chromium_src-e4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1.zip chromium_src-e4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1.tar.gz chromium_src-e4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1.tar.bz2 |
[GTK] Fix paragraph directionality for first run dialog in Hebrew.
BUG=54898
TEST=
Review URL: http://codereview.chromium.org/3368011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59664 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | app/l10n_util.cc | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/app/l10n_util.cc b/app/l10n_util.cc index 1ec4b19..824d054 100644 --- a/app/l10n_util.cc +++ b/app/l10n_util.cc @@ -362,6 +362,20 @@ void SplitAndNormalizeLanguageList(const std::string& env_language, } #endif +// On Linux, the text layout engine Pango determines paragraph directionality +// by looking at the first strongly-directional character in the text. This +// means text such as "Google Chrome foo bar..." will be layed out LTR even +// if "foo bar" is RTL. So this function prepends the necessary RLM in such +// cases. +void AdjustParagraphDirectionality(string16* paragraph) { +#if defined(OS_LINUX) + if (base::i18n::IsRTL() && + base::i18n::StringContainsStrongRTLChars(*paragraph)) { + paragraph->insert(0, 1, static_cast<char16>(base::i18n::kRightToLeftMark)); + } +#endif +} + } // namespace namespace l10n_util { @@ -490,18 +504,19 @@ string16 GetDisplayNameForLocale(const std::string& locale, } std::wstring GetString(int message_id) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - return UTF16ToWide(rb.GetLocalizedString(message_id)); + return UTF16ToWide(GetStringUTF16(message_id)); } std::string GetStringUTF8(int message_id) { - ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - return UTF16ToUTF8(rb.GetLocalizedString(message_id)); + return UTF16ToUTF8(GetStringUTF16(message_id)); } string16 GetStringUTF16(int message_id) { ResourceBundle& rb = ResourceBundle::GetSharedInstance(); - return rb.GetLocalizedString(message_id); + string16 str = rb.GetLocalizedString(message_id); + AdjustParagraphDirectionality(&str); + + return str; } static string16 GetStringF(int message_id, @@ -523,6 +538,8 @@ static string16 GetStringF(int message_id, subst.push_back(d); string16 formatted = ReplaceStringPlaceholders(format_string, subst, offsets); + AdjustParagraphDirectionality(&formatted); + return formatted; } |