Slovenian slovenščina

BCP 47 language tag: sl

Lokalized supports cardinality, cardinality range, and ordinality rules for Slovenian.

Slovenian is most often spoken in Slovenia, Italy, Austria, and Hungary.

Cardinalities

  • CARDINALITY_ONE

    Matches v = 0 and i % 100 = 1

    Example Integers: 1, 101, 201, 301, 401, 501, 601, 701, 1001, …

  • CARDINALITY_TWO

    Matches v = 0 and i % 100 = 2

    Example Integers: 2, 102, 202, 302, 402, 502, 602, 702, 1002, …

  • CARDINALITY_FEW

    Matches v = 0 and i % 100 = 3..4 or v != 0

    Example Integers: 3, 4, 103, 104, 203, 204, 303, 304, 403, 404, 503, 504, 603, 604, 703, 704, 1003, …

    Example Decimals: 0.0, 1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …

  • CARDINALITY_OTHER

    Matches all other values

    Example Integers: 0, 5, 19, 100, 1000, 10000, 100000, 1000000, …

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 sl locale data.

Sample localized strings file
sl.json Localized Strings File (Slovenian)
{
  "Cardinality.MinimalPair": {
    "commentary": "Demonstrates every CLDR cardinal category defined for this locale.",
    "translation": "{{cardinalityExample}}",
    "placeholders": {
      "cardinalityExample": {
        "value": "cardinalityValue",
        "translations": {
          "CARDINALITY_ONE": "{{formattedCardinalityValue}} dan",
          "CARDINALITY_TWO": "{{formattedCardinalityValue}} dneva",
          "CARDINALITY_FEW": "{{formattedCardinalityValue}} dnevi",
          "CARDINALITY_OTHER": "{{formattedCardinalityValue}} dni"
        }
      }
    }
  }
}
Usage and expected results

JavaScript

The JavaScript code passes each raw number for cardinality selection and formats its display value separately with Intl.NumberFormat.

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

const locale = "sl";

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_ONE
const oneCardinality = 1;
const oneFormattedCardinalityValue = numberFormat.format(oneCardinality);

cardinalityForNumber(oneCardinality, locale).name;   // => "CARDINALITY_ONE"
strings.get("Cardinality.MinimalPair", {
  cardinalityValue: oneCardinality,
  formattedCardinalityValue: oneFormattedCardinalityValue,
});   // => "1 dan"

// CARDINALITY_TWO
const twoCardinality = 2;
const twoFormattedCardinalityValue = numberFormat.format(twoCardinality);

cardinalityForNumber(twoCardinality, locale).name;   // => "CARDINALITY_TWO"
strings.get("Cardinality.MinimalPair", {
  cardinalityValue: twoCardinality,
  formattedCardinalityValue: twoFormattedCardinalityValue,
});   // => "2 dneva"

// CARDINALITY_FEW
const fewCardinality = 3;
const fewFormattedCardinalityValue = numberFormat.format(fewCardinality);

cardinalityForNumber(fewCardinality, locale).name;   // => "CARDINALITY_FEW"
strings.get("Cardinality.MinimalPair", {
  cardinalityValue: fewCardinality,
  formattedCardinalityValue: fewFormattedCardinalityValue,
});   // => "3 dnevi"

// CARDINALITY_OTHER
const otherCardinality = 0;
const otherFormattedCardinalityValue = numberFormat.format(otherCardinality);

cardinalityForNumber(otherCardinality, locale).name;   // => "CARDINALITY_OTHER"
strings.get("Cardinality.MinimalPair", {
  cardinalityValue: otherCardinality,
  formattedCardinalityValue: otherFormattedCardinalityValue,
});   // => "0 dni"

Java

The Java code passes each raw number for cardinality selection and formats its display value separately with NumberFormat.

Locale locale = Locale.forLanguageTag("sl");

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 oneCardinality = 1;
String oneFormattedCardinalityValue = numberFormat.format(oneCardinality);

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

// Expected: 1 dan
assertEquals(oneFormattedCardinalityValue + " dan", strings.get(
  "Cardinality.MinimalPair",
  Map.of("cardinalityValue", oneCardinality, "formattedCardinalityValue", oneFormattedCardinalityValue)
));

// CARDINALITY_TWO
Number twoCardinality = 2;
String twoFormattedCardinalityValue = numberFormat.format(twoCardinality);

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

// Expected: 2 dneva
assertEquals(twoFormattedCardinalityValue + " dneva", strings.get(
  "Cardinality.MinimalPair",
  Map.of("cardinalityValue", twoCardinality, "formattedCardinalityValue", twoFormattedCardinalityValue)
));

// CARDINALITY_FEW
Number fewCardinality = 3;
String fewFormattedCardinalityValue = numberFormat.format(fewCardinality);

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

// Expected: 3 dnevi
assertEquals(fewFormattedCardinalityValue + " dnevi", strings.get(
  "Cardinality.MinimalPair",
  Map.of("cardinalityValue", fewCardinality, "formattedCardinalityValue", fewFormattedCardinalityValue)
));

// CARDINALITY_OTHER
Number otherCardinality = 0;
String otherFormattedCardinalityValue = numberFormat.format(otherCardinality);

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

// Expected: 0 dni
assertEquals(otherFormattedCardinalityValue + " dni", strings.get(
  "Cardinality.MinimalPair",
  Map.of(
    "cardinalityValue", otherCardinality,
    "formattedCardinalityValue", otherFormattedCardinalityValue
  )
));

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("sl")
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_ONE
let number1 = try NumericValue.forDecimal("1")
let category1 = try Cardinality.forNumber(number1, locale: locale.tag)
assert(category1 == .one)
// This fixed display value makes the translation assertion reproducible.
let display1 = "1"
let message1 = try strings.get("Cardinality.MinimalPair", placeholders: [
  "cardinalityValue": .number(number1),
  "formattedCardinalityValue": .text(display1),
])
assert(ExactString(message1) == ExactString("1 dan"))

// CARDINALITY_TWO
let number2 = try NumericValue.forDecimal("2")
let category2 = try Cardinality.forNumber(number2, locale: locale.tag)
assert(category2 == .two)
// This fixed display value makes the translation assertion reproducible.
let display2 = "2"
let message2 = try strings.get("Cardinality.MinimalPair", placeholders: [
  "cardinalityValue": .number(number2),
  "formattedCardinalityValue": .text(display2),
])
assert(ExactString(message2) == ExactString("2 dneva"))

// CARDINALITY_FEW
let number3 = try NumericValue.forDecimal("3")
let category3 = try Cardinality.forNumber(number3, locale: locale.tag)
assert(category3 == .few)
// This fixed display value makes the translation assertion reproducible.
let display3 = "3"
let message3 = try strings.get("Cardinality.MinimalPair", placeholders: [
  "cardinalityValue": .number(number3),
  "formattedCardinalityValue": .text(display3),
])
assert(ExactString(message3) == ExactString("3 dnevi"))

// CARDINALITY_OTHER
let number4 = try NumericValue.forDecimal("0")
let category4 = try Cardinality.forNumber(number4, locale: locale.tag)
assert(category4 == .other)
// This fixed display value makes the translation assertion reproducible.
let display4 = "0"
let message4 = try strings.get("Cardinality.MinimalPair", placeholders: [
  "cardinalityValue": .number(number4),
  "formattedCardinalityValue": .text(display4),
])
assert(ExactString(message4) == ExactString("0 dni"))

Cardinality Ranges

These are CLDR's explicit range mappings. For any start/end pair not listed, the range falls back to the ending cardinality.

  • CARDINALITY_ONE - CARDINALITY_ONE

    Matches CARDINALITY_FEW

  • CARDINALITY_ONE - CARDINALITY_TWO

    Matches CARDINALITY_TWO

  • CARDINALITY_ONE - CARDINALITY_FEW

    Matches CARDINALITY_FEW

  • CARDINALITY_ONE - CARDINALITY_OTHER

    Matches CARDINALITY_OTHER

  • CARDINALITY_TWO - CARDINALITY_ONE

    Matches CARDINALITY_FEW

  • CARDINALITY_TWO - CARDINALITY_TWO

    Matches CARDINALITY_TWO

  • CARDINALITY_TWO - CARDINALITY_FEW

    Matches CARDINALITY_FEW

  • CARDINALITY_TWO - CARDINALITY_OTHER

    Matches CARDINALITY_OTHER

  • CARDINALITY_FEW - CARDINALITY_ONE

    Matches CARDINALITY_FEW

  • CARDINALITY_FEW - CARDINALITY_TWO

    Matches CARDINALITY_TWO

  • CARDINALITY_FEW - CARDINALITY_FEW

    Matches CARDINALITY_FEW

  • CARDINALITY_FEW - CARDINALITY_OTHER

    Matches CARDINALITY_OTHER

  • CARDINALITY_OTHER - CARDINALITY_ONE

    Matches CARDINALITY_FEW

  • CARDINALITY_OTHER - CARDINALITY_TWO

    Matches CARDINALITY_TWO

  • CARDINALITY_OTHER - CARDINALITY_FEW

    Matches CARDINALITY_FEW

  • 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
sl.json Localized Strings File (Slovenian)
{
  "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}} dan",
          "CARDINALITY_TWO": "{{formattedDayRange}} dneva",
          "CARDINALITY_FEW": "{{formattedDayRange}} dni",
          "CARDINALITY_OTHER": "{{formattedDayRange}} dni"
        }
      }
    }
  }
}
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.

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

const locale = "sl";

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_FEW range
const minDays = 1;
const formattedMinDays = numberFormat.format(minDays);
const maxDays = 101;
const formattedMaxDays = numberFormat.format(maxDays);
const formattedDayRange = formattedMinDays + "-" + formattedMaxDays;

cardinalityForRange(
  cardinalityForNumber(minDays, locale),
  cardinalityForNumber(maxDays, locale),
  locale
).name;   // => "CARDINALITY_FEW"
strings.get("Delivery.Window", { minDays, maxDays, formattedDayRange });   // => "1-101 dni"

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.

Locale locale = Locale.forLanguageTag("sl");

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_FEW range
Number minDays = 1;
String formattedMinDays = numberFormat.format(minDays);
Number maxDays = 101;
String formattedMaxDays = numberFormat.format(maxDays);
String formattedDayRange = formattedMinDays + "-" + formattedMaxDays;

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

// Expected: 1-101 dni
assertEquals(formattedDayRange + " dni", 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("sl")
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("1")
let end = try NumericValue.forDecimal("101")
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 == .few)
let message1 = try strings.get("Delivery.Window", placeholders: [
  "minDays": .number(start),
  "maxDays": .number(end),
  "formattedDayRange": .text("1-101"),
])
assert(ExactString(message1) == ExactString("1-101 dni"))

Ordinalities

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

Example: V 2. križišču zavijte desno..

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