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

Side by Side Diff: ui/base/l10n/l10n_util_plurals.cc

Issue 1140153005: ICU msg format support with more than one arguments (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mark's review comments Created 5 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 | « ui/base/l10n/l10n_util_plurals.h ('k') | ui/base/ui_base.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/base/l10n/l10n_util_plurals.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "ui/base/l10n/l10n_util.h"
10
11 namespace l10n_util {
12
13 scoped_ptr<icu::PluralRules> BuildPluralRules() {
14 UErrorCode err = U_ZERO_ERROR;
15 scoped_ptr<icu::PluralRules> rules(
16 icu::PluralRules::forLocale(icu::Locale::getDefault(), err));
17 if (U_FAILURE(err)) {
18 err = U_ZERO_ERROR;
19 icu::UnicodeString fallback_rules("one: n is 1", -1, US_INV);
20 rules.reset(icu::PluralRules::createRules(fallback_rules, err));
21 DCHECK(U_SUCCESS(err));
22 }
23 return rules.Pass();
24 }
25
26 void FormatNumberInPlural(const icu::MessageFormat& format, int number,
27 icu::UnicodeString* result, UErrorCode* err) {
28 if (U_FAILURE(*err)) return;
29 icu::Formattable formattable(number);
30 icu::FieldPosition ignore(icu::FieldPosition::DONT_CARE);
31 format.format(&formattable, 1, *result, ignore, *err);
32 DCHECK(U_SUCCESS(*err));
33 return;
34 }
35
36
37 } // namespace l10n_util
OLDNEW
« no previous file with comments | « ui/base/l10n/l10n_util_plurals.h ('k') | ui/base/ui_base.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698