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

Side by Side Diff: app/l10n_util.h

Issue 5643002: Add utility function to determine if a locale is valid syntax; this will... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | app/l10n_util.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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 // This file contains utility functions for dealing with localized 5 // This file contains utility functions for dealing with localized
6 // content. 6 // content.
7 7
8 #ifndef APP_L10N_UTIL_H_ 8 #ifndef APP_L10N_UTIL_H_
9 #define APP_L10N_UTIL_H_ 9 #define APP_L10N_UTIL_H_
10 #pragma once 10 #pragma once
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // it returns "French". To get the display name of 49 // it returns "French". To get the display name of
50 // |locale| in the UI language of Chrome, |display_locale| can be 50 // |locale| in the UI language of Chrome, |display_locale| can be
51 // set to the return value of g_browser_process->GetApplicationLocale() 51 // set to the return value of g_browser_process->GetApplicationLocale()
52 // in the UI thread. 52 // in the UI thread.
53 // If |is_for_ui| is true, U+200F is appended so that it can be 53 // If |is_for_ui| is true, U+200F is appended so that it can be
54 // rendered properly in a RTL Chrome. 54 // rendered properly in a RTL Chrome.
55 string16 GetDisplayNameForLocale(const std::string& locale, 55 string16 GetDisplayNameForLocale(const std::string& locale,
56 const std::string& display_locale, 56 const std::string& display_locale,
57 bool is_for_ui); 57 bool is_for_ui);
58 58
59 // Converts all - into _, to be consistent with ICU and file system names.
60 std::string NormalizeLocale(const std::string& locale);
61
62 // Produce a vector of parent locales for given locale.
63 // It includes the current locale in the result.
64 // sr_Cyrl_RS generates sr_Cyrl_RS, sr_Cyrl and sr.
65 void GetParentLocales(const std::string& current_locale,
66 std::vector<std::string>* parent_locales);
67
68 // Checks if a string is plausibly a syntactically-valid locale string,
69 // for cases where we want the valid input to be a locale string such as
70 // 'en', 'pt-BR', 'fil', 'es-419', 'zh-Hans-CN', 'i-klingon' or
71 // 'de_DE@collation=phonebook', but we don't want to limit it to
72 // locales that Chrome actually knows about, so 'xx-YY' should be
73 // accepted, but 'z', 'German', 'en-$1', or 'abcd-1234' should not.
74 // Case-insensitive. Based on BCP 47, see:
75 // http://unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
76 bool IsValidLocaleSyntax(const std::string& locale);
77
59 // 78 //
60 // Mac Note: See l10n_util_mac.h for some NSString versions and other support. 79 // Mac Note: See l10n_util_mac.h for some NSString versions and other support.
61 // 80 //
62 81
63 // Pulls resource string from the string bundle and returns it. 82 // Pulls resource string from the string bundle and returns it.
64 std::wstring GetString(int message_id); 83 std::wstring GetString(int message_id);
65 std::string GetStringUTF8(int message_id); 84 std::string GetStringUTF8(int message_id);
66 string16 GetStringUTF16(int message_id); 85 string16 GetStringUTF16(int message_id);
67 86
68 // Get a resource string and replace $1-$2-$3 with |a| and |b| 87 // Get a resource string and replace $1-$2-$3 with |a| and |b|
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 const std::vector<std::string>& GetAvailableLocales(); 203 const std::vector<std::string>& GetAvailableLocales();
185 204
186 // Returns a vector of locale codes usable for accept-languages. 205 // Returns a vector of locale codes usable for accept-languages.
187 void GetAcceptLanguagesForLocale(const std::string& display_locale, 206 void GetAcceptLanguagesForLocale(const std::string& display_locale,
188 std::vector<std::string>* locale_codes); 207 std::vector<std::string>* locale_codes);
189 208
190 209
191 } // namespace l10n_util 210 } // namespace l10n_util
192 211
193 #endif // APP_L10N_UTIL_H_ 212 #endif // APP_L10N_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | app/l10n_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698