Malay Melayu

BCP 47 language tag: ms

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

Additional modeled concepts for Malay: inclusive and exclusive “we”.

Malay is most often spoken in Malaysia, Indonesia, Singapore, and Brunei.

Cardinalities

All numbers use CARDINALITY_OTHER; no value selects a different form.

Example: 2 hari.

Cardinality Ranges

Every range resolves to CARDINALITY_OTHER because every endpoint is CARDINALITY_OTHER. Cardinality.forRange(...) therefore cannot select a different form.

Ordinalities

  • ORDINALITY_ONE

    Matches n = 1

    Example Integers: 1

  • ORDINALITY_OTHER

    Matches all other values

    Example Integers: 0, 2, 16, 100, 1000, 10000, 100000, 1000000, …

Ordinality example

This localized strings example uses complete CLDR minimal-pair patterns to demonstrate every Ordinality category defined for the locale.

Source: Unicode CLDR 48.2 ms locale data.

Sample localized strings file
ms.json Localized Strings File (Malay)
{
  "Ordinal.MinimalPair": {
    "commentary": "Demonstrates every CLDR ordinal category defined for this locale.",
    "translation": "{{ordinalExample}}",
    "placeholders": {
      "ordinalExample": {
        "value": "ordinalValue",
        "translations": {
          "ORDINALITY_ONE": "Ambil belokan kanan {{formattedOrdinalValue}}.",
          "ORDINALITY_OTHER": "Ambil belokan kanan yang ke-{{formattedOrdinalValue}}."
        }
      }
    }
  }
}
Usage and expected results

The Java code passes each raw number to Ordinality.forNumber(...) and formats its display value separately with NumberFormat.

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

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

// ORDINALITY_ONE
Number oneOrdinalValue = 1;
String oneFormattedOrdinalValue = numberFormat.format(oneOrdinalValue);

assertEquals(Ordinality.ONE, Ordinality.forNumber(oneOrdinalValue, locale));

// Expected: Ambil belokan kanan 1.
assertEquals("Ambil belokan kanan " + oneFormattedOrdinalValue + ".", strings.get(
  "Ordinal.MinimalPair",
  Map.of("ordinalValue", oneOrdinalValue, "formattedOrdinalValue", oneFormattedOrdinalValue)
));

// ORDINALITY_OTHER
Number otherOrdinalValue = 2;
String otherFormattedOrdinalValue = numberFormat.format(otherOrdinalValue);

assertEquals(Ordinality.OTHER, Ordinality.forNumber(otherOrdinalValue, locale));

// Expected: Ambil belokan kanan yang ke-2.
assertEquals("Ambil belokan kanan yang ke-" + otherFormattedOrdinalValue + ".", strings.get(
  "Ordinal.MinimalPair",
  Map.of("ordinalValue", otherOrdinalValue, "formattedOrdinalValue", otherFormattedOrdinalValue)
));

Language-Specific Examples

These examples show how Lokalized models grammatical choices and translation behavior that commonly affect Malay application copy. Each example identifies the Lokalized language forms and other library features it uses.

Inclusive and exclusive we

Malay distinguishes kita, which includes the addressee, from kami, which excludes the addressee.

Language references: Dewan Bahasa dan Pustaka - kami and kita, University of Malaya - inclusive kita and exclusive kami

Lokalized forms used: Clusivity

Sample localized strings file
ms.json Localized Strings File (Malay)
{
  "We will meet at noon.": {
    "translation": "{{we}} akan bertemu pada tengah hari.",
    "placeholders": {
      "we": {
        "value": "clusivity",
        "translations": {
          "CLUSIVITY_INCLUSIVE": "Kita",
          "CLUSIVITY_EXCLUSIVE": "Kami"
        }
      }
    }
  }
}
Usage and expected results
Locale locale = Locale.forLanguageTag("ms");

Strings strings = Strings.withFallbackLocale(locale)
  .localizedStringSupplier(() -> LocalizedStringLoader.loadFromFilesystem(Paths.get("strings")))
  .localeSupplier((matcher) -> matcher.bestMatchFor(locale))
  .build();

assertEquals("Kita akan bertemu pada tengah hari.", strings.get(
  "We will meet at noon.", Map.of("clusivity", Clusivity.INCLUSIVE)
));

assertEquals("Kami akan bertemu pada tengah hari.", strings.get(
  "We will meet at noon.", Map.of("clusivity", Clusivity.EXCLUSIVE)
));

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