summaryrefslogtreecommitdiffstats
path: root/app/l10n_util.cc
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 16:30:31 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-16 16:30:31 +0000
commite4ce5f12d132e6a56c73cd42a5bb4e6aaea9a4e1 (patch)
treea67fd0c447659c2f86d5b1bea61645e4010fc3f1 /app/l10n_util.cc
parenteb3793b3c41f06476975821a24e630d86b46a374 (diff)
downloadchromium_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
Diffstat (limited to 'app/l10n_util.cc')
-rw-r--r--app/l10n_util.cc27
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;
}