OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "ui/base/l10n/formatter.h" | 5 #include "ui/base/l10n/formatter.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "third_party/icu/source/common/unicode/unistr.h" | 10 #include "third_party/icu/source/common/unicode/unistr.h" |
| 11 #include "third_party/icu/source/i18n/unicode/msgfmt.h" |
| 12 #include "ui/base/l10n/l10n_util.h" |
11 #include "ui/base/l10n/l10n_util_plurals.h" | 13 #include "ui/base/l10n/l10n_util_plurals.h" |
12 #include "ui/strings/grit/ui_strings.h" | 14 #include "ui/strings/grit/ui_strings.h" |
13 | 15 |
14 namespace ui { | 16 namespace ui { |
15 | 17 |
16 UI_BASE_EXPORT bool formatter_force_fallback = false; | 18 UI_BASE_EXPORT bool formatter_force_fallback = false; |
17 | 19 |
18 static const size_t kNumberPluralities = 6; | |
19 struct Pluralities { | 20 struct Pluralities { |
20 int ids[kNumberPluralities]; | 21 int id; |
21 const char* fallback_one; | 22 const char* fallback_one; |
22 const char* fallback_other; | 23 const char* fallback_other; |
23 }; | 24 }; |
24 | 25 |
25 static const Pluralities IDS_ELAPSED_SHORT_SEC = { | 26 static const Pluralities IDS_ELAPSED_SHORT_SEC = { |
26 { IDS_TIME_ELAPSED_SECS_DEFAULT, IDS_TIME_ELAPSED_SECS_SINGULAR, | 27 IDS_TIME_ELAPSED_SECS, |
27 IDS_TIME_ELAPSED_SECS_ZERO, IDS_TIME_ELAPSED_SECS_TWO, | |
28 IDS_TIME_ELAPSED_SECS_FEW, IDS_TIME_ELAPSED_SECS_MANY }, | |
29 "one{# sec ago}", | 28 "one{# sec ago}", |
30 " other{# secs ago}" | 29 " other{# secs ago}" |
31 }; | 30 }; |
32 static const Pluralities IDS_ELAPSED_SHORT_MIN = { | 31 static const Pluralities IDS_ELAPSED_SHORT_MIN = { |
33 { IDS_TIME_ELAPSED_MINS_DEFAULT, IDS_TIME_ELAPSED_MINS_SINGULAR, | 32 IDS_TIME_ELAPSED_MINS, |
34 IDS_TIME_ELAPSED_MINS_ZERO, IDS_TIME_ELAPSED_MINS_TWO, | |
35 IDS_TIME_ELAPSED_MINS_FEW, IDS_TIME_ELAPSED_MINS_MANY }, | |
36 "one{# min ago}", | 33 "one{# min ago}", |
37 " other{# mins ago}" | 34 " other{# mins ago}" |
38 }; | 35 }; |
39 static const Pluralities IDS_ELAPSED_HOUR = { | 36 static const Pluralities IDS_ELAPSED_HOUR = { |
40 { IDS_TIME_ELAPSED_HOURS_DEFAULT, IDS_TIME_ELAPSED_HOURS_SINGULAR, | 37 IDS_TIME_ELAPSED_HOURS, |
41 IDS_TIME_ELAPSED_HOURS_ZERO, IDS_TIME_ELAPSED_HOURS_TWO, | |
42 IDS_TIME_ELAPSED_HOURS_FEW, IDS_TIME_ELAPSED_HOURS_MANY }, | |
43 "one{# hour ago}", | 38 "one{# hour ago}", |
44 " other{# hours ago}" | 39 " other{# hours ago}" |
45 }; | 40 }; |
46 static const Pluralities IDS_ELAPSED_DAY = { | 41 static const Pluralities IDS_ELAPSED_DAY = { |
47 { IDS_TIME_ELAPSED_DAYS_DEFAULT, IDS_TIME_ELAPSED_DAYS_SINGULAR, | 42 IDS_TIME_ELAPSED_DAYS, |
48 IDS_TIME_ELAPSED_DAYS_ZERO, IDS_TIME_ELAPSED_DAYS_TWO, | |
49 IDS_TIME_ELAPSED_DAYS_FEW, IDS_TIME_ELAPSED_DAYS_MANY }, | |
50 "one{# day ago}", | 43 "one{# day ago}", |
51 " other{# days ago}" | 44 " other{# days ago}" |
52 }; | 45 }; |
53 | 46 |
54 static const Pluralities IDS_REMAINING_SHORT_SEC = { | 47 static const Pluralities IDS_REMAINING_SHORT_SEC = { |
55 { IDS_TIME_REMAINING_SECS_DEFAULT, IDS_TIME_REMAINING_SECS_SINGULAR, | 48 IDS_TIME_REMAINING_SECS, |
56 IDS_TIME_REMAINING_SECS_ZERO, IDS_TIME_REMAINING_SECS_TWO, | |
57 IDS_TIME_REMAINING_SECS_FEW, IDS_TIME_REMAINING_SECS_MANY }, | |
58 "one{# sec left}", | 49 "one{# sec left}", |
59 " other{# secs left}" | 50 " other{# secs left}" |
60 }; | 51 }; |
61 static const Pluralities IDS_REMAINING_SHORT_MIN = { | 52 static const Pluralities IDS_REMAINING_SHORT_MIN = { |
62 { IDS_TIME_REMAINING_MINS_DEFAULT, IDS_TIME_REMAINING_MINS_SINGULAR, | 53 IDS_TIME_REMAINING_MINS, |
63 IDS_TIME_REMAINING_MINS_ZERO, IDS_TIME_REMAINING_MINS_TWO, | |
64 IDS_TIME_REMAINING_MINS_FEW, IDS_TIME_REMAINING_MINS_MANY }, | |
65 "one{# min left}", | 54 "one{# min left}", |
66 " other{# mins left}" | 55 " other{# mins left}" |
67 }; | 56 }; |
68 | 57 |
69 static const Pluralities IDS_REMAINING_LONG_SEC = { | 58 static const Pluralities IDS_REMAINING_LONG_SEC = { |
70 { IDS_TIME_REMAINING_LONG_SECS_DEFAULT, IDS_TIME_REMAINING_LONG_SECS_SINGULAR, | 59 IDS_TIME_REMAINING_LONG_SECS, |
71 IDS_TIME_REMAINING_LONG_SECS_ZERO, IDS_TIME_REMAINING_LONG_SECS_TWO, | |
72 IDS_TIME_REMAINING_LONG_SECS_FEW, IDS_TIME_REMAINING_LONG_SECS_MANY }, | |
73 "one{# second left}", | 60 "one{# second left}", |
74 " other{# seconds left}" | 61 " other{# seconds left}" |
75 }; | 62 }; |
76 static const Pluralities IDS_REMAINING_LONG_MIN = { | 63 static const Pluralities IDS_REMAINING_LONG_MIN = { |
77 { IDS_TIME_REMAINING_LONG_MINS_DEFAULT, IDS_TIME_REMAINING_LONG_MINS_SINGULAR, | 64 IDS_TIME_REMAINING_LONG_MINS, |
78 IDS_TIME_REMAINING_LONG_MINS_ZERO, IDS_TIME_REMAINING_LONG_MINS_TWO, | |
79 IDS_TIME_REMAINING_LONG_MINS_FEW, IDS_TIME_REMAINING_LONG_MINS_MANY }, | |
80 "one{# minute left}", | 65 "one{# minute left}", |
81 " other{# minutes left}" | 66 " other{# minutes left}" |
82 }; | 67 }; |
83 static const Pluralities IDS_REMAINING_HOUR = { | 68 static const Pluralities IDS_REMAINING_HOUR = { |
84 { IDS_TIME_REMAINING_HOURS_DEFAULT, IDS_TIME_REMAINING_HOURS_SINGULAR, | 69 IDS_TIME_REMAINING_HOURS, |
85 IDS_TIME_REMAINING_HOURS_ZERO, IDS_TIME_REMAINING_HOURS_TWO, | |
86 IDS_TIME_REMAINING_HOURS_FEW, IDS_TIME_REMAINING_HOURS_MANY }, | |
87 "one{# hour left}", | 70 "one{# hour left}", |
88 " other{# hours left}" | 71 " other{# hours left}" |
89 }; | 72 }; |
90 static const Pluralities IDS_REMAINING_DAY = { | 73 static const Pluralities IDS_REMAINING_DAY = { |
91 { IDS_TIME_REMAINING_DAYS_DEFAULT, IDS_TIME_REMAINING_DAYS_SINGULAR, | 74 IDS_TIME_REMAINING_DAYS, |
92 IDS_TIME_REMAINING_DAYS_ZERO, IDS_TIME_REMAINING_DAYS_TWO, | |
93 IDS_TIME_REMAINING_DAYS_FEW, IDS_TIME_REMAINING_DAYS_MANY }, | |
94 "one{# day left}", | 75 "one{# day left}", |
95 " other{# days left}" | 76 " other{# days left}" |
96 }; | 77 }; |
97 | 78 |
98 static const Pluralities IDS_DURATION_SHORT_SEC = { | 79 static const Pluralities IDS_DURATION_SHORT_SEC = { |
99 { IDS_TIME_SECS_DEFAULT, IDS_TIME_SECS_SINGULAR, IDS_TIME_SECS_ZERO, | 80 IDS_TIME_SECS, |
100 IDS_TIME_SECS_TWO, IDS_TIME_SECS_FEW, IDS_TIME_SECS_MANY }, | |
101 "one{# sec}", | 81 "one{# sec}", |
102 " other{# secs}" | 82 " other{# secs}" |
103 }; | 83 }; |
104 static const Pluralities IDS_DURATION_SHORT_MIN = { | 84 static const Pluralities IDS_DURATION_SHORT_MIN = { |
105 { IDS_TIME_MINS_DEFAULT, IDS_TIME_MINS_SINGULAR, IDS_TIME_MINS_ZERO, | 85 IDS_TIME_MINS, |
106 IDS_TIME_MINS_TWO, IDS_TIME_MINS_FEW, IDS_TIME_MINS_MANY }, | |
107 "one{# min}", | 86 "one{# min}", |
108 " other{# mins}" | 87 " other{# mins}" |
109 }; | 88 }; |
110 | 89 |
111 static const Pluralities IDS_LONG_SEC = { | 90 static const Pluralities IDS_LONG_SEC = { |
112 { IDS_TIME_LONG_SECS_DEFAULT, IDS_TIME_LONG_SECS_SINGULAR, | 91 IDS_TIME_LONG_SECS, |
113 IDS_TIME_LONG_SECS_ZERO, IDS_TIME_LONG_SECS_TWO, | |
114 IDS_TIME_LONG_SECS_FEW, IDS_TIME_LONG_SECS_MANY }, | |
115 "one{# second}", | 92 "one{# second}", |
116 " other{# seconds}" | 93 " other{# seconds}" |
117 }; | 94 }; |
118 static const Pluralities IDS_LONG_MIN = { | 95 static const Pluralities IDS_LONG_MIN = { |
119 { IDS_TIME_LONG_MINS_DEFAULT, IDS_TIME_LONG_MINS_SINGULAR, | 96 IDS_TIME_LONG_MINS, |
120 IDS_TIME_LONG_MINS_ZERO, IDS_TIME_LONG_MINS_TWO, | |
121 IDS_TIME_LONG_MINS_FEW, IDS_TIME_LONG_MINS_MANY }, | |
122 "one{# minute}", | 97 "one{# minute}", |
123 " other{# minutes}" | 98 " other{# minutes}" |
124 }; | 99 }; |
125 static const Pluralities IDS_DURATION_HOUR = { | 100 static const Pluralities IDS_DURATION_HOUR = { |
126 { IDS_TIME_HOURS_DEFAULT, IDS_TIME_HOURS_SINGULAR, IDS_TIME_HOURS_ZERO, | 101 IDS_TIME_HOURS, |
127 IDS_TIME_HOURS_TWO, IDS_TIME_HOURS_FEW, IDS_TIME_HOURS_MANY }, | |
128 "one{# hour}", | 102 "one{# hour}", |
129 " other{# hours}" | 103 " other{# hours}" |
130 }; | 104 }; |
131 static const Pluralities IDS_DURATION_DAY = { | 105 static const Pluralities IDS_DURATION_DAY = { |
132 { IDS_TIME_DAYS_DEFAULT, IDS_TIME_DAYS_SINGULAR, IDS_TIME_DAYS_ZERO, | 106 IDS_TIME_DAYS, |
133 IDS_TIME_DAYS_TWO, IDS_TIME_DAYS_FEW, IDS_TIME_DAYS_MANY }, | |
134 "one{# day}", | 107 "one{# day}", |
135 " other{# days}" | 108 " other{# days}" |
136 }; | 109 }; |
137 | 110 |
138 static const Pluralities IDS_LONG_MIN_1ST = { | 111 static const Pluralities IDS_LONG_MIN_1ST = { |
139 { IDS_TIME_LONG_MINS_1ST_DEFAULT, IDS_TIME_LONG_MINS_1ST_SINGULAR, | 112 IDS_TIME_LONG_MINS_1ST, |
140 IDS_TIME_LONG_MINS_1ST_ZERO, IDS_TIME_LONG_MINS_1ST_TWO, | 113 "one{# minute and }", |
141 IDS_TIME_LONG_MINS_1ST_FEW, IDS_TIME_LONG_MINS_1ST_MANY }, | 114 " other{# minutes and }" |
142 "one{# minute }", | |
143 " other{# minutes }" | |
144 }; | 115 }; |
145 static const Pluralities IDS_LONG_SEC_2ND = { | 116 static const Pluralities IDS_LONG_SEC_2ND = { |
146 { IDS_TIME_LONG_SECS_2ND_DEFAULT, IDS_TIME_LONG_SECS_2ND_SINGULAR, | 117 IDS_TIME_LONG_SECS_2ND, |
147 IDS_TIME_LONG_SECS_2ND_ZERO, IDS_TIME_LONG_SECS_2ND_TWO, | |
148 IDS_TIME_LONG_SECS_2ND_FEW, IDS_TIME_LONG_SECS_2ND_MANY }, | |
149 "one{# second}", | 118 "one{# second}", |
150 " other{# seconds}" | 119 " other{# seconds}" |
151 }; | 120 }; |
152 static const Pluralities IDS_DURATION_HOUR_1ST = { | 121 static const Pluralities IDS_DURATION_HOUR_1ST = { |
153 { IDS_TIME_HOURS_1ST_DEFAULT, IDS_TIME_HOURS_1ST_SINGULAR, | 122 IDS_TIME_HOURS_1ST, |
154 IDS_TIME_HOURS_1ST_ZERO, IDS_TIME_HOURS_1ST_TWO, | 123 "one{# hour and }", |
155 IDS_TIME_HOURS_1ST_FEW, IDS_TIME_HOURS_1ST_MANY }, | 124 " other{# hours and }" |
156 "one{# hour }", | |
157 " other{# hours }" | |
158 }; | 125 }; |
159 static const Pluralities IDS_LONG_MIN_2ND = { | 126 static const Pluralities IDS_LONG_MIN_2ND = { |
160 { IDS_TIME_LONG_MINS_2ND_DEFAULT, IDS_TIME_LONG_MINS_2ND_SINGULAR, | 127 IDS_TIME_LONG_MINS_2ND, |
161 IDS_TIME_LONG_MINS_2ND_ZERO, IDS_TIME_LONG_MINS_2ND_TWO, | |
162 IDS_TIME_LONG_MINS_2ND_FEW, IDS_TIME_LONG_MINS_2ND_MANY }, | |
163 "one{# minute}", | 128 "one{# minute}", |
164 " other{# minutes}" | 129 " other{# minutes}" |
165 }; | 130 }; |
166 static const Pluralities IDS_DURATION_DAY_1ST = { | 131 static const Pluralities IDS_DURATION_DAY_1ST = { |
167 { IDS_TIME_DAYS_1ST_DEFAULT, IDS_TIME_DAYS_1ST_SINGULAR, | 132 IDS_TIME_DAYS_1ST, |
168 IDS_TIME_DAYS_1ST_ZERO, IDS_TIME_DAYS_1ST_TWO, | 133 "one{# day and }", |
169 IDS_TIME_DAYS_1ST_FEW, IDS_TIME_DAYS_1ST_MANY }, | 134 " other{# days and }" |
170 "one{# day }", | |
171 " other{# days }" | |
172 }; | 135 }; |
173 static const Pluralities IDS_DURATION_HOUR_2ND = { | 136 static const Pluralities IDS_DURATION_HOUR_2ND = { |
174 { IDS_TIME_HOURS_2ND_DEFAULT, IDS_TIME_HOURS_2ND_SINGULAR, | 137 IDS_TIME_HOURS_2ND, |
175 IDS_TIME_HOURS_2ND_ZERO, IDS_TIME_HOURS_2ND_TWO, | |
176 IDS_TIME_HOURS_2ND_FEW, IDS_TIME_HOURS_2ND_MANY }, | |
177 "one{# hour}", | 138 "one{# hour}", |
178 " other{# hours}" | 139 " other{# hours}" |
179 }; | 140 }; |
180 | 141 |
181 Formatter::Formatter(const Pluralities& sec_pluralities, | 142 Formatter::Formatter(const Pluralities& sec_pluralities, |
182 const Pluralities& min_pluralities, | 143 const Pluralities& min_pluralities, |
183 const Pluralities& hour_pluralities, | 144 const Pluralities& hour_pluralities, |
184 const Pluralities& day_pluralities) { | 145 const Pluralities& day_pluralities) { |
185 simple_format_[UNIT_SEC] = InitFormat(sec_pluralities); | 146 simple_format_[UNIT_SEC] = InitFormat(sec_pluralities); |
186 simple_format_[UNIT_MIN] = InitFormat(min_pluralities); | 147 simple_format_[UNIT_MIN] = InitFormat(min_pluralities); |
(...skipping 18 matching lines...) Expand all Loading... |
205 detailed_format_[TWO_UNITS_MIN_SEC][0] = InitFormat(min_sec_pluralities1); | 166 detailed_format_[TWO_UNITS_MIN_SEC][0] = InitFormat(min_sec_pluralities1); |
206 detailed_format_[TWO_UNITS_MIN_SEC][1] = InitFormat(min_sec_pluralities2); | 167 detailed_format_[TWO_UNITS_MIN_SEC][1] = InitFormat(min_sec_pluralities2); |
207 detailed_format_[TWO_UNITS_HOUR_MIN][0] = InitFormat(hour_min_pluralities1); | 168 detailed_format_[TWO_UNITS_HOUR_MIN][0] = InitFormat(hour_min_pluralities1); |
208 detailed_format_[TWO_UNITS_HOUR_MIN][1] = InitFormat(hour_min_pluralities2); | 169 detailed_format_[TWO_UNITS_HOUR_MIN][1] = InitFormat(hour_min_pluralities2); |
209 detailed_format_[TWO_UNITS_DAY_HOUR][0] = InitFormat(day_hour_pluralities1); | 170 detailed_format_[TWO_UNITS_DAY_HOUR][0] = InitFormat(day_hour_pluralities1); |
210 detailed_format_[TWO_UNITS_DAY_HOUR][1] = InitFormat(day_hour_pluralities2); | 171 detailed_format_[TWO_UNITS_DAY_HOUR][1] = InitFormat(day_hour_pluralities2); |
211 } | 172 } |
212 | 173 |
213 void Formatter::Format(Unit unit, | 174 void Formatter::Format(Unit unit, |
214 int value, | 175 int value, |
215 icu::UnicodeString& formatted_string) const { | 176 icu::UnicodeString* formatted_string) const { |
216 DCHECK(simple_format_[unit]); | 177 DCHECK(simple_format_[unit]); |
| 178 DCHECK(formatted_string->isEmpty() == TRUE); |
217 UErrorCode error = U_ZERO_ERROR; | 179 UErrorCode error = U_ZERO_ERROR; |
218 formatted_string = simple_format_[unit]->format(value, error); | 180 l10n_util::FormatNumberInPlural(*simple_format_[unit], |
| 181 value, formatted_string, &error); |
219 DCHECK(U_SUCCESS(error)) << "Error in icu::PluralFormat::format()."; | 182 DCHECK(U_SUCCESS(error)) << "Error in icu::PluralFormat::format()."; |
220 return; | 183 return; |
221 } | 184 } |
222 | 185 |
223 void Formatter::Format(TwoUnits units, | 186 void Formatter::Format(TwoUnits units, |
224 int value_1, | 187 int value_1, |
225 int value_2, | 188 int value_2, |
226 icu::UnicodeString& formatted_string) const { | 189 icu::UnicodeString* formatted_string) const { |
227 DCHECK(detailed_format_[units][0]) | 190 DCHECK(detailed_format_[units][0]) |
228 << "Detailed() not implemented for your (format, length) combination!"; | 191 << "Detailed() not implemented for your (format, length) combination!"; |
229 DCHECK(detailed_format_[units][1]) | 192 DCHECK(detailed_format_[units][1]) |
230 << "Detailed() not implemented for your (format, length) combination!"; | 193 << "Detailed() not implemented for your (format, length) combination!"; |
| 194 DCHECK(formatted_string->isEmpty() == TRUE); |
231 UErrorCode error = U_ZERO_ERROR; | 195 UErrorCode error = U_ZERO_ERROR; |
232 formatted_string = detailed_format_[units][0]->format(value_1, error); | 196 l10n_util::FormatNumberInPlural(*detailed_format_[units][0], value_1, |
| 197 formatted_string, &error); |
233 DCHECK(U_SUCCESS(error)); | 198 DCHECK(U_SUCCESS(error)); |
234 formatted_string += detailed_format_[units][1]->format(value_2, error); | 199 l10n_util::FormatNumberInPlural(*detailed_format_[units][1], value_2, |
| 200 formatted_string, &error); |
235 DCHECK(U_SUCCESS(error)); | 201 DCHECK(U_SUCCESS(error)); |
236 return; | 202 return; |
237 } | 203 } |
238 | 204 |
239 scoped_ptr<icu::PluralFormat> Formatter::CreateFallbackFormat( | 205 scoped_ptr<icu::MessageFormat> Formatter::CreateFallbackFormat( |
240 const icu::PluralRules& rules, | 206 const icu::PluralRules& rules, |
241 const Pluralities& pluralities) const { | 207 const Pluralities& pluralities) const { |
242 icu::UnicodeString pattern; | 208 icu::UnicodeString pattern("{NUMBER, plural, "); |
243 if (rules.isKeyword(UNICODE_STRING_SIMPLE("one"))) | 209 if (rules.isKeyword(UNICODE_STRING_SIMPLE("one"))) |
244 pattern += icu::UnicodeString(pluralities.fallback_one); | 210 pattern += icu::UnicodeString(pluralities.fallback_one); |
245 pattern += icu::UnicodeString(pluralities.fallback_other); | 211 pattern += icu::UnicodeString(pluralities.fallback_other); |
| 212 pattern.append(UChar(0x7du)); // "}" = U+007D |
246 | 213 |
247 UErrorCode error = U_ZERO_ERROR; | 214 UErrorCode error = U_ZERO_ERROR; |
248 scoped_ptr<icu::PluralFormat> format( | 215 scoped_ptr<icu::MessageFormat> format( |
249 new icu::PluralFormat(rules, pattern, error)); | 216 new icu::MessageFormat(pattern, error)); |
250 DCHECK(U_SUCCESS(error)); | 217 DCHECK(U_SUCCESS(error)); |
251 return format.Pass(); | 218 return format.Pass(); |
252 } | 219 } |
253 | 220 |
254 scoped_ptr<icu::PluralFormat> Formatter::InitFormat( | 221 scoped_ptr<icu::MessageFormat> Formatter::InitFormat( |
255 const Pluralities& pluralities) { | 222 const Pluralities& pluralities) { |
256 if (!formatter_force_fallback) { | 223 if (!formatter_force_fallback) { |
257 icu::UnicodeString pattern; | 224 base::string16 pattern = l10n_util::GetStringUTF16(pluralities.id); |
258 std::vector<int> ids; | 225 UErrorCode error = U_ZERO_ERROR; |
259 for (size_t j = 0; j < kNumberPluralities; ++j) | 226 scoped_ptr<icu::MessageFormat> format(new icu::MessageFormat( |
260 ids.push_back(pluralities.ids[j]); | 227 icu::UnicodeString(FALSE, pattern.data(), pattern.length()), error)); |
261 scoped_ptr<icu::PluralFormat> format = l10n_util::BuildPluralFormat(ids); | 228 DCHECK(U_SUCCESS(error)); |
262 if (format.get()) | 229 if (format.get()) |
263 return format.Pass(); | 230 return format.Pass(); |
264 } | 231 } |
265 | 232 |
266 scoped_ptr<icu::PluralRules> rules(l10n_util::BuildPluralRules()); | 233 scoped_ptr<icu::PluralRules> rules(l10n_util::BuildPluralRules()); |
267 return CreateFallbackFormat(*rules, pluralities); | 234 return CreateFallbackFormat(*rules, pluralities); |
268 } | 235 } |
269 | 236 |
270 const Formatter* FormatterContainer::Get(TimeFormat::Format format, | 237 const Formatter* FormatterContainer::Get(TimeFormat::Format format, |
271 TimeFormat::Length length) const { | 238 TimeFormat::Length length) const { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 | 285 |
319 void FormatterContainer::Shutdown() { | 286 void FormatterContainer::Shutdown() { |
320 for (int format = 0; format < TimeFormat::FORMAT_COUNT; ++format) { | 287 for (int format = 0; format < TimeFormat::FORMAT_COUNT; ++format) { |
321 for (int length = 0; length < TimeFormat::LENGTH_COUNT; ++length) { | 288 for (int length = 0; length < TimeFormat::LENGTH_COUNT; ++length) { |
322 formatter_[format][length].reset(); | 289 formatter_[format][length].reset(); |
323 } | 290 } |
324 } | 291 } |
325 } | 292 } |
326 | 293 |
327 } // namespace ui | 294 } // namespace ui |
OLD | NEW |