How to use the @lingui/core.i18n.plural function in @lingui/core

To help you get started, we’ve selected a few @lingui/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / lingui__core / lingui__core-tests.ts View on Github external
MessageOptions,
    LanguageData,
    I18n,
    date,
    number,
    i18nMark
} from '@lingui/core';

const age = 12;
const templateResult: string = i18n.t`${age} years old`;
const templateIdResult: string = i18n.t('templateId')`${age} years old`;
const translateResult: string = i18n._('age', { age }, { defaults: '{age} years old' });

const count = 42;

const pluralResult: string = i18n.plural({
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});
const pluralIdResult: string = i18n.plural('pluralId', {
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});

const selectOrdinalResult: string = i18n.selectOrdinal({
    value: count,
    0: 'Zeroth book',
    one: '#st book',
github DefinitelyTyped / DefinitelyTyped / types / lingui__core / lingui__core-tests.ts View on Github external
const selectOrdinalIdResult: string = i18n.selectOrdinal('selectOrdinalId', {
    value: count,
    0: 'Zeroth book',
    one: '#st book',
    two: '#nd book',
    few: '#rd book',
    other: '#th book'
});

const gender = 'female';
const numOfGuests = 2;
const host = 'Amy';
const guest = 'Bob';
const selectResult = i18n.select({
    value: gender,
    female: i18n.plural({
        value: numOfGuests,
        offset: 1,
        0: i18n.t`${host} does not give a party.`,
        1: i18n.t`${host} invites ${guest} to her party.`,
        2: i18n.t`${host} invites ${guest} and one other person to her party.`,
        other: i18n.t`${host} invites ${guest} and # other people to her party.`
    }),
    male: 'male',
    other: 'other'
});

const selectIdResult = i18n.select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
github DefinitelyTyped / DefinitelyTyped / types / lingui__core / lingui__core-tests.ts View on Github external
} from '@lingui/core';

const age = 12;
const templateResult: string = i18n.t`${age} years old`;
const templateIdResult: string = i18n.t('templateId')`${age} years old`;
const translateResult: string = i18n._('age', { age }, { defaults: '{age} years old' });

const count = 42;

const pluralResult: string = i18n.plural({
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});
const pluralIdResult: string = i18n.plural('pluralId', {
    value: count,
    0: 'no books',
    one: '# book',
    other: '# books'
});

const selectOrdinalResult: string = i18n.selectOrdinal({
    value: count,
    0: 'Zeroth book',
    one: '#st book',
    two: '#nd book',
    few: '#rd book',
    other: '#th book'
});
const selectOrdinalIdResult: string = i18n.selectOrdinal('selectOrdinalId', {
    value: count,