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

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

Issue 23591040: Use ICU for string pluralization in the extension permission dialog. (Closed) Base URL: http://git.chromium.org/chromium/src.git@gtk-extension-install-dialog
Patch Set: Created 7 years, 3 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 513a615a14166e5e335b59203ab5899e1f7e4402..8dcc607e31ea912448e84ed540f29999da0336f2 100644
--- a/ui/base/l10n/l10n_util.cc
+++ b/ui/base/l10n/l10n_util.cc
@@ -28,6 +28,7 @@
#include "third_party/icu/source/common/unicode/rbbi.h"
#include "third_party/icu/source/common/unicode/uloc.h"
#include "ui/base/l10n/l10n_util_collator.h"
+#include "ui/base/l10n/l10n_util_plurals.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/ui_base_paths.h"
@@ -831,6 +832,27 @@ bool StringComparator<string16>::operator()(const string16& lhs,
UCOL_LESS;
};
+string16 GetPluralStringFUTF16(const std::vector<int>& message_ids,
+ int number) {
+ scoped_ptr<icu::PluralFormat> format = BuildPluralFormat(message_ids);
+ DCHECK(format);
+
+ UErrorCode err = U_ZERO_ERROR;
+ icu::UnicodeString result_files_string = format->format(number, err);
+ int capacity = result_files_string.length() + 1;
+ DCHECK_GT(capacity, 1);
+ string16 result;
+ result_files_string.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));
+}
+
void SortStrings16(const std::string& locale,
std::vector<string16>* strings) {
SortVectorWithStringKey(locale, strings, false);
« 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