Czech čeština

BCP 47 language tag: cs

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

Czech is most often spoken in Czechia and Slovakia.

Cardinalities

  • CARDINALITY_ONE

    Matches i = 1 and v = 0

    Example Integers: 1

  • CARDINALITY_FEW

    Matches i = 2..4 and v = 0

    Example Integers: 2, 4

  • CARDINALITY_MANY

    Matches v != 0

    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 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
cs.json Localized Strings File (Czech)
{
  "Delivery.LeadTime": {
    "commentary": "Estimated delivery time, expressed in days.",
    "translation": "{{leadTime}}",
    "placeholders": {
      "leadTime": {
        "value": "dayCount",
        "translations": {
          "CARDINALITY_ONE": "{{formattedDayCount}} den",
          "CARDINALITY_FEW": "{{formattedDayCount}} dny",
          "CARDINALITY_MANY": "{{formattedDayCount}} dne",
          "CARDINALITY_OTHER": "{{formattedDayCount}} dnů"
        }
      }
    }
  }
}
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("cs");

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 den
assertEquals(oneFormattedDayCount + " den", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", oneDayCount, "formattedDayCount", oneFormattedDayCount)
));

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

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

// Expected: 2 dny
assertEquals(fewFormattedDayCount + " dny", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", fewDayCount, "formattedDayCount", fewFormattedDayCount)
));

// CARDINALITY_MANY
Number manyDayCount = new java.math.BigDecimal("0.0");
NumberFormat manyDayCountFormat = NumberFormat.getNumberInstance(locale);
manyDayCountFormat.setMinimumFractionDigits(1);
manyDayCountFormat.setMaximumFractionDigits(1);
String manyFormattedDayCount = manyDayCountFormat.format(manyDayCount);

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

// Expected: 0,0 dne
assertEquals(manyFormattedDayCount + " dne", strings.get(
  "Delivery.LeadTime", Map.of("dayCount", manyDayCount, "formattedDayCount", manyFormattedDayCount)
));

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

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

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

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_FEW

    Matches CARDINALITY_FEW

  • CARDINALITY_ONE - CARDINALITY_MANY

    Matches CARDINALITY_MANY

  • CARDINALITY_ONE - 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_ONE

    Matches CARDINALITY_ONE

  • 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_ONE

  • 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
cs.json Localized Strings File (Czech)
{
  "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}} den",
          "CARDINALITY_FEW": "{{formattedDayRange}} dny",
          "CARDINALITY_MANY": "{{formattedDayRange}} dne",
          "CARDINALITY_OTHER": "{{formattedDayRange}} dnů"
        }
      }
    }
  }
}
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("cs");

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 = 2;
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-2 dny
assertEquals(formattedDayRange + " dny", 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. křižovatce odbočte vpravo..

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