Japanese 日本語

BCP 47 language tag: ja

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

Additional modeled concepts for Japanese: classifiers and counters; formality and register, including humble and honorific variants.

Japanese is most often spoken in Japan, Brazil, and Canada.

Cardinalities

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

Example: 2 日.

Cardinality Ranges

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

Ordinalities

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

Example: 2 番目の角を右折します。.

Language-Specific Examples

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

Counters by classifier

Japanese uses different counters for different semantic classes, such as bound volumes and machines.

Language references: Japan Foundation - counters by an object's shape or properties, Japan Foundation - counter grammar and examples

Lokalized forms used: Classifier

Sample localized strings file
ja.json Localized Strings File (Japanese)
{
  "I bought {{count}} items.": {
    "translation": "{{count}}{{counter}}買いました。",
    "placeholders": {
      "counter": {
        "value": "classifier",
        "translations": {
          "CLASSIFIER_GENERAL": "つ",
          "CLASSIFIER_BOUND": "冊",
          "CLASSIFIER_MACHINE": "台"
        }
      }
    }
  }
}
Usage and expected results
Locale locale = Locale.forLanguageTag("ja");

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

assertEquals("4つ買いました。", strings.get(
  "I bought {{count}} items.", Map.of("count", 4, "classifier", Classifier.GENERAL)
));

assertEquals("3冊買いました。", strings.get(
  "I bought {{count}} items.", Map.of("count", 3, "classifier", Classifier.BOUND)
));

assertEquals("2台買いました。", strings.get(
  "I bought {{count}} items.", Map.of("count", 2, "classifier", Classifier.MACHINE)
));

Welcome phrases by interaction context

These welcome phrases are context-specific, not four interchangeable politeness grades: いらっしゃい can greet a familiar visitor, ようこそ welcomes someone to a place, service staff use いらっしゃいませ, and お待ちしておりました presupposes an expected arrival. Treat the mapping as a product-context example and have its exact use reviewed by a native speaker.

Language references: NINJAL - role-bound use of いらっしゃいませ, Japan Tourism Agency - ようこそ and いらっしゃいませ, Agency for Cultural Affairs - honorific and humble Japanese, Gakushuin University - いらっしゃい as a home greeting

Lokalized forms used: Formality

Sample localized strings file
ja.json Localized Strings File (Japanese)
{
  "Welcome.": {
    "translation": "{{welcome}}",
    "placeholders": {
      "welcome": {
        "value": "formality",
        "translations": {
          "FORMALITY_CASUAL": "いらっしゃい。",
          "FORMALITY_FORMAL": "ようこそ。",
          "FORMALITY_HONORIFIC": "いらっしゃいませ。",
          "FORMALITY_HUMBLE": "お待ちしておりました。"
        }
      }
    }
  }
}
Usage and expected results
Locale locale = Locale.forLanguageTag("ja");

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

assertEquals("いらっしゃい。", strings.get(
  "Welcome.", Map.of("formality", Formality.CASUAL)
));

assertEquals("ようこそ。", strings.get(
  "Welcome.", Map.of("formality", Formality.FORMAL)
));

assertEquals("いらっしゃいませ。", strings.get(
  "Welcome.", Map.of("formality", Formality.HONORIFIC)
));

assertEquals("お待ちしておりました。", strings.get(
  "Welcome.", Map.of("formality", Formality.HUMBLE)
));

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