Ordinal numbers |
Most languages have a concept of ordinal numbers. When you use the ordinal number, you don't use the number but either write the number figure and an ending (short form) or spell out the number (long form). The following table contains English and Finnish ordinals from 1 to 5:
Number | English short | English long | Finnish short | Finnish long |
---|---|---|---|---|
1 | 1st | first | 1. |
ensimmäinen |
2 | 2nd | second | 2. | toinen |
3 | 3rd | third | 3. | kolmas |
4 | 4th | fourth | 4. | neljäs |
5 | 5th | fifth | 5. | viides |
When we create the ordinal, there are other properties that may affect how to ordinal is written. Such properties are plurals and genders. In some languages, the result is different on singular and plurals. For example, in Finnish, the plural ordinals are different.
Short | Long singular | Long plural |
---|---|---|
1. |
ensimmäinen |
ensimmäiset |
2. | toinen | toiset |
3. | kolmas | kolmannet |
4. | neljäs | neljännet |
5. | viides | viidennet |
In some languages, gender affects how to write ordinals. For example, in German, the ordinals depend on the gender of the word.
Short | Generic long | Long neutral singular | Long female singular | Long male singular | Long plural |
---|---|---|---|---|---|
1. |
erstes |
erstes |
erste |
erster |
ersten |
2. | zweitens | zweites | zweite | zweiter | zweiten |
3. | drittens | drittes | dritte | dritter | dritten |
4. | viertens | viertens | viertens | viertens | viertens |
5. | fünftens | fünftens | fünftens | fünftens | fünftens |
When we get ordinals as a string with all these variations, we need to tell the API the ordinal number and the plural and gender forms. Ordinal API provides functions to convert a number into a string containing localized ordinal numbers in short (i.e., figure + ending) or in long (spelled out) form. The generic format of the API is
Ordinal.Format(form, ordinal, plural, gender): string;
It takes three parameters: short or long-form, ordinal number, plural form (e.g., singular or plural), gender form (e.g., male, female), and returns a string.
Hardly any platform contains built-in support for ordinal numbers. The most platform requires that you use our custom API. The following table shows how various platforms support ordinals:
Platforms | Status | APIs | Samples |
---|---|---|---|
.NET Standard | yes | <data-dir>\Library\NET\Ordinal.cs | <data-dir>\Samples\ASP.NET\Ordinal |
Android | yes | <data-dir>\Library\Java\Ordinal.java | |
Angular | yes | <data-dir>\Library\Angular\ordinal.pipe.ts | <data-dir>\Samples\Angular\Ordinal |
Delphi | yes | <data-dir>\Library\Delphi\NtOrdinal.pas | <data-dir>\Samples\Delphi\VCL\Ordinal <data-dir>\Samples\Delphi\FMX\Ordinal |
Java | yes | <data-dir>\Library\Java\Ordinal.java | |
JavaScript | yes | <data-dir>\Library\JavaScript\ordinal.js | |
PHP | built-in | ||
TypeScript | yes | <data-dir>\Library\TypeScript\ordinal.ts | See the Angular sample. |
yes means that we have implemented an open-source API. To use the open-source API, include the plural API file into your project and start using the API. To see how to use the API, see the provided plural samples at <data-dir>\Samples\<platform>\Pattern directory.
built-in means that the standard API of the platform supports the feature. Only Angular has a built-in solution that matches Soluling API. Other platforms provide built-in support for plural parameters and/or gender but do not have a solution for multiple parameters or select. If your platform does not have built-in support and Soluling's API does not support it, you can easily write your own by viewing the implementation of one of the APIs we provide.