Skip to content

Improve i18n warnings #9097

Open
Open
@jmooring

Description

@jmooring

Details

Pluralization warnings were eliminated during the implementation of #8497.

i18n/pl.toml

[day]
other = "miesiąca"
Statement Result Current Warning Desired Warning
{{ i18n "day" }} miesiąca
{{ i18n "day" 0 }} miesiąca WARN ... "day" has no plural form "many"
{{ i18n "day" 1 }} miesiąca WARN ... "day" has no plural form "one"
{{ i18n "day" 2 }} miesiąca WARN ... "day" has no plural form "few"
{{ i18n "day" "1.5" }} miesiąca

Ref: https://unicode-org.github.io/cldr-staging/charts/37/supplemental/language_plural_rules.html

Background

The motivation behind #8497 was to suppress warnings when site authors translate words or phrases that do not require pluralization, using this construct:

i18n/es.toml

[contact]
other = "contacto"

and then invoke the translation without specifying a quantity: {{ i18n "contact" }}

Ideally, all i18n files should have this structure:

# Items without pluralization rules.

contact = "contacto"
help = "ayuda"

# Items with pluralization rules.

[day]
one = "día"
other = "días"

Approach

Detect when the i18n function has been passed a quantity (including zero). If there's a quantity (including zero), perform the i18n lookup and emit warnings as needed. If there's not a quantity, do what we're doing now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions