Localizing numbers and dates
It is possible to define a localized numbering sequence for use by
This sequence will be used when
you specify a language in the
lang attribute of the
element, or in the third argument of the functions
format-dateTime(). The feature is primarily
intended to provide language-dependent numbers and dates, but in fact it can be used to
provide arbitrary numbering sequences.
For Saxon-PE/EE from version 9.6 the repertoire of supported languages for numbering and dates can be extended (or replaced) by the use of facilities from ICU - International Components for Unicode, as described in Numbers and Dates from ICU.
The numbering sequence for English is used by default if no other can be loaded.
Additional numbering sequences are available as described in Numberings for selected languages.
To implement a numberer for language X, you need to define a class that implements the
Numberer; usually it will
be convenient to write the class as a subclass of the supplied
Normally your localization class will extend the class
that you can reuse functionality like roman numerals which do not need to be localized.
Alternatively, if you only want to modify the existing English localization, you could
choose to implement a subclass of
You can override any of the non-private methods in the base class, but the most useful ones to implement are the following:
Supplies a suffix to be appended to a number to create the ordinal form, for example "1" becomes "1st" in English
Displays a number in words, in title case: for example "53" becomes "Fifty Three" in English
Displays an ordinal number in words, in title case: for example "53" becomes "Fifty Third" in English
Displays the name of a month, optionally abbreviated
Displays the name of a day of the week, optionally abbreviated
The class name can be anything you like, but by convention the Numberer for language LL is
The way that the numberer is registered with the Saxon
Configuration differs between
Saxon-HE on the one hand, and Saxon-PE/EE on the other. On Saxon-HE, you need to supply a
LocalizerFactory that responds to the request for a particular language, for
You can also use this mechanism on Saxon-PE/EE, but an alternative is to register the localization module in the configuration file.
If you write a comprehensive
Numberer for a particular language, please
submit it, and we will be happy to include it in future versions of the product as an
open-source component. You must agree to release it under the Mozilla Public License or
under any other recognized open source license that Saxon might adopt in the future.