Nova · i18n

Counted phrases

No book can hold “4 left”: the number makes the rows endless. The row is the pattern, {n} left. It is translated whole, so the words may change places, and then its holes are closed. They close in the source language too, so a component is never handed the pattern itself.

The action, as it is written
{
  id: 'i18n-patterns',
  data: { left: 4, sold: 16, seats: 20 },
  layout: {
    component: 'Stack',
    children: [
      {
        component: 'Badge',
        props: { label: { phrase: '{n} left', slots: { n: '$.left' } } },
      },
      {
        component: 'Badge',
        props: {
          label: {
            phrase: '{n} of {total}',
            slots: { n: '$.sold', total: '$.seats' },
          },
        },
      },
    ],
  },
}
The book it is drawn through
{
  {n} left: 'noch {n}',
  {n} of {total}: '{n} von {total}',
}
What is done to it
Nothing. It is only drawn.
What it then holds
{ left: 4, sold: 16, seats: 20 }
What it then says
noch 4
16 von 20
Output matches the expected value

Runs in this page on the installed package. The input and the expected output are defined by the example.