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
{ "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
{ "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:
nabsolute value of the source number (integer and decimals)iinteger digits ofnvnumber of visible fraction digits inn, with trailing zeroswnumber of visible fraction digits inn, without trailing zerosfvisible fractional digits inn, with trailing zerostvisible fractional digits inn, without trailing zerosc/ecompact decimal exponent operands used by some CLDR compact-number rules