You are currently viewing a snapshot of www.mozilla.org taken on April 21, 2008. Most of this content is highly out of date (some pages haven't been updated since the project began in 1998) and exists for historical purposes only. If there are any pages on this archive site that you think should be added back to www.mozilla.org, please file a bug.



message formatting
by Erik van der Poel <erik@netscape.com>
Last Modified: 1/24/2001

Introduction

Programmers often compose sentences from smaller pieces using mechanisms such as C's printf family of functions. Since sentence syntax is highly dependent on human language, it is necessary to vary the order in which Subject, Verb and Object appear in the sentence.

How to do this in Mozilla

Use nsTextFormatter. You can find examples of this in the sources. Use LXR to find examples. Here is an example of a string with ordered arguments:

    "There are %1$d files in directory %2$s."