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

Side by Side Diff: app/l10n_util.cc

Issue 174043: Gtk languages options page part 1: accept-languages configuration. (Closed)
Patch Set: rebase Created 11 years, 4 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
« no previous file with comments | « app/l10n_util.h ('k') | chrome/browser/gtk/options/fonts_languages_window_gtk.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 "app/l10n_util.h" 5 #include "app/l10n_util.h"
6 6
7 #include "app/app_paths.h" 7 #include "app/app_paths.h"
8 #include "app/app_switches.h" 8 #include "app/app_switches.h"
9 #include "app/gfx/canvas.h" 9 #include "app/gfx/canvas.h"
10 #include "app/resource_bundle.h" 10 #include "app/resource_bundle.h"
(...skipping 21 matching lines...) Expand all
32 32
33 #if defined(OS_WIN) 33 #if defined(OS_WIN)
34 static const FilePath::CharType kLocaleFileExtension[] = L".dll"; 34 static const FilePath::CharType kLocaleFileExtension[] = L".dll";
35 #elif defined(OS_POSIX) 35 #elif defined(OS_POSIX)
36 static const FilePath::CharType kLocaleFileExtension[] = ".pak"; 36 static const FilePath::CharType kLocaleFileExtension[] = ".pak";
37 #endif 37 #endif
38 38
39 // Added to the end of strings that are too big in TrucateString. 39 // Added to the end of strings that are too big in TrucateString.
40 static const wchar_t* const kElideString = L"\x2026"; 40 static const wchar_t* const kElideString = L"\x2026";
41 41
42 static const char* const kAcceptLanguageList[] = {
43 "af", // Afrikaans
44 "am", // Amharic
45 "ar", // Arabic
46 "az", // Azerbaijani
47 "be", // Belarusian
48 "bg", // Bulgarian
49 "bh", // Bihari
50 "bn", // Bengali
51 "br", // Breton
52 "bs", // Bosnian
53 "ca", // Catalan
54 "co", // Corsican
55 "cs", // Czech
56 "cy", // Welsh
57 "da", // Danish
58 "de", // German
59 "de-AT", // German (Austria)
60 "de-CH", // German (Switzerland)
61 "de-DE", // German (Germany)
62 "el", // Greek
63 "en", // English
64 "en-AU", // English (Austrailia)
65 "en-CA", // English (Canada)
66 "en-GB", // English (UK)
67 "en-NZ", // English (New Zealand)
68 "en-US", // English (US)
69 "en-ZA", // English (South Africa)
70 "eo", // Esperanto
71 // TODO(jungshik) : Do we want to list all es-Foo for Latin-American
72 // Spanish speaking countries?
73 "es", // Spanish
74 "et", // Estonian
75 "eu", // Basque
76 "fa", // Persian
77 "fi", // Finnish
78 "fil", // Filipino
79 "fo", // Faroese
80 "fr", // French
81 "fr-CA", // French (Canada)
82 "fr-CH", // French (Switzerland)
83 "fr-FR", // French (France)
84 "fy", // Frisian
85 "ga", // Irish
86 "gd", // Scots Gaelic
87 "gl", // Galician
88 "gn", // Guarani
89 "gu", // Gujarati
90 "he", // Hebrew
91 "hi", // Hindi
92 "hr", // Croatian
93 "hu", // Hungarian
94 "hy", // Armenian
95 "ia", // Interlingua
96 "id", // Indonesian
97 "is", // Icelandic
98 "it", // Italian
99 "it-CH", // Italian (Switzerland)
100 "it-IT", // Italian (Italy)
101 "ja", // Japanese
102 "jw", // Javanese
103 "ka", // Georgian
104 "kk", // Kazakh
105 "km", // Cambodian
106 "kn", // Kannada
107 "ko", // Korean
108 "ku", // Kurdish
109 "ky", // Kyrgyz
110 "la", // Latin
111 "ln", // Lingala
112 "lo", // Laothian
113 "lt", // Lithuanian
114 "lv", // Latvian
115 "mk", // Macedonian
116 "ml", // Malayalam
117 "mn", // Mongolian
118 "mo", // Moldavian
119 "mr", // Marathi
120 "ms", // Malay
121 "mt", // Maltese
122 "nb", // Norwegian (Bokmal)
123 "ne", // Nepali
124 "nl", // Dutch
125 "nn", // Norwegian (Nynorsk)
126 "no", // Norwegian
127 "oc", // Occitan
128 "or", // Oriya
129 "pa", // Punjabi
130 "pl", // Polish
131 "ps", // Pashto
132 "pt", // Portuguese
133 "pt-BR", // Portuguese (Brazil)
134 "pt-PT", // Portuguese (Portugal)
135 "qu", // Quechua
136 "rm", // Romansh
137 "ro", // Romanian
138 "ru", // Russian
139 "sd", // Sindhi
140 "sh", // Serbo-Croatian
141 "si", // Sinhalese
142 "sk", // Slovak
143 "sl", // Slovenian
144 "sn", // Shona
145 "so", // Somali
146 "sq", // Albanian
147 "sr", // Serbian
148 "st", // Sesotho
149 "su", // Sundanese
150 "sv", // Swedish
151 "sw", // Swahili
152 "ta", // Tamil
153 "te", // Telugu
154 "tg", // Tajik
155 "th", // Thai
156 "ti", // Tigrinya
157 "tk", // Turkmen
158 "to", // Tonga
159 "tr", // Turkish
160 "tt", // Tatar
161 "tw", // Twi
162 "ug", // Uighur
163 "uk", // Ukrainian
164 "ur", // Urdu
165 "uz", // Uzbek
166 "vi", // Vietnamese
167 "xh", // Xhosa
168 "yi", // Yiddish
169 "yo", // Yoruba
170 "zh", // Chinese
171 "zh-CN", // Chinese (Simplified)
172 "zh-TW", // Chinese (Traditional)
173 "zu", // Zulu
174 };
175
176
42 // Get language and region from the OS. 177 // Get language and region from the OS.
43 void GetLanguageAndRegionFromOS(std::string* lang, std::string* region) { 178 void GetLanguageAndRegionFromOS(std::string* lang, std::string* region) {
44 // Later we may have to change this to be OS-dependent so that 179 // Later we may have to change this to be OS-dependent so that
45 // it's not affected by ICU's default locale. It's all right 180 // it's not affected by ICU's default locale. It's all right
46 // to do this way because SetICUDefaultLocale is internal 181 // to do this way because SetICUDefaultLocale is internal
47 // to this file and we know where/when it's called. 182 // to this file and we know where/when it's called.
48 icu::Locale locale = icu::Locale::getDefault(); 183 icu::Locale locale = icu::Locale::getDefault();
49 const char* language = locale.getLanguage(); 184 const char* language = locale.getLanguage();
50 const char* country = locale.getCountry(); 185 const char* country = locale.getCountry();
51 DCHECK(language); 186 DCHECK(language);
(...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 870 }
736 locales.push_back(locale_name); 871 locales.push_back(locale_name);
737 } 872 }
738 873
739 // Manually add 'es-419' to the list. See the comment in IsDuplicateName(). 874 // Manually add 'es-419' to the list. See the comment in IsDuplicateName().
740 locales.push_back("es-419"); 875 locales.push_back("es-419");
741 } 876 }
742 return locales; 877 return locales;
743 } 878 }
744 879
880 void GetAcceptLanguagesForLocale(const std::string& display_locale,
881 std::vector<std::string>* locale_codes) {
882 for (size_t i = 0; i < arraysize(kAcceptLanguageList); ++i) {
883 string16 display_name =
884 l10n_util::GetDisplayNameForLocale(kAcceptLanguageList[i],
885 display_locale, false);
886 // This is a hack. If ICU doesn't have a translated name for
887 // this language, GetDisplayNameForLocale will just return the
888 // language code. In that case, we skip it.
889 // TODO(jungshik) : Put them at the of the list with language codes
890 // enclosed by brackets.
891 if (IsStringASCII(display_name) &&
892 UTF16ToASCII(display_name) == kAcceptLanguageList[i])
893 continue;
894 locale_codes->push_back(kAcceptLanguageList[i]);
895 }
896 }
897
745 BiDiLineIterator::~BiDiLineIterator() { 898 BiDiLineIterator::~BiDiLineIterator() {
746 if (bidi_) { 899 if (bidi_) {
747 ubidi_close(bidi_); 900 ubidi_close(bidi_);
748 bidi_ = NULL; 901 bidi_ = NULL;
749 } 902 }
750 } 903 }
751 904
752 UBool BiDiLineIterator::Open(const std::wstring& text, 905 UBool BiDiLineIterator::Open(const std::wstring& text,
753 bool right_to_left, 906 bool right_to_left,
754 bool url) { 907 bool url) {
(...skipping 30 matching lines...) Expand all
785 } 938 }
786 939
787 void BiDiLineIterator::GetLogicalRun(int start, 940 void BiDiLineIterator::GetLogicalRun(int start,
788 int* end, 941 int* end,
789 UBiDiLevel* level) { 942 UBiDiLevel* level) {
790 DCHECK(bidi_ != NULL); 943 DCHECK(bidi_ != NULL);
791 ubidi_getLogicalRun(bidi_, start, end, level); 944 ubidi_getLogicalRun(bidi_, start, end, level);
792 } 945 }
793 946
794 } 947 }
OLDNEW
« no previous file with comments | « app/l10n_util.h ('k') | chrome/browser/gtk/options/fonts_languages_window_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698