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

Side by Side Diff: pkg/intl/lib/intl.dart

Issue 167943005: Fix the obscure corner case of three items in a plural (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/intl/test/message_extraction/sample_with_messages.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * This library provides internationalization and localization. This includes 6 * This library provides internationalization and localization. This includes
7 * message formatting and replacement, date and number formatting and parsing, 7 * message formatting and replacement, date and number formatting and parsing,
8 * and utilities for working with Bidirectional text. 8 * and utilities for working with Bidirectional text.
9 * 9 *
10 * This is part of the [intl package] 10 * This is part of the [intl package]
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 if (other == null) { 263 if (other == null) {
264 throw new ArgumentError("The 'other' named argument must be provided"); 264 throw new ArgumentError("The 'other' named argument must be provided");
265 } 265 }
266 // TODO(alanknight): This algorithm needs to be locale-dependent. 266 // TODO(alanknight): This algorithm needs to be locale-dependent.
267 switch (howMany) { 267 switch (howMany) {
268 case 0 : return (zero == null) ? other : zero; 268 case 0 : return (zero == null) ? other : zero;
269 case 1 : return (one == null) ? other : one; 269 case 1 : return (one == null) ? other : one;
270 case 2: return (two == null) ? ((few == null) ? other : few) : two; 270 case 2: return (two == null) ? ((few == null) ? other : few) : two;
271 default: 271 default:
272 if (howMany == 3 || howMany == 4 && few != null) return few; 272 if ((howMany == 3 || howMany == 4) && few != null) return few;
273 if (howMany > 10 && howMany < 100 && many != null) return many; 273 if (howMany > 10 && howMany < 100 && many != null) return many;
274 return other; 274 return other;
275 } 275 }
276 throw new ArgumentError("Invalid plural usage for $howMany"); 276 throw new ArgumentError("Invalid plural usage for $howMany");
277 } 277 }
278 278
279 /** 279 /**
280 * Format a message differently depending on [targetGender]. Normally used as 280 * Format a message differently depending on [targetGender]. Normally used as
281 * part of an Intl.message message that is to be translated. 281 * part of an Intl.message message that is to be translated.
282 */ 282 */
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 * unless for some reason this gets called inside a message that resets the 360 * unless for some reason this gets called inside a message that resets the
361 * locale. 361 * locale.
362 */ 362 */
363 static String getCurrentLocale() { 363 static String getCurrentLocale() {
364 if (defaultLocale == null) defaultLocale = systemLocale; 364 if (defaultLocale == null) defaultLocale = systemLocale;
365 return defaultLocale; 365 return defaultLocale;
366 } 366 }
367 367
368 toString() => "Intl($locale)"; 368 toString() => "Intl($locale)";
369 } 369 }
OLDNEW
« no previous file with comments | « no previous file | pkg/intl/test/message_extraction/sample_with_messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698