Cardinalities
-
CARDINALITY_ONE
Matches
i = 0,1Example Integers:
0, 1Example Decimals:
0.0, 1.5 -
CARDINALITY_MANY
Matches
e = 0 and i != 0 and i % 1000000 = 0 and v = 0 or e != 0..5Example Integers:
1000000, … -
CARDINALITY_OTHER
Matches
all other valuesExample Integers:
2, 17, 100, 1000, 10000, 100000, …Example Decimals:
2.0, 3.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
Cardinality example
This localized strings file selects the localized form of “day” for a delivery estimate. Raw numbers choose the CLDR category; values formatted with the JDK NumberFormat are interpolated for display.
Sample localized strings file
{ "Delivery.LeadTime": { "commentary": "Estimated delivery time, expressed in days.", "translation": "{{leadTime}}", "placeholders": { "leadTime": { "value": "dayCount", "translations": { "CARDINALITY_ONE": "{{formattedDayCount}} jour", "CARDINALITY_MANY": "{{formattedDayCount}} jours", "CARDINALITY_OTHER": "{{formattedDayCount}} jours" } } } } }
Usage and expected results
The Java code passes each raw number for cardinality selection and formats its display value separately with NumberFormat. The exact-tag 1,000,000 assertion records JDK 26 output; older JDK locale data can differ.
Locale locale = Locale.forLanguageTag("fr-CA"); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); // Raw numbers select language forms; NumberFormat produces the display values // CARDINALITY_ONE Number oneDayCount = 0; String oneFormattedDayCount = numberFormat.format(oneDayCount); // Expected: 0<NBSP>jour // U+00A0 NO-BREAK SPACE preserves exact nonbreaking spacing from localized source text or locale formatting assertEquals(oneFormattedDayCount + "\u00A0jour", strings.get( "Delivery.LeadTime", Map.of("dayCount", oneDayCount, "formattedDayCount", oneFormattedDayCount) )); // CARDINALITY_MANY Number manyDayCount = 1_000_000; String manyFormattedDayCount = numberFormat.format(manyDayCount); // Expected: 1<NBSP>000<NBSP>000<NBSP>jours assertEquals(manyFormattedDayCount + "\u00A0jours", strings.get( "Delivery.LeadTime", Map.of("dayCount", manyDayCount, "formattedDayCount", manyFormattedDayCount) )); // CARDINALITY_OTHER Number otherDayCount = 2; String otherFormattedDayCount = numberFormat.format(otherDayCount); // Expected: 2<NBSP>jours assertEquals(otherFormattedDayCount + "\u00A0jours", strings.get( "Delivery.LeadTime", Map.of("dayCount", otherDayCount, "formattedDayCount", otherFormattedDayCount) )); // Exact-tag formatting sample Number localeProfileDayCount = 1_000_000; String localeProfileFormattedDayCount = numberFormat.format(localeProfileDayCount); assertEquals("1\u00A0000\u00A0000", localeProfileFormattedDayCount); assertEquals(Cardinality.MANY, Cardinality.forNumber(localeProfileDayCount, locale)); // Expected: 1<NBSP>000<NBSP>000<NBSP>jours assertEquals(localeProfileFormattedDayCount + "\u00A0jours", strings.get( "Delivery.LeadTime", Map.of("dayCount", localeProfileDayCount, "formattedDayCount", localeProfileFormattedDayCount) ));
Cardinality Ranges
These are CLDR's explicit range mappings. For any start/end pair not listed, Cardinality.forRange(...) falls back to the ending cardinality.
-
CARDINALITY_ONE - CARDINALITY_ONE
Matches
CARDINALITY_ONE -
CARDINALITY_ONE - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_OTHER - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER
Cardinality range example
The start and end cardinalities select the locale's CLDR range result. The selected form wraps a separately formatted display range.
Sample localized strings file
{ "Delivery.Window": { "commentary": "Estimated delivery window, expressed as a range of days.", "translation": "{{window}}", "placeholders": { "window": { "range": { "start": "minDays", "end": "maxDays" }, "translations": { "CARDINALITY_ONE": "{{formattedDayRange}} jour", "CARDINALITY_MANY": "{{formattedDayRange}} jours", "CARDINALITY_OTHER": "{{formattedDayRange}} jours" } } } } }
Usage and expected results
The Java code passes raw range endpoints for selection. Because NumberFormat formats one number at a time, it formats both endpoints separately and joins them for display; choose range punctuation appropriate to your application.
Locale locale = Locale.forLanguageTag("fr-CA"); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); // Raw numbers select language forms; NumberFormat produces the display values // CARDINALITY_ONE range Number minDays = 0; String formattedMinDays = numberFormat.format(minDays); Number maxDays = 1; String formattedMaxDays = numberFormat.format(maxDays); String formattedDayRange = formattedMinDays + "-" + formattedMaxDays; assertEquals(Cardinality.ONE, Cardinality.forRange( Cardinality.forNumber(minDays, locale), Cardinality.forNumber(maxDays, locale), locale )); // Expected: 0-1<NBSP>jour // U+00A0 NO-BREAK SPACE preserves exact nonbreaking spacing from localized source text or locale formatting assertEquals(formattedDayRange + "\u00A0jour", strings.get( "Delivery.Window", Map.of("minDays", minDays, "maxDays", maxDays, "formattedDayRange", formattedDayRange) ));
Ordinalities
-
ORDINALITY_ONE
Matches
n = 1Example Integers:
1 -
ORDINALITY_OTHER
Matches
all other valuesExample Integers:
0, 2, 16, 100, 1000, 10000, 100000, 1000000, …
Ordinality example
This localized strings example uses complete CLDR minimal-pair patterns to demonstrate every Ordinality category defined for the locale.
Source: Unicode CLDR 48.2 fr locale data.
Sample localized strings file
{ "Ordinal.MinimalPair": { "commentary": "Demonstrates every CLDR ordinal category defined for this locale.", "translation": "{{ordinalExample}}", "placeholders": { "ordinalExample": { "value": "ordinalValue", "translations": { "ORDINALITY_ONE": "Prenez la {{formattedOrdinalValue}}re à droite.", "ORDINALITY_OTHER": "Prenez la {{formattedOrdinalValue}}e à droite." } } } } }
Usage and expected results
The Java code passes each raw number to Ordinality.forNumber(...) and formats its display value separately with NumberFormat.
Locale locale = Locale.forLanguageTag("fr-CA"); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); // Raw numbers select language forms; NumberFormat produces the display values // ORDINALITY_ONE Number oneOrdinalValue = 1; String oneFormattedOrdinalValue = numberFormat.format(oneOrdinalValue); assertEquals(Ordinality.ONE, Ordinality.forNumber(oneOrdinalValue, locale)); // Expected: Prenez la 1re à droite. assertEquals("Prenez la " + oneFormattedOrdinalValue + "re à droite.", strings.get( "Ordinal.MinimalPair", Map.of("ordinalValue", oneOrdinalValue, "formattedOrdinalValue", oneFormattedOrdinalValue) )); // ORDINALITY_OTHER Number otherOrdinalValue = 2; String otherFormattedOrdinalValue = numberFormat.format(otherOrdinalValue); assertEquals(Ordinality.OTHER, Ordinality.forNumber(otherOrdinalValue, locale)); // Expected: Prenez la 2e à droite. assertEquals("Prenez la " + otherFormattedOrdinalValue + "e à droite.", strings.get( "Ordinal.MinimalPair", Map.of("ordinalValue", otherOrdinalValue, "formattedOrdinalValue", otherFormattedOrdinalValue) ));
Language-Specific Examples
These examples show how Lokalized models grammatical choices and translation behavior that commonly affect Canadian French application copy. Each example identifies the Lokalized language forms and other library features it uses.
Customer status by gender
French customer labels and predicate adjectives agree in gender, producing client actif for masculine and cliente active for feminine.
Language references: OQLF: client actif, cliente active, OQLF: subject-complement adjective agreement
Lokalized forms used: Gender
Sample localized strings file
{ "The customer is active.": { "translation": "{{customer}} est {{active}}.", "placeholders": { "customer": { "value": "gender", "translations": { "GENDER_MASCULINE": "Le client", "GENDER_FEMININE": "La cliente" } }, "active": { "value": "gender", "translations": { "GENDER_MASCULINE": "actif", "GENDER_FEMININE": "active" } } } } }
Usage and expected results
Locale locale = Locale.forLanguageTag("fr-CA"); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); assertEquals("Le client est actif.", strings.get( "The customer is active.", Map.of("gender", Gender.MASCULINE) )); assertEquals("La cliente est active.", strings.get( "The customer is active.", Map.of("gender", Gender.FEMININE) ));
Definite-article elision by phonetic onset
French elides le or la before a vowel or h muet, but retains the full article before h aspiré; these forms cover common application content and navigation labels.
Language references: OQLF: elision before vowels, h muet, and h aspiré, OQLF: h muet pronunciation and elision
Lokalized forms used: Phonetic
Sample localized strings file
{ "Display {{content}}.": { "translation": "Affichez {{content}}.", "placeholders": { "content": { "value": "content", "translations": { "PHONETIC_VOWEL": "l’aperçu", "PHONETIC_H_SILENT": "l’historique", "PHONETIC_H_ASPIRATED": "le haut de la page" } } } } }
The application-provided resolver classifies each raw term at runtime. Its small lookup map stands in for application-specific pronunciation logic or a lexicon.
Usage and expected results
Locale locale = Locale.forLanguageTag("fr-CA"); Map<String, Phonetic> phoneticsByTerm = Map.ofEntries( Map.entry("aperçu", Phonetic.VOWEL), Map.entry("historique", Phonetic.H_SILENT), Map.entry("haut de la page", Phonetic.H_ASPIRATED) ); PhoneticResolver phoneticResolver = (term, ignoredLocale) -> phoneticsByTerm.getOrDefault(term, Phonetic.OTHER); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .phoneticResolver(phoneticResolver) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); // U+2019 RIGHT SINGLE QUOTATION MARK preserves the punctuation used by the localized source text assertEquals("Affichez l\u2019aperçu.", strings.get( "Display {{content}}.", Map.of("content", "aperçu") )); assertEquals("Affichez l\u2019historique.", strings.get( "Display {{content}}.", Map.of("content", "historique") )); assertEquals("Affichez le haut de la page.", strings.get( "Display {{content}}.", Map.of("content", "haut de la page") ));
Addendum: Language Form Rules
The language form expressions above are specified by Unicode Technical Standard #35 and use the following notation:
nabsolute value of the source number (integer and decimals)iinteger digits ofnvnumber of visible fraction digits inn, with trailing zeroswnumber of visible fraction digits inn, without trailing zerosfvisible fractional digits inn, with trailing zerostvisible fractional digits inn, without trailing zerosc/ecompact decimal exponent operands used by some CLDR compact-number rules