Skip to content

Disallow plural-suffixed keys as t values #1849

Open
i18next/i18next
#2322
@cbejensen

Description

@cbejensen

🚀 Feature Proposal

Enable disallowing plural-suffixed keys as the first argument to t, perhaps through CustomTypeOptions.

Motivation

  1. The TS autocomplete list for t can easily become very large and hard to look through.
  2. I'd never do t('key_one') or t('key_other'), I'd always do t('key', { count }).

Considering these, it would be great if the plural-suffixed variations of keys were not considered valid. This would drastically decrease the number of options in my IDE autocomplete and help discourage bad practice. Currently, a key in English with _one and _other suffixes creates 6 possible values:

  • key
  • key_one
  • key_other
  • translation:key
  • translation:key_one
  • translation:key_other

This could be only 2 values if we removed the plural-suffixed options.

Example

I type t(', then ctrl+space to open autocomplete, and I only see the basic keys without plural suffixes.

Additionally, if I try to include the plural suffix in the key instead of using the count option for some reason, I get a type error, which is desired.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions