Skip to content
Novus Examples
json1.9 KB

ICU MessageFormat — Plural offset (English)

The 'Rana and 5 others like this' pattern: ICU plural arguments with offset:1 and offset:2, where the explicit =0/=1/=2 selectors match the RAW value but '#' prints the value MINUS the offset. Ships every boundary case with its expected output.

Preview — first 50 linesjson
{
  "locale": "en",
  "format": "icu-messageformat",
  "note": "In ICU MessageFormat, '#' inside a plural branch binds to the NEAREST enclosing plural argument, not the outermost one. Where an outer count must appear inside an inner plural, these messages use the explicit {name} form instead of '#'.",
  "messages": {
    "likes": "{count, plural, offset:1 =0 {No one likes this} =1 {{name} likes this} one {{name} and # other like this} other {{name} and # others like this}}",
    "attending": "{count, plural, offset:2 =0 {Nobody is attending} =1 {{host} is attending} =2 {{host} and {guest} are attending} one {{host}, {guest} and # other are attending} other {{host}, {guest} and # others are attending}}"
  },
  "cases": [
    {
      "message": "likes",
      "args": {
        "count": 0,
        "name": "Rana"
      },
      "expected": "No one likes this"
    },
    {
      "message": "likes",
      "args": {
        "count": 1,
        "name": "Rana"
      },
      "expected": "Rana likes this"
    },
    {
      "message": "likes",
      "args": {
        "count": 2,
        "name": "Rana"
      },
      "expected": "Rana and 1 other like this"
    },
    {
      "message": "likes",
      "args": {
        "count": 6,
        "name": "Rana"
      },
      "expected": "Rana and 5 others like this"
    },
    {
      "message": "attending",
      "args": {
        "count": 2,
        "host": "Rana",
        "guest": "Tomás"
      },
      "expected": "Rana and Tomás are attending"
    },
72 lines total — download for the full file.

Specifications

Format
ICU MessageFormat
Locale
en
Feature
offset:1 and offset:2
Messages
2
Cases
7
Seed
20260807
Wave
p7
Line Endings
LF

Testing contract

Expected to pass
Scenario
Format `likes` with count 0, 1, 2 and 6, and `attending` with count 2, 3 and 40.
Expected result
count 6 renders '5 others' (6 minus the offset of 1) while the =1 selector still matches a raw count of exactly 1; an implementation that applies the offset before the explicit selectors gets every boundary wrong.

What is a .json file?

JSON (JavaScript Object Notation) is a lightweight, text-based data-interchange format representing objects, arrays, strings, numbers, booleans, and null. It is language-independent, human-readable, and the dominant format for web APIs and configuration. It requires a single well-formed root value.

How to use this file

Use an example JSON file to test parsers and serializers, schema validation, Unicode and number-precision handling, and API request or response processing.

How to use this file for testing

“ICU MessageFormat — Plural offset (English)” is a deterministic Novus Examples fixture for Internationalization, Localization catalogs, JSON parsing. Parallel text and accented, multi-script content — for testing translation pipelines, Unicode handling, and localization tooling.

Documented properties for this file: seed 20260807 · 2 messages · LF. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Translation-catalog fixtures carry the same message set across formats, each with its native placeholder syntax. Test your i18n loader, catalog converter, or translation-memory tool, and use the RTL and CJK variants to check bidirectional text and Unicode handling.

Load the catalog with your i18n framework and verify placeholder interpolation and plural handling; the RTL and CJK variants exercise bidirectional text and font fallback.

Code examples

import json

with open("plural-offset-en.json") as f:
    data = json.load(f)
print(type(data), len(data))

Generated by generation/localization_p7.py. Free for any use, no attribution required — license.