Skip to content

Instantly share code, notes, and snippets.

@enagy27
Created November 18, 2023 00:53
Show Gist options
  • Save enagy27/fcfe7e215085f4ace6f7193eb30ce1c2 to your computer and use it in GitHub Desktop.
Save enagy27/fcfe7e215085f4ace6f7193eb30ce1c2 to your computer and use it in GitHub Desktop.
Before and after comparison of the intl plural helper versus standard ICU format
// before
intl.formatMessage(
{
id: 'TemplateSearchResults.templates',
defaultMessage:
'{templatesCount, plural, one {{templatesCount} template} other {{templatesCount} templates}}',
description: 'Number of templates in a section',
},
{
templatesCount: category.numberOfTemplates,
}
)
// after
intl.formatMessage(
{
id: 'TemplateSearchResults.templates',
defaultMessage: plural('templatesCount', {
one: '{templatesCount} template',
other: '{templatesCount} templates',
}),
description: 'Number of templates in a section',
},
{
templatesCount: category.numberOfTemplates,
}
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment