Skip to content

ICU pluralisation in Android React Native app breaks if label has #  #47

@catarinamateus

Description

@catarinamateus

Which package?

"react-native": "0.61.2",
"i18next": "17.2.0",
"i18next-icu": "2.0.3",
"intl-messageformat": "9.4.6",

"@formatjs/intl-getcanonicallocales": "1.8.0",
"@formatjs/intl-locale": "2.4.41",
"@formatjs/intl-pluralrules": "4.2.0",

Describe the bug

When I use plural labels in my JSON and they include '#' following ICU format, these label are broken in my app without throwing any error.

To Reproduce

import i18n, { InitOptions } from 'i18next';
import ICU from 'i18next-icu';
import { initReactI18next } from 'react-i18next';
import '@formatjs/intl-getcanonicallocales/polyfill'
import '@formatjs/intl-locale/polyfill'
import '@formatjs/intl-pluralrules/polyfill'
import '@formatjs/intl-pluralrules/locale-data/en'

//On my app init
 i18n.use(languageDetector(cfg))
        .use(ICU)
        .use(initReactI18next)
        .init({
              fallbackLng: 'en',
               debug: true,
               nsSeparator: ':',
               keySeparator: '.',
               interpolation: {
                  escapeValue: false,
                  formatSeparator: ',',
                },
              react: {
                  wait: true,
                  useSuspense: false,
               },
            resources: {
                en: {
                     error: '{count, plural, one {Recording canceled.} other {Canceled # recordings.}}',
                     success: '{count, plural, one {Recording canceled.} other {Canceled recordings.}}',
                },
            },
        });


//Testing labels

i18n.t('error', {count : 1})
i18n.t('success', {count : 1})

//OUTPUT:  
// Recording canceled.
// Recording canceled.

i18n.('error', {count : 9})
i18n.t('success', {count : 9})

//OUTPUT: 
// {count, plural, one {Recording canceled.} other {Canceled # recordings.}} ---> EXPECTED OUTPUT: Canceled 9 recordings.
// Canceled recordings.

Smartphone (please complete the following information):

Android emulator pixel 30 api 30

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions