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

Unified Diff: ui/base/l10n/l10n_util.cc

Issue 1049513002: Use the ICU syntax message for plural formatting (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ios whitelist update Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | ui/base/l10n/l10n_util_plurals.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/l10n/l10n_util.cc
diff --git a/ui/base/l10n/l10n_util.cc b/ui/base/l10n/l10n_util.cc
index 354db4b98977f5a35e465935d9738fb3f816a4e8..23ca7ce1af9ad7c66e2daac06e1bbe133d52316b 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -823,25 +823,24 @@ base::string16 GetStringFUTF16Int(int message_id, int64 a) {
return GetStringFUTF16(message_id, base::UTF8ToUTF16(base::Int64ToString(a)));
}
-base::string16 GetPluralStringFUTF16(const std::vector<int>& message_ids,
- int number) {
- scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids);
- DCHECK(format);
-
+base::string16 GetPluralStringFUTF16(int message_id, int number) {
+ base::string16 pattern = GetStringUTF16(message_id);
UErrorCode err = U_ZERO_ERROR;
- icu::UnicodeString result_files_string = format->format(number, err);
- int capacity = result_files_string.length() + 1;
+ icu::MessageFormat format(
+ icu::UnicodeString(FALSE, pattern.data(), pattern.length()), err);
+ icu::UnicodeString result_unistring;
+ FormatNumberInPlural(format, number, &result_unistring, &err);
+ int capacity = result_unistring.length() + 1;
DCHECK_GT(capacity, 1);
base::string16 result;
- result_files_string.extract(
+ result_unistring.extract(
static_cast<UChar*>(WriteInto(&result, capacity)), capacity, err);
DCHECK(U_SUCCESS(err));
return result;
}
-std::string GetPluralStringFUTF8(const std::vector<int>& message_ids,
- int number) {
- return base::UTF16ToUTF8(GetPluralStringFUTF16(message_ids, number));
+std::string GetPluralStringFUTF8(int message_id, int number) {
+ return base::UTF16ToUTF8(GetPluralStringFUTF16(message_id, number));
}
void SortStrings16(const std::string& locale,
« no previous file with comments | « ui/base/l10n/l10n_util.h ('k') | ui/base/l10n/l10n_util_plurals.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698