Skip to content

Keys and message format

ICU MessageFormat plurals in Japanese: why "other" is enough

Under Unicode CLDR, Japanese has a single plural category, other. How ICU plural, select and selectordinal work, when to keep =0, and how i18next _one and _other keys map to Japanese.

Last checked

Key points

  • CLDR gives Japanese only the other category, for both cardinal and ordinal numbers
  • ICU plural, select and selectordinal require an other branch, and FormatJS throws without it
  • Exact matches such as =0 work regardless of language rules, so they can stay in Japanese
  • In i18next, Japanese needs only the key_other entry, and the variable must be named count

Plural categories differ by language

English changes the noun with the number: 1 file, 2 files. Which numbers take which form is different in every language, and Unicode CLDR publishes the rules as a set of categories named zero, one, two, few, many and other. Each language uses a subset. The next-intl documentation points to the CLDR Language Plural Rules chart and notes that the exact range of few and many varies by locale.

From the CLDR Language Plural Rules chart
LanguageCardinal (plural) categoriesOrdinal (selectordinal) categories
English (en)one, otherone, two, few, other
Japanese (ja)other onlyother only
Korean (ko)other only—
Chinese (zh)other only—

Japanese does not inflect nouns for number. 1件 and 3件 use the same word, so a single category covers every number. You can confirm this in any modern browser or in Node.js with Intl.PluralRules. Even for the number 1, the Japanese rules return other, not one.

Inspecting categories with Intl.PluralRules
new Intl.PluralRules('en').resolvedOptions().pluralCategories;
// ['one', 'other']
new Intl.PluralRules('ja').resolvedOptions().pluralCategories;
// ['other']
new Intl.PluralRules('ja').select(1);
// 'other'

How ICU plural messages work

ICU MessageFormat, used by next-intl and by FormatJS libraries such as react-intl, writes number-dependent text as {count, plural, ...}. The FormatJS syntax guide lists the categories and notes that Chinese and Japanese do not use one. It says other is required, as in the icu4j implementation, and that an error is thrown if plural is used without other. A branch written as =value matches that exact number regardless of the locale's categories. Inside a branch, # is replaced with the number, formatted like {key, number}; next-intl's example renders 3580 as 3,580.

English and Japanese messages (next-intl)
// en.json
{
  "inbox": "{count, plural, =0 {No messages} one {# message} other {# messages}}"
}

// ja.json
{
  "inbox": "{count, plural, =0 {メッセージはありません} other {#件のメッセージ}}"
}

Because the Japanese rules never select one, the Japanese translation can drop that branch and keep only other. The =0 branch is different: it is an exact match, not a category, so it works in Japanese too. Keep it whenever the zero case should read differently, as in メッセージはありません (there are no messages).

In practice, the author of the English message writes every category English needs, and the Japanese translator removes the branches Japanese never selects. Any tool that compares the two files should therefore accept a Japanese message with fewer branches than the English one, as long as other is present.

one is not the same as =1

The FormatJS guide advises against writing =1 in place of one. The category one means "singular", and in some languages it matches numbers other than 1. Keep that rule for the source language. For the Japanese translation, the practical consequence is simple: fold one into other, and use =1 only if you deliberately want different text for exactly one item.

select and selectordinal

select branches on a string value instead of a number. The next-intl docs state that the other case is required and is used when none of the specific values match; FormatJS also throws an error when select has no other. selectordinal handles ordinals such as 1st, 2nd and 3rd. English uses one, two, few and other for ordinals, but Japanese ordinals also have only other, so a single form such as #位 (rank) or #番目 covers every number.

Translating select and selectordinal
// en.json
{
  "status": "{state, select, open {Open} closed {Closed} other {Unknown}}",
  "rank": "You finished {place, selectordinal, one {#st} two {#nd} few {#rd} other {#th}}."
}

// ja.json
{
  "status": "{state, select, open {受付中} closed {終了} other {不明}}",
  "rank": "{place, selectordinal, other {#位}}でした。"
}

Note that the select keys (open, closed) are code values and must stay in English in every language. Only the text inside the braces is translated. A translator who localizes the keys themselves breaks the message silently, because the other branch then catches every value.

Plurals in i18next

i18next does not use ICU strings by default. It stores each plural form as its own key with a suffix, such as key_one and key_other; the suffixes changed with JSON format v4, introduced in i18next v21. The official docs say the variable must be named count and must be passed, and that there is no fallback to the plain key if count is missing. If count is 0 and a key_zero entry exists, it is used instead of the language's plural suffix.

English and Japanese resources in i18next
// en/translation.json
{
  "file_one": "{{count}} file",
  "file_other": "{{count}} files"
}

// ja/translation.json
{
  "file_other": "{{count}}件のファイル"
}

// call
i18next.t('file', { count: 1 });

With Japanese, count 1 still resolves to the other category, so file_other is used. If someone copies the English structure and translates only file_one, Japanese has no usable entry for any number. Ordinal plurals work the same way with ordinal: true and keys such as key_ordinal_other.

Testing Japanese plural messages

Plural branches are easy to break and hard to see, because the broken branch only appears for certain numbers. A unit test that formats each Japanese message with a few counts catches most problems before review. FormatJS's intl-messageformat package, which implements the same ICU syntax, can be used directly in a test. Format each message with 0, 1 and a large number, and compare the output with what the screen should show.

Formatting a Japanese message in a test (intl-messageformat)
import IntlMessageFormat from 'intl-messageformat';

const ja = '{count, plural, =0 {メッセージはありません} other {#件のメッセージ}}';
const msg = new IntlMessageFormat(ja, 'ja');

msg.format({count: 0});    // 'メッセージはありません'
msg.format({count: 1});    // '1件のメッセージ'
msg.format({count: 3580}); // '3,580件のメッセージ'

A message whose plural has no other branch fails as soon as it is parsed, with the MISSING_OTHER_CLAUSE error described in the FormatJS docs. Constructing every message in ja.json once in a test is therefore a cheap way to find that mistake across the whole file. The output for count 1 also shows that Japanese uses the other branch for one item.

Common mistakes

MistakeResultFix
Deleting other and keeping one in the Japanese messageFormatJS throws, because plural requires otherMerge the text into other
Writing special Japanese text in the one branchJapanese never selects one, so the text never appearsUse =1 if exactly one needs different text
Replacing # with a fixed numberThe same number shows for every countKeep # or {count}
Naming the i18next variable something other than countPlural resolution does not happenRename the variable to count
Providing only key_one in Japanese i18next resourcesNo translation is found for any numberProvide key_other
Translating select keys such as open or closedEvery value falls through to otherTranslate only the branch text

Japanese does not need plural forms, but it does use counter words such as 件, 個 and 人. Microsoft's Japanese style guide asks for counters read as ka or ko to be written in hiragana or kanji, as in 3 か月 and 5 個, rather than 3 ヶ月 or 5 コ.

FAQ

Is it a problem if a Japanese message still has a one branch?

Nothing breaks, but the branch is never chosen, so its text never appears. Merging it into other avoids confusion for the next translator.

Should we remove =0 as well?

No. =0 is an exact match and works in Japanese. Keep it whenever zero should read differently.

Do we need different counter words for different nouns?

Yes, that is a translation decision rather than a plural rule. 件 for messages and files, 人 for people and 個 for items are common choices; keep them consistent across the product.

How YakuCheck helps

YakuCheck checks plurals against the CLDR rule that Japanese has only other. An ICU plural without other and an extra i18next _one key are reported as YC007, and a missing i18next _other key is reported as a missing key (YC001).

Broken ICU braces are reported as YC008 and placeholder mismatches ({count} or {{count}}) as YC003. On the Try page you can paste your own en.json and ja.json and check them entirely in your browser.

Sources

Last checked

Library behavior changes between versions. Check the official documentation for the version you use.