Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple fallback keys #249

Closed
rozekfr opened this issue Apr 22, 2023 · 0 comments
Closed

Multiple fallback keys #249

rozekfr opened this issue Apr 22, 2023 · 0 comments

Comments

@rozekfr
Copy link

rozekfr commented Apr 22, 2023

🚀 Feature Proposal

Please implement this essential function of i18next. These keys are removed as unused even if allowDynamicKeys turned on. Maybe you don't consider the case that the input of the function t can be an array. Here is the link to Multiple fallback keys - i18next essentials.

Motivation

Calling the t function with an array of keys enables you to translate dynamic keys providing a non specific fallback value.

Example

As a sample think of an error code you get and you like to show a specific warning in some cases:

keys

{
  "error": {
    "unspecific": "Something went wrong.",
    "404": "The page was not found."
  }
}

sample

// const error = '404';
i18next.t([`error.${error}`, 'error.unspecific']); // -> "The page was not found"

// const error = '502';
i18next.t([`error.${error}`, 'error.unspecific']); // -> "Something went wrong"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants