2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/system/common/locale-utils.h>
36 struct LocaleDirectionInfo
40 Locale::Direction direction;
43 const LocaleDirectionInfo LOCALE_DIRECTION_LOOKUP_TABLE[] =
45 { "af", "Afrikaans", Locale::LeftToRight },
46 { "am", "Amharic", Locale::LeftToRight },
47 { "ar", "Arabic", Locale::RightToLeft },
48 { "as", "Assamese", Locale::LeftToRight },
49 { "az", "Azerbaijani", Locale::LeftToRight },
50 { "be", "Belarusian", Locale::LeftToRight },
51 { "bg", "Bulgarian", Locale::LeftToRight },
52 { "bn", "Bengali", Locale::LeftToRight },
53 { "bo", "Tibetan", Locale::LeftToRight },
54 { "bs", "Bosnian", Locale::LeftToRight },
55 { "ca", "Catalan", Locale::LeftToRight },
56 { "ck", "Iraq", Locale::RightToLeft },
57 { "cs", "Czech", Locale::LeftToRight },
58 { "cy", "Welsh", Locale::LeftToRight },
59 { "da", "Danish", Locale::LeftToRight },
60 { "de", "German", Locale::LeftToRight },
61 { "dv", "Divehi", Locale::RightToLeft },
62 { "el", "Greek", Locale::LeftToRight },
63 { "en", "English", Locale::LeftToRight },
64 { "es", "Spanish", Locale::LeftToRight },
65 { "et", "Estonian", Locale::LeftToRight },
66 { "eu", "Basque", Locale::LeftToRight },
67 { "fa", "Farsi", Locale::RightToLeft },
68 { "fi", "Finnish", Locale::LeftToRight },
69 { "fo", "Faroese", Locale::LeftToRight },
70 { "fr", "French", Locale::LeftToRight },
71 { "gd", "Gaelic", Locale::LeftToRight },
72 { "gl", "Galician", Locale::LeftToRight },
73 { "gn", "Guarani", Locale::LeftToRight },
74 { "gu", "Gujarati", Locale::LeftToRight },
75 { "ha", "Hausa", Locale::RightToLeft },
76 { "he", "Hebrew", Locale::RightToLeft },
77 { "hi", "Hindi", Locale::LeftToRight },
78 { "hr", "Croatian", Locale::LeftToRight },
79 { "hu", "Hungarian", Locale::LeftToRight },
80 { "hy", "Armenian", Locale::LeftToRight },
81 { "id", "Indonesian", Locale::LeftToRight },
82 { "is", "Icelandic", Locale::LeftToRight },
83 { "it", "Italian", Locale::LeftToRight },
84 { "ja", "Japanese", Locale::LeftToRight },
85 { "ka", "Georgian", Locale::LeftToRight },
86 { "kk", "Kazakh", Locale::LeftToRight },
87 { "km", "Khmer", Locale::LeftToRight },
88 { "kn", "Kannada", Locale::LeftToRight },
89 { "ko", "Korean", Locale::LeftToRight },
90 { "ks", "Kashmiri", Locale::LeftToRight },
91 { "ku", "Kurdish", Locale::RightToLeft },
92 { "la", "Latin", Locale::LeftToRight },
93 { "lo", "Lao", Locale::LeftToRight },
94 { "lt", "Lithuanian", Locale::LeftToRight },
95 { "lv", "Latvian", Locale::LeftToRight },
96 { "mi", "Maori", Locale::LeftToRight },
97 { "mk", "FYRO Macedonia", Locale::LeftToRight },
98 { "ml", "Malayalam", Locale::LeftToRight },
99 { "mn", "Mongolian", Locale::LeftToRight },
100 { "mr", "Marathi", Locale::LeftToRight },
101 { "ms", "Malay", Locale::LeftToRight },
102 { "mt", "Maltese", Locale::LeftToRight },
103 { "my", "Burmese", Locale::LeftToRight },
104 { "nb", "Norwegian: Bokml", Locale::LeftToRight },
105 { "ne", "Nepali", Locale::LeftToRight },
106 { "nl", "Dutch", Locale::LeftToRight },
107 { "nn", "Norwegian: Nynorsk", Locale::LeftToRight },
108 { "or", "Oriya", Locale::LeftToRight },
109 { "pa", "Punjabi", Locale::LeftToRight },
110 { "pl", "Polish", Locale::LeftToRight },
111 { "pt", "Portuguese", Locale::LeftToRight },
112 { "rm", "Raeto-Romance", Locale::LeftToRight },
113 { "ro", "Romanian", Locale::LeftToRight },
114 { "ru", "Russian", Locale::LeftToRight },
115 { "sa", "Sanskrit", Locale::LeftToRight },
116 { "sb", "Sorbian", Locale::LeftToRight },
117 { "sd", "Sindhi", Locale::LeftToRight },
118 { "si", "Sinhala", Locale::LeftToRight },
119 { "sk", "Slovak", Locale::LeftToRight },
120 { "sl", "Slovenian", Locale::LeftToRight },
121 { "so", "Somali", Locale::LeftToRight },
122 { "sq", "Albanian", Locale::LeftToRight },
123 { "sr", "Serbian", Locale::LeftToRight },
124 { "sv", "Swedish", Locale::LeftToRight },
125 { "sw", "Swahili", Locale::LeftToRight },
126 { "ta", "Tamil", Locale::LeftToRight },
127 { "te", "Telugu", Locale::LeftToRight },
128 { "tg", "Tajik", Locale::LeftToRight },
129 { "th", "Thai", Locale::LeftToRight },
130 { "tk", "Turkmen", Locale::LeftToRight },
131 { "tn", "Setsuana", Locale::LeftToRight },
132 { "tr", "Turkish", Locale::LeftToRight },
133 { "ts", "Tsonga", Locale::LeftToRight },
134 { "tt", "Tatar", Locale::LeftToRight },
135 { "uk", "Ukrainian", Locale::LeftToRight },
136 { "ur", "Urdu", Locale::RightToLeft },
137 { "uz", "Uzbek", Locale::LeftToRight },
138 { "vi", "Vietnamese", Locale::LeftToRight },
139 { "xh", "Xhosa", Locale::LeftToRight },
140 { "yi", "Yiddish", Locale::RightToLeft },
141 { "zh", "Chinese", Locale::LeftToRight },
142 { "zu", "Zulu", Locale::LeftToRight },
144 { NULL, NULL, Locale::LeftToRight }
147 } // unnamed namespace
149 Locale::Direction GetDirection( const std::string& locale )
151 Locale::Direction direction( Locale::LeftToRight );
153 if ( !locale.empty() && locale.size() > 2 )
155 for ( const LocaleDirectionInfo* iter = &LOCALE_DIRECTION_LOOKUP_TABLE[0]; iter->locale; ++iter )
157 if ( !locale.compare( 0, 2, iter->locale ) )
159 direction = iter->direction;
168 } // namespace Locale
170 } // namespace Adaptor
172 } // namespace Internal