Upper Sorbian hornjoserbšćina

BCP 47 language tag: hsb

Lokalized supports cardinality, cardinality range, and ordinality rules for Upper Sorbian.

Upper Sorbian is most often spoken in Germany.

Cardinalities

  • CARDINALITY_ONE

    Matches v = 0 and i % 100 = 1 or f % 100 = 1

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

    Example Decimals: 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …

  • CARDINALITY_TWO

    Matches v = 0 and i % 100 = 2 or f % 100 = 2

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

    Example Decimals: 0.2, 1.2, 2.2, 3.2, 4.2, 5.2, 6.2, 7.2, 10.2, 100.2, 1000.2, …

  • CARDINALITY_FEW

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

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

    Example Decimals: 0.3, 0.4, 1.3, 1.4, 2.3, 2.4, 3.3, 3.4, 4.3, 4.4, 5.3, 5.4, 6.3, 6.4, 7.3, 7.4, 10.3, 100.3, 1000.3, …

  • CARDINALITY_OTHER

    Matches all other values

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

    Example Decimals: 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 2.7, 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
hsb.json Localized Strings File (Upper Sorbian)
{
  "Delivery.LeadTime": {
    "commentary": "Estimated delivery time, expressed in days.",
    "translation": "{{leadTime}}",
    "placeholders": {
      "leadTime": {
        "value": "dayCount",
        "translations": {
          "CARDINALITY_ONE": "{{formattedDayCount}} dźeń",
          "CARDINALITY_TWO": "{{formattedDayCount}} dnjej",
          "CARDINALITY_FEW": "{{formattedDayCount}} dny",
          "CARDINALITY_OTHER": "{{formattedDayCount}} dnjow"
        }
      }
    }
  }
}
Usage and expected results

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

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

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

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

// Expected: 1 dźeń
assertEquals(oneFormattedDayCount + " dźeń", 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));

// Expected: 2 dnjej
assertEquals(twoFormattedDayCount + " dnjej", 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: 3 dny
assertEquals(fewFormattedDayCount + " dny", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", fewDayCount, "formattedDayCount", fewFormattedDayCount)
));

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

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

// Expected: 0 dnjow
assertEquals(otherFormattedDayCount + " dnjow", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", otherDayCount, "formattedDayCount", otherFormattedDayCount)
));

Cardinality Ranges

No explicit CLDR cardinality-range mapping is defined for this language. Cardinality.forRange(...) therefore falls back to the ending cardinality for every range.

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
hsb.json Localized Strings File (Upper Sorbian)
{
  "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}} dźeń",
          "CARDINALITY_TWO": "{{formattedDayRange}} dnjej",
          "CARDINALITY_FEW": "{{formattedDayRange}} dny",
          "CARDINALITY_OTHER": "{{formattedDayRange}} dnjow"
        }
      }
    }
  }
}
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("hsb");

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 (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.ONE, Cardinality.forRange(
  Cardinality.forNumber(minDays, locale),
  Cardinality.forNumber(maxDays, locale),
  locale
));

// Expected: 0-0,1 dźeń
assertEquals(formattedDayRange + " dźeń", 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: Na 2. wotbóčce naprawo..

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