• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Localization and plural rules revisited
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Localization and plural rules revisited


  • Subject: Re: Localization and plural rules revisited
  • From: "Stephen F. Booth" <email@hidden>
  • Date: Tue, 20 May 2008 08:09:28 -0700

I would recommend using ICU (http://icu-project.org) for more advanced localization options. In particular have a look at the MessageFormat and ChoiceFormat classes.

For example, here is an ICU code snippet for formatting a string representing the number of files on a disk:

UErrorCode success = U_ZERO_ERROR;
MessageFormat* form("The disk \"{1}\" contains {0}.", success);
double filelimits[] = {0,1,2};
UnicodeString filepart[] = {"no files","one file","{0,number} files"};
ChoiceFormat* fileform = new ChoiceFormat(filelimits, filepart, 3);
form.setFormat(1, *fileform); // NOT zero, see below

Formattable testArgs[] = {1273L, "MyDisk"};

UnicodeString string;
FieldPosition fpos = 0;
cout << form.format(testArgs, 2, string, fpos, success) << endl;

     // output, with different testArgs
     // output: The disk "MyDisk" contains no files.
     // output: The disk "MyDisk" contains one file.
     // output: The disk "MyDisk" contains 1,273 files.

(from http://icu-project.org/apiref/icu4c/classMessageFormat.html)

Stephen
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: NSApp with wrong _running count
  • Next by Date: Re: Problem with updating NSProgressIndicator
  • Previous by thread: Re: Localization and plural rules revisited
  • Next by thread: Re: Localization and plural rules revisited
  • Index(es):
    • Date
    • Thread