diff options
author | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
---|---|---|
committer | ben@chromium.org <ben@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-20 06:37:01 +0000 |
commit | 7cf1b6ced3b14cce1d66ca0ddc713851f0d37536 (patch) | |
tree | 1c2fc9f4d52bf3046addf820d5eec03a2e150749 /app/l10n_util.h | |
parent | f9f4841b14a9f309ce5ee613f0d4de6afad88767 (diff) | |
download | chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.zip chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.gz chromium_src-7cf1b6ced3b14cce1d66ca0ddc713851f0d37536.tar.bz2 |
Move RTL related functions from app/l10n_util to base/i18n/rtl
TBR=darin
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/1073005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'app/l10n_util.h')
-rw-r--r-- | app/l10n_util.h | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/app/l10n_util.h b/app/l10n_util.h index b87442c..c176f73f 100644 --- a/app/l10n_util.h +++ b/app/l10n_util.h @@ -25,17 +25,10 @@ #include "app/l10n_util_mac.h" #endif // OS_MACOSX -class FilePath; class PrefService; namespace l10n_util { -const char16 kRightToLeftMark = 0x200f; -const char16 kLeftToRightMark = 0x200e; -const char16 kLeftToRightEmbeddingMark = 0x202A; -const char16 kRightToLeftEmbeddingMark = 0x202B; -const char16 kPopDirectionalFormatting = 0x202C; - // This method is responsible for determining the locale as defined below. In // nearly all cases you shouldn't call this, rather use GetApplicationLocale // defined on browser_process. @@ -181,97 +174,6 @@ string16 ToLower(const string16& string); // Returns the upper case equivalent of string. string16 ToUpper(const string16& string); -// Represents the text direction returned by the GetTextDirection() function. -enum TextDirection { - UNKNOWN_DIRECTION, - RIGHT_TO_LEFT, - LEFT_TO_RIGHT, -}; - -// Returns the text direction for the default ICU locale. It is assumed -// that SetICUDefaultLocale has been called to set the default locale to -// the UI locale of Chrome. Its return is one of the following three: -// * LEFT_TO_RIGHT: Left-To-Right (e.g. English, Chinese, etc.); -// * RIGHT_TO_LEFT: Right-To-Left (e.g. Arabic, Hebrew, etc.), and; -// * UNKNOWN_DIRECTION: unknown (or error). -TextDirection GetICUTextDirection(); - -// Get the application text direction. (This is just the ICU direction, -// except on GTK.) -TextDirection GetTextDirection(); - -// Returns the text direction for |locale_name|. -TextDirection GetTextDirectionForLocale(const char* locale_name); - -// Given the string in |text|, returns the directionality of the first -// character with strong directionality in the string. If no character in the -// text has strong directionality, LEFT_TO_RIGHT is returned. The Bidi -// character types L, LRE, LRO, R, AL, RLE, and RLO are considered as strong -// directionality characters. Please refer to http://unicode.org/reports/tr9/ -// for more information. -TextDirection GetFirstStrongCharacterDirection(const std::wstring& text); - -// Given the string in |text|, this function creates a copy of the string with -// the appropriate Unicode formatting marks that mark the string direction -// (either left-to-right or right-to-left). The new string is returned in -// |localized_text|. The function checks both the current locale and the -// contents of the string in order to determine the direction of the returned -// string. The function returns true if the string in |text| was properly -// adjusted. -// -// Certain LTR strings are not rendered correctly when the context is RTL. For -// example, the string "Foo!" will appear as "!Foo" if it is rendered as is in -// an RTL context. Calling this function will make sure the returned localized -// string is always treated as a right-to-left string. This is done by -// inserting certain Unicode formatting marks into the returned string. -// -// TODO(idana) bug# 1206120: this function adjusts the string in question only -// if the current locale is right-to-left. The function does not take care of -// the opposite case (an RTL string displayed in an LTR context) since -// adjusting the string involves inserting Unicode formatting characters that -// Windows does not handle well unless right-to-left language support is -// installed. Since the English version of Windows doesn't have right-to-left -// language support installed by default, inserting the direction Unicode mark -// results in Windows displaying squares. -bool AdjustStringForLocaleDirection(const std::wstring& text, - std::wstring* localized_text); - -// Returns true if the string contains at least one character with strong right -// to left directionality; that is, a character with either R or AL Unicode -// BiDi character type. -bool StringContainsStrongRTLChars(const std::wstring& text); - -// Wraps a string with an LRE-PDF pair which essentialy marks the string as a -// Left-To-Right string. Doing this is useful in order to make sure LTR -// strings are rendered properly in an RTL context. -void WrapStringWithLTRFormatting(std::wstring* text); - -// Wraps a string with an RLE-PDF pair which essentialy marks the string as a -// Right-To-Left string. Doing this is useful in order to make sure RTL -// strings are rendered properly in an LTR context. -void WrapStringWithRTLFormatting(std::wstring* text); - -// Wraps file path to get it to display correctly in RTL UI. All filepaths -// should be passed through this function before display in UI for RTL locales. -void WrapPathWithLTRFormatting(const FilePath& path, - string16* rtl_safe_path); - -// Given the string in |text|, this function returns the adjusted string having -// LTR directionality for display purpose. Which means that in RTL locale the -// string is wrapped with LRE (Left-To-Right Embedding) and PDF (Pop -// Directional Formatting) marks and returned. In LTR locale, the string itself -// is returned. -std::wstring GetDisplayStringInLTRDirectionality(std::wstring* text); - -// Returns the default text alignment to be used when drawing text on a -// gfx::Canvas based on the directionality of the system locale language. This -// function is used by gfx::Canvas::DrawStringInt when the text alignment is -// not specified. -// -// This function returns either gfx::Canvas::TEXT_ALIGN_LEFT or -// gfx::Canvas::TEXT_ALIGN_RIGHT. -int DefaultCanvasTextAlignment(); - // In place sorting of strings using collation rules for |locale|. // TODO(port): this should take string16. void SortStrings(const std::string& locale, |