Najdi Arabic اللهجة النجدية

BCP 47 language tag: ars

Lokalized supports cardinality, cardinality range, and ordinality rules for Najdi Arabic.

Najdi Arabic is most often spoken in Saudi Arabia.

Cardinalities

  • CARDINALITY_ZERO

    Matches n = 0

    Example Integers: 0

    Example Decimals: 0.0, 0.00, 0.000, 0.0000

  • CARDINALITY_ONE

    Matches n = 1

    Example Integers: 1

    Example Decimals: 1.0, 1.00, 1.000, 1.0000

  • CARDINALITY_TWO

    Matches n = 2

    Example Integers: 2

    Example Decimals: 2.0, 2.00, 2.000, 2.0000

  • CARDINALITY_FEW

    Matches n % 100 = 3..10

    Example 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..99

    Example 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 values

    Example 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 file selects the localized form of “day” for a delivery estimate. Raw numbers choose the CLDR category; values formatted for display are interpolated.

Sample localized strings file
ars.json Localized Strings File (Najdi Arabic)
{
  "Delivery.LeadTime": {
    "commentary": "Estimated delivery time, expressed in days.",
    "translation": "{{leadTime}}",
    "placeholders": {
      "leadTime": {
        "value": "dayCount",
        "translations": {
          "CARDINALITY_ZERO": "{{formattedDayCount}} يوم",
          "CARDINALITY_ONE": "يوم",
          "CARDINALITY_TWO": "يومان",
          "CARDINALITY_FEW": "{{formattedDayCount}} أيام",
          "CARDINALITY_MANY": "{{formattedDayCount}} يومًا",
          "CARDINALITY_OTHER": "{{formattedDayCount}} يوم"
        }
      }
    }
  }
}
Usage and expected results

JavaScript

The JavaScript code passes each raw number for cardinality selection and formats its display value separately with Intl.NumberFormat. For this right-to-left locale, the default bidiIsolation, "rtl-locales", wraps caller-supplied formatted values with U+2068 FIRST STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE; the expected strings below show those escapes.

import { cardinalityForNumber, createStrings } from "lokalized";
import { readStringsFromDirectory } from "lokalized/node";

const locale = "ars";

const strings = createStrings({
  localizedStringSupplier: () => readStringsFromDirectory("strings").catalogs,
  fallbackLocale: locale,
  localeSupplier: () => locale,
});

const numberFormat = new Intl.NumberFormat(locale);

// Raw numbers select language forms; Intl.NumberFormat produces the display values

// CARDINALITY_ZERO
const zeroDayCount = 0;
const zeroFormattedDayCount = numberFormat.format(zeroDayCount);

cardinalityForNumber(zeroDayCount, locale).name;   // => "CARDINALITY_ZERO"
// 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
strings.get("Delivery.LeadTime", {
  dayCount: zeroDayCount,
  formattedDayCount: zeroFormattedDayCount,
});   // => "\u2068٠\u2069 يوم"

// CARDINALITY_ONE
const oneDayCount = 1;
const oneFormattedDayCount = numberFormat.format(oneDayCount);

cardinalityForNumber(oneDayCount, locale).name;   // => "CARDINALITY_ONE"
strings.get("Delivery.LeadTime", {
  dayCount: oneDayCount,
  formattedDayCount: oneFormattedDayCount,
});   // => "يوم"

// CARDINALITY_TWO
const twoDayCount = 2;
const twoFormattedDayCount = numberFormat.format(twoDayCount);

cardinalityForNumber(twoDayCount, locale).name;   // => "CARDINALITY_TWO"
strings.get("Delivery.LeadTime", {
  dayCount: twoDayCount,
  formattedDayCount: twoFormattedDayCount,
});   // => "يومان"

// CARDINALITY_FEW
const fewDayCount = 3;
const fewFormattedDayCount = numberFormat.format(fewDayCount);

cardinalityForNumber(fewDayCount, locale).name;   // => "CARDINALITY_FEW"
strings.get("Delivery.LeadTime", {
  dayCount: fewDayCount,
  formattedDayCount: fewFormattedDayCount,
});   // => "\u2068٣\u2069 أيام"

// CARDINALITY_MANY
const manyDayCount = 11;
const manyFormattedDayCount = numberFormat.format(manyDayCount);

cardinalityForNumber(manyDayCount, locale).name;   // => "CARDINALITY_MANY"
strings.get("Delivery.LeadTime", {
  dayCount: manyDayCount,
  formattedDayCount: manyFormattedDayCount,
});   // => "\u2068١١\u2069 يومًا"

// CARDINALITY_OTHER
const otherDayCount = 100;
const otherFormattedDayCount = numberFormat.format(otherDayCount);

cardinalityForNumber(otherDayCount, locale).name;   // => "CARDINALITY_OTHER"
strings.get("Delivery.LeadTime", {
  dayCount: otherDayCount,
  formattedDayCount: otherFormattedDayCount,
});   // => "\u2068١٠٠\u2069 يوم"

Java

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("ars");

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 zeroDayCount = 0;
String zeroFormattedDayCount = numberFormat.format(zeroDayCount);

assertEquals(Cardinality.ZERO, Cardinality.forNumber(zeroDayCount, locale));

// Expected: <FSI>٠<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" + zeroFormattedDayCount + "\u2069 يوم", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", zeroDayCount, "formattedDayCount", zeroFormattedDayCount)
));

// CARDINALITY_ONE
Number oneDayCount = 1;
String oneFormattedDayCount = numberFormat.format(oneDayCount);

assertEquals(Cardinality.ONE, Cardinality.forNumber(oneDayCount, locale));

assertEquals("يوم", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", oneDayCount, "formattedDayCount", oneFormattedDayCount)
));

// CARDINALITY_TWO
Number twoDayCount = 2;
String twoFormattedDayCount = numberFormat.format(twoDayCount);

assertEquals(Cardinality.TWO, Cardinality.forNumber(twoDayCount, locale));

assertEquals("يومان", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", twoDayCount, "formattedDayCount", twoFormattedDayCount)
));

// CARDINALITY_FEW
Number fewDayCount = 3;
String fewFormattedDayCount = numberFormat.format(fewDayCount);

assertEquals(Cardinality.FEW, Cardinality.forNumber(fewDayCount, locale));

// Expected: <FSI>٣<PDI> أيام
assertEquals("\u2068" + fewFormattedDayCount + "\u2069 أيام", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", fewDayCount, "formattedDayCount", fewFormattedDayCount)
));

// CARDINALITY_MANY
Number manyDayCount = 11;
String manyFormattedDayCount = numberFormat.format(manyDayCount);

assertEquals(Cardinality.MANY, Cardinality.forNumber(manyDayCount, locale));

// Expected: <FSI>١١<PDI> يومًا
assertEquals("\u2068" + manyFormattedDayCount + "\u2069 يومًا", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", manyDayCount, "formattedDayCount", manyFormattedDayCount)
));

// CARDINALITY_OTHER
Number otherDayCount = 100;
String otherFormattedDayCount = numberFormat.format(otherDayCount);

assertEquals(Cardinality.OTHER, Cardinality.forNumber(otherDayCount, locale));

// Expected: <FSI>١٠٠<PDI> يوم
assertEquals("\u2068" + otherFormattedDayCount + "\u2069 يوم", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", otherDayCount, "formattedDayCount", otherFormattedDayCount)
));

Swift

Swift uses pinned CLDR rules for raw numeric values. The display strings in these assertions are fixed examples; applications format display values separately with Foundation. Default .rtlLocales bidi isolation adds FSI/PDI to interpolated values in right-to-left output.

import Foundation
import Lokalized

let locale = try LocaleTag("ars")
let files = try LocalizedStringLoader.loadFromDirectory(URL(fileURLWithPath: "strings"))
let catalogs = files.mapValues { LocalizedCatalog(strings: $0.strings) }

let strings = try DefaultStrings(configuration: StringsConfiguration(
  localizedStringSupplier: { catalogs }, localeSupplier: { _ in locale },
  fallbackLocale: locale
))

// CARDINALITY_ZERO
let number1 = try NumericValue.forDecimal("0")
let category1 = try Cardinality.forNumber(number1, locale: locale.tag)
assert(category1 == .zero)
// This fixed display value makes the translation assertion reproducible.
let display1 = "٠"
let message1 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number1),
  "formattedDayCount": .text(display1),
])
assert(ExactString(message1) == ExactString("\u{2068}٠\u{2069} يوم"))

// CARDINALITY_ONE
let number2 = try NumericValue.forDecimal("1")
let category2 = try Cardinality.forNumber(number2, locale: locale.tag)
assert(category2 == .one)
// This fixed display value makes the translation assertion reproducible.
let display2 = "١"
let message2 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number2),
  "formattedDayCount": .text(display2),
])
assert(ExactString(message2) == ExactString("يوم"))

// CARDINALITY_TWO
let number3 = try NumericValue.forDecimal("2")
let category3 = try Cardinality.forNumber(number3, locale: locale.tag)
assert(category3 == .two)
// This fixed display value makes the translation assertion reproducible.
let display3 = "٢"
let message3 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number3),
  "formattedDayCount": .text(display3),
])
assert(ExactString(message3) == ExactString("يومان"))

// CARDINALITY_FEW
let number4 = try NumericValue.forDecimal("3")
let category4 = try Cardinality.forNumber(number4, locale: locale.tag)
assert(category4 == .few)
// This fixed display value makes the translation assertion reproducible.
let display4 = "٣"
let message4 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number4),
  "formattedDayCount": .text(display4),
])
assert(ExactString(message4) == ExactString("\u{2068}٣\u{2069} أيام"))

// CARDINALITY_MANY
let number5 = try NumericValue.forDecimal("11")
let category5 = try Cardinality.forNumber(number5, locale: locale.tag)
assert(category5 == .many)
// This fixed display value makes the translation assertion reproducible.
let display5 = "١١"
let message5 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number5),
  "formattedDayCount": .text(display5),
])
assert(ExactString(message5) == ExactString("\u{2068}١١\u{2069} يومًا"))

// CARDINALITY_OTHER
let number6 = try NumericValue.forDecimal("100")
let category6 = try Cardinality.forNumber(number6, locale: locale.tag)
assert(category6 == .other)
// This fixed display value makes the translation assertion reproducible.
let display6 = "١٠٠"
let message6 = try strings.get("Delivery.LeadTime", placeholders: [
  "dayCount": .number(number6),
  "formattedDayCount": .text(display6),
])
assert(ExactString(message6) == ExactString("\u{2068}١٠٠\u{2069} يوم"))

Cardinality Ranges

No explicit CLDR cardinality-range mapping is defined for this language, so every range falls back to the ending cardinality.

Cardinality range example

Because CLDR defines no explicit range mapping for this locale, the ending cardinality selects the result. The selected form wraps a separately formatted display range.

Sample localized strings file
ars.json Localized Strings File (Najdi Arabic)
{
  "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

JavaScript

The JavaScript code passes raw range endpoints for selection, formats both endpoints separately with Intl.NumberFormat, and joins them for display; choose range punctuation appropriate to your application. Range rules are an optional import, lokalized/data/ranges. For this right-to-left locale, the default bidiIsolation, "rtl-locales", wraps caller-supplied formatted values with U+2068 FIRST STRONG ISOLATE and U+2069 POP DIRECTIONAL ISOLATE; the expected strings below show those escapes.

import { cardinalityForNumber, createStrings, decimal } from "lokalized";
import { cardinalRangeData, cardinalityForRange } from "lokalized/data/ranges";
import { readStringsFromDirectory } from "lokalized/node";

const locale = "ars";

const strings = createStrings({
  localizedStringSupplier: () => readStringsFromDirectory("strings").catalogs,
  fallbackLocale: locale,
  localeSupplier: () => locale,
  pluralData: { ranges: cardinalRangeData },
});

const numberFormat = new Intl.NumberFormat(locale);

// Raw numbers select language forms; Intl.NumberFormat produces the display values

// CARDINALITY_OTHER range (ending-cardinality fallback)
const minDays = 0;
const formattedMinDays = numberFormat.format(minDays);
const maxDays = decimal("0.1");
const formattedMaxDays = new Intl.NumberFormat(locale, { minimumFractionDigits: 1, maximumFractionDigits: 1 })
  .format("0.1");
const formattedDayRange = formattedMinDays + "-" + formattedMaxDays;

cardinalityForRange(
  cardinalityForNumber(minDays, locale),
  cardinalityForNumber(maxDays, locale),
  locale
).name;   // => "CARDINALITY_OTHER"
// 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
strings.get("Delivery.Window", { minDays, maxDays, formattedDayRange });   // => "\u2068٠-٠٫١\u2069 يوم"

Java

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("ars");

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_OTHER range (ending-cardinality fallback)
Number minDays = 0;
String formattedMinDays = numberFormat.format(minDays);
Number maxDays = new java.math.BigDecimal("0.1");
NumberFormat maxDaysFormat = NumberFormat.getNumberInstance(locale);
maxDaysFormat.setMinimumFractionDigits(1);
maxDaysFormat.setMaximumFractionDigits(1);
String formattedMaxDays = maxDaysFormat.format(maxDays);
String formattedDayRange = formattedMinDays + "-" + formattedMaxDays;

assertEquals(Cardinality.OTHER, Cardinality.forRange(
  Cardinality.forNumber(minDays, locale),
  Cardinality.forNumber(maxDays, locale),
  locale
));

// Expected: <FSI>٠-٠٫١<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)
));

Swift

Swift uses pinned CLDR rules for raw numeric values. The display strings in these assertions are fixed examples; applications format display values separately with Foundation. Default .rtlLocales bidi isolation adds FSI/PDI to interpolated values in right-to-left output.

import Foundation
import Lokalized

let locale = try LocaleTag("ars")
let files = try LocalizedStringLoader.loadFromDirectory(URL(fileURLWithPath: "strings"))
let catalogs = files.mapValues { LocalizedCatalog(strings: $0.strings) }

let strings = try DefaultStrings(configuration: StringsConfiguration(
  localizedStringSupplier: { catalogs }, localeSupplier: { _ in locale },
  fallbackLocale: locale
))

let start = try NumericValue.forDecimal("0")
let end = try NumericValue.forDecimal("0.1")
let startForm = try Cardinality.forNumber(start, locale: locale.tag)
let endForm = try Cardinality.forNumber(end, locale: locale.tag)
let rangeForm = try Cardinality.forRange(startForm, endForm, locale: locale.tag)
assert(rangeForm == .other)
let message1 = try strings.get("Delivery.Window", placeholders: [
  "minDays": .number(start),
  "maxDays": .number(end),
  "formattedDayRange": .text("٠-٠٫١"),
])
assert(ExactString(message1) == ExactString("\u{2068}٠-٠٫١\u{2069} يوم"))

Ordinalities

All ordinal numbers use ORDINALITY_OTHER; no value selects a different form.

Addendum: Language Form Rules

The language form expressions above are specified by Unicode Technical Standard #35 and use the following notation:

  • n absolute value of the source number (integer and decimals)
  • i integer digits of n
  • v number of visible fraction digits in n, with trailing zeros
  • w number of visible fraction digits in n, without trailing zeros
  • f visible fractional digits in n, with trailing zeros
  • t visible fractional digits in n, without trailing zeros
  • c/e compact decimal exponent operands used by some CLDR compact-number rules