Cardinalities
-
CARDINALITY_ZERO
Matches
n = 0Example Integers:
0Example Decimals:
0.0, 0.00, 0.000, 0.0000 -
CARDINALITY_ONE
Matches
n = 1Example Integers:
1Example Decimals:
1.0, 1.00, 1.000, 1.0000 -
CARDINALITY_TWO
Matches
n = 2Example Integers:
2Example Decimals:
2.0, 2.00, 2.000, 2.0000 -
CARDINALITY_FEW
Matches
n % 100 = 3..10Example Integers:
3, 10, 103, 110, 1003, …Example Decimals:
3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, … -
CARDINALITY_MANY
Matches
n % 100 = 11..99Example Integers:
11, 26, 111, 1011, …Example Decimals:
11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, … -
CARDINALITY_OTHER
Matches
all other valuesExample Integers:
100, 102, 200, 202, 300, 302, 400, 402, 500, 502, 600, 1000, 10000, 100000, 1000000, …Example Decimals:
0.1, 0.9, 1.1, 1.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …
Cardinality example
This localized strings example uses complete, page-local CLDR minimal-pair patterns to demonstrate every Cardinality category defined for the locale. Minimal-pair text contrasts grammatical forms; it is language-reference data, not reusable application copy.
Source: Unicode CLDR 48.2 ar locale data.
Sample localized strings file
{ "Cardinality.MinimalPair": { "commentary": "Demonstrates every CLDR cardinal category defined for this locale.", "translation": "{{cardinalityExample}}", "placeholders": { "cardinalityExample": { "value": "cardinalityValue", "translations": { "CARDINALITY_ZERO": "{{formattedCardinalityValue}} ولد حضر", "CARDINALITY_ONE": "ولد واحد حضر", "CARDINALITY_TWO": "ولدان حضرا", "CARDINALITY_FEW": "{{formattedCardinalityValue}} أولاد حضروا", "CARDINALITY_MANY": "{{formattedCardinalityValue}} ولدًا حضروا", "CARDINALITY_OTHER": "{{formattedCardinalityValue}} ولد حضروا" } } } } }
Usage and expected results
The Java code passes each raw number for cardinality selection and formats its display value separately with NumberFormat. For this right-to-left locale, Lokalized's default BidiIsolation.RTL_LOCALES wraps caller-supplied formatted values with U+2068 FIRST STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE; the expected expressions below show those escapes.
Locale locale = Locale.forLanguageTag("ar"); 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_ZERO Number zeroCardinalityValue = 0; String zeroFormattedCardinalityValue = numberFormat.format(zeroCardinalityValue); assertEquals(Cardinality.ZERO, Cardinality.forNumber(zeroCardinalityValue, locale)); // Expected: <FSI>0<PDI> ولد حضر // U+2068 FIRST STRONG ISOLATE begins bidirectional isolation around a caller-supplied value in right-to-left text // U+2069 POP DIRECTIONAL ISOLATE ends bidirectional isolation around a caller-supplied value in right-to-left text assertEquals("\u2068" + zeroFormattedCardinalityValue + "\u2069 ولد حضر", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", zeroCardinalityValue, "formattedCardinalityValue", zeroFormattedCardinalityValue ) )); // CARDINALITY_ONE Number oneCardinalityValue = 1; String oneFormattedCardinalityValue = numberFormat.format(oneCardinalityValue); assertEquals(Cardinality.ONE, Cardinality.forNumber(oneCardinalityValue, locale)); assertEquals("ولد واحد حضر", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", oneCardinalityValue, "formattedCardinalityValue", oneFormattedCardinalityValue ) )); // CARDINALITY_TWO Number twoCardinalityValue = 2; String twoFormattedCardinalityValue = numberFormat.format(twoCardinalityValue); assertEquals(Cardinality.TWO, Cardinality.forNumber(twoCardinalityValue, locale)); assertEquals("ولدان حضرا", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", twoCardinalityValue, "formattedCardinalityValue", twoFormattedCardinalityValue ) )); // CARDINALITY_FEW Number fewCardinalityValue = 3; String fewFormattedCardinalityValue = numberFormat.format(fewCardinalityValue); assertEquals(Cardinality.FEW, Cardinality.forNumber(fewCardinalityValue, locale)); // Expected: <FSI>3<PDI> أولاد حضروا assertEquals("\u2068" + fewFormattedCardinalityValue + "\u2069 أولاد حضروا", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", fewCardinalityValue, "formattedCardinalityValue", fewFormattedCardinalityValue ) )); // CARDINALITY_MANY Number manyCardinalityValue = 11; String manyFormattedCardinalityValue = numberFormat.format(manyCardinalityValue); assertEquals(Cardinality.MANY, Cardinality.forNumber(manyCardinalityValue, locale)); // Expected: <FSI>11<PDI> ولدًا حضروا assertEquals("\u2068" + manyFormattedCardinalityValue + "\u2069 ولدًا حضروا", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", manyCardinalityValue, "formattedCardinalityValue", manyFormattedCardinalityValue ) )); // CARDINALITY_OTHER Number otherCardinalityValue = 100; String otherFormattedCardinalityValue = numberFormat.format(otherCardinalityValue); assertEquals(Cardinality.OTHER, Cardinality.forNumber(otherCardinalityValue, locale)); // Expected: <FSI>100<PDI> ولد حضروا assertEquals("\u2068" + otherFormattedCardinalityValue + "\u2069 ولد حضروا", strings.get( "Cardinality.MinimalPair", Map.of( "cardinalityValue", otherCardinalityValue, "formattedCardinalityValue", otherFormattedCardinalityValue ) ));
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_ZERO - CARDINALITY_ONE
Matches
CARDINALITY_ZERO -
CARDINALITY_ZERO - CARDINALITY_TWO
Matches
CARDINALITY_ZERO -
CARDINALITY_ZERO - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_ZERO - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
CARDINALITY_ZERO - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_ONE - CARDINALITY_TWO
Matches
CARDINALITY_OTHER -
CARDINALITY_ONE - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_ONE - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
CARDINALITY_ONE - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_TWO - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_TWO - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
CARDINALITY_TWO - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_FEW - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_FEW - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
CARDINALITY_FEW - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_MANY - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_MANY - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
CARDINALITY_MANY - CARDINALITY_OTHER
Matches
CARDINALITY_OTHER -
CARDINALITY_OTHER - CARDINALITY_ONE
Matches
CARDINALITY_OTHER -
CARDINALITY_OTHER - CARDINALITY_TWO
Matches
CARDINALITY_OTHER -
CARDINALITY_OTHER - CARDINALITY_FEW
Matches
CARDINALITY_FEW -
CARDINALITY_OTHER - CARDINALITY_MANY
Matches
CARDINALITY_MANY -
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_ZERO": "{{formattedDayRange}} يوم", "CARDINALITY_ONE": "{{formattedDayRange}} يوم", "CARDINALITY_TWO": "{{formattedDayRange}} يومان", "CARDINALITY_FEW": "{{formattedDayRange}} أيام", "CARDINALITY_MANY": "{{formattedDayRange}} يومًا", "CARDINALITY_OTHER": "{{formattedDayRange}} يوم" } } } } }
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. For this right-to-left locale, Lokalized's default BidiIsolation.RTL_LOCALES wraps caller-supplied formatted values with U+2068 FIRST STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE; the expected expressions below show those escapes.
Locale locale = Locale.forLanguageTag("ar"); 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_ZERO range Number minDays = 0; String formattedMinDays = numberFormat.format(minDays); Number maxDays = 1; String formattedMaxDays = numberFormat.format(maxDays); String formattedDayRange = formattedMinDays + "-" + formattedMaxDays; assertEquals(Cardinality.ZERO, Cardinality.forRange( Cardinality.forNumber(minDays, locale), Cardinality.forNumber(maxDays, locale), locale )); // Expected: <FSI>0-1<PDI> يوم // U+2068 FIRST STRONG ISOLATE begins bidirectional isolation around a caller-supplied value in right-to-left text // U+2069 POP DIRECTIONAL ISOLATE ends bidirectional isolation around a caller-supplied value in right-to-left text assertEquals("\u2068" + formattedDayRange + "\u2069 يوم", strings.get( "Delivery.Window", Map.of("minDays", minDays, "maxDays", maxDays, "formattedDayRange", formattedDayRange) ));
Ordinalities
All ordinal numbers use ORDINALITY_OTHER; no value selects a different form.
Example: اتجه إلى المنعطف الـ 2 يمينًا..
Language-Specific Examples
These examples show how Lokalized models grammatical choices and translation behavior that commonly affect Arabic application copy. Each example identifies the Lokalized language forms and other library features it uses.
Definiteness in noun phrases
This example contrasts an indefinite direct object, a definite noun, and a definite iḍāfa construct phrase. Construct state describes the relationship between the nouns; it is not a third degree of definiteness.
Language references: University of Oregon - the Arabic definite article, University of Oregon - the iḍāfa construct, Western Kentucky University - Arabic accusative forms
Lokalized forms used: Definiteness
Sample localized strings file
{ "Open {{document}}.": { "translation": "افتح {{document}}.", "placeholders": { "document": { "value": "definiteness", "translations": { "DEFINITENESS_DEFINITE": "الكتاب", "DEFINITENESS_INDEFINITE": "كتابًا", "DEFINITENESS_CONSTRUCT": "كتاب الطالب" } } } } }
Usage and expected results
Locale locale = Locale.forLanguageTag("ar"); Strings strings = Strings.withFallbackLocale(locale) .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings"))) .localeSupplier((matcher) -> matcher.bestMatchFor(locale)) .build(); assertEquals("افتح الكتاب.", strings.get( "Open {{document}}.", Map.of("definiteness", Definiteness.DEFINITE) )); assertEquals("افتح كتابًا.", strings.get( "Open {{document}}.", Map.of("definiteness", Definiteness.INDEFINITE) )); assertEquals("افتح كتاب الطالب.", strings.get( "Open {{document}}.", Map.of("definiteness", Definiteness.CONSTRUCT) ));
Solar and lunar article pronunciation
The definite article is written ال in both cases, but its pronunciation assimilates before solar letters. Transliteration makes the selected pronunciation visible: ash-shams versus al-qamar.
Language reference: University of Oregon - the Arabic definite article
Lokalized forms used: Phonetic
Sample localized strings file
{ "Pronounce the definite noun.": { "translation": "{{word}}", "placeholders": { "word": { "value": "word", "translations": { "PHONETIC_SOLAR": "ash-shams (الشمس)", "PHONETIC_LUNAR": "al-qamar (القمر)" } } } } }
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("ar"); Map<String, Phonetic> phoneticsByTerm = Map.ofEntries( Map.entry("الشمس", Phonetic.SOLAR), Map.entry("القمر", Phonetic.LUNAR) ); 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(); assertEquals("ash-shams (الشمس)", strings.get( "Pronounce the definite noun.", Map.of("word", "الشمس") )); assertEquals("al-qamar (القمر)", strings.get( "Pronounce the definite noun.", Map.of("word", "القمر") ));
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