SelectOrdinal
SelectOrdinal is the Component Macro counterpart to the core selectOrdinal macro.
It is useful when ordinal cases belong directly in template markup and the component form is easier to maintain than a function call.
Standard ICU plural categories (one, two, few, many, other) are used as plain prop
names. Exact-value matches use an underscore-prefixed number: _1="1st" matches exactly when
value is 1, taking precedence over the category props. This is useful for irregular ordinals
that do not map cleanly to a category in all locales.
For the framework-agnostic Lingui semantics, see the
official SelectOrdinal reference.
<p>
<SelectOrdinal value={place} one="#st" two="#nd" few="#rd" other="#th" />
</p> 1st
<script lang="ts"> import { SelectOrdinal } from "lingui-for-svelte/macro";
let place = $state(1);</script>
<SelectOrdinal value={place} one="#st" two="#nd" few="#rd" other="#th" />---import { SelectOrdinal } from "lingui-for-astro/macro";
const place = 1;---
<SelectOrdinal value={place} one="#st" two="#nd" few="#rd" other="#th" />import { SelectOrdinal } from "@lingui/react/macro";
function Component() { return ( <SelectOrdinal value={place} one="#st" two="#nd" few="#rd" other="#th" /> );}Exact value match
Section titled “Exact value match”Prefix a number with _ to match an exact value. Exact matches take precedence over category
props.
<SelectOrdinal value={place} _1="1st" _2="2nd" _3="3rd" other="#th" />The function form uses plain numeric keys for the same effect:
<p>{$selectOrdinal(place, { 1: '1st', 2: '2nd', 3: '3rd', other: '#th' })}</p>When SelectOrdinal is a good fit
Section titled “When SelectOrdinal is a good fit”- ordinal branches belong naturally in template markup
- the component form is clearer than
selectOrdinal(...) - you want authoring symmetry with
PluralandSelect