| OLD | NEW |
| (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 | |
| OLD | NEW |