Skip to main content
Version: 1.3.0

Ordinal

Arithmetic Internationalization

Synopsis

Converts numbers to ordinal format in multiple languages.

Schema

- ordinal:
field: <ident>
target_field: <string>
language: <string>
format: <string>
case: <string>
date_format: <string>
gender: <string>
superscript: <boolean>
space_before_suffix: <boolean>
description: <text>
if: <script>
ignore_failure: <boolean>
ignore_missing: <boolean>
on_failure: <processor[]>
on_success: <processor[]>
tag: <string>

Configuration

The following fields are used to define the processor:

FieldRequiredDefaultDescription
fieldY-Source field containing number or date to convert
target_fieldNSame as fieldTarget field to store ordinal result
languageNenLanguage code (en, es, fr, de, it, pt, nl, ru, ja, zh)
formatNsuffixOutput format (suffix, word, both, number_suffix)
caseNlowerText case (lower, upper, title, sentence)
date_formatN-Custom date format with ordinals using {day} placeholder
genderN-Gender for languages with gender (masculine, feminine, neuter)
superscriptNfalseOutput ordinal suffix with HTML superscript tags
space_before_suffixNfalseAdd space before ordinal suffix
descriptionN-Explanatory note
ifN-Condition to run
ignore_failureNfalseContinue processing if conversion fails
ignore_missingNfalseSkip processing if referenced field doesn't exist
on_failureN-See Handling Failures
on_successN-See Handling Success
tagN-Identifier

Details

Converts numeric values to ordinal representations supporting multiple languages and output formats. The processor handles both individual numbers and numbers embedded within strings.

The processor supports ten languages with proper linguistic rules for ordinal formation. For gendered languages like Spanish, French, Italian, and Portuguese, the gender parameter affects the ordinal suffix and word forms.

note

Languages use different ordinal conventions: English uses suffixes (1st, 2nd, 3rd), Romance languages use degree symbols (1º, 2ª), Germanic languages use periods (1.), and Asian languages use prefixes (第1, 1番目).

The processor can output ordinals in various formats: numeric with suffix (21st), word form (twenty-first), or both (21st (twenty-first)). For date formatting, use the special \{day\} placeholder to insert ordinal day numbers into custom date templates.

warning

When processing strings containing multiple numbers, all numeric values in the text will be converted to ordinals. Use field isolation if you need to convert only specific numbers.

Examples

Basic Number Ordinals

Converting numbers to English ordinals...

{
"position": 23
}
- ordinal:
field: position
target_field: position_ordinal
format: suffix

creates ordinal form:

{
"position": 23,
"position_ordinal": "23rd"
}

Spanish Gendered Ordinals

Using Spanish feminine ordinals...

{
"floor": 3
}
- ordinal:
field: floor
language: es
gender: feminine
format: both
target_field: floor_description

generates Spanish feminine ordinal:

{
"floor": 3,
"floor_description": "3ª (tercera)"
}

Date Formatting with Ordinals

Creating ordinal date format using custom template...

{
"event_date": "2024-01-15T10:30:00Z"
}
- ordinal:
field: event_date
date_format: "Day: 15th of January, 2024"
target_field: formatted_date
case: title

formats with ordinal day:

{
"event_date": "2024-01-15T10:30:00Z",
"formatted_date": "Day: 15th Of January, 2024"
}

Word Form Ordinals

Converting to word form ordinals...

{
"rank": 1
}
- ordinal:
field: rank
format: word
case: title
target_field: rank_word

creates word form:

{
"rank": 1,
"rank_word": "First"
}

Superscript HTML Format

Generating HTML superscript ordinals...

{
"place": 42
}
- ordinal:
field: place
superscript: true
space_before_suffix: true
target_field: html_ordinal

outputs HTML formatted ordinal:

{
"place": 42,
"html_ordinal": "42<sup>nd</sup>"
}

Multi-Language Processing

Processing French ordinals with proper formatting...

{
"chapter": 21
}
- ordinal:
field: chapter
language: fr
format: suffix
case: lower
target_field: chapitre

generates French ordinal:

{
"chapter": 21,
"chapitre": "21ᵉ"
}

String Number Conversion

Converting numbers within text strings...

{
"message": "User completed level 5 on attempt 3"
}
- ordinal:
field: message
target_field: ordinal_message

converts embedded numbers:

{
"message": "User completed level 5 on attempt 3",
"ordinal_message": "User completed level 5th on attempt 3rd"
}