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

fix(plural): Create cache entry for PluralRules created as part of the fallback flow #2256

Conversation

nilskaspersson-imtf
Copy link
Contributor

@nilskaspersson-imtf nilskaspersson-imtf commented Nov 20, 2024

This PR extends the fallback flow discussed in #2252 by creating a cache entry for custom language codes.

This avoids a cache miss that would otherwise happen for every invocation with an invalid language code.

The function is restructured to try...catch only the Intl.PluralRules constructor and assign the created value to a variable in the previous closure. This way, the formatted values and cache entry extension can be reused.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin

@adrai adrai merged commit 32ad023 into i18next:master Nov 20, 2024
8 checks passed
@coveralls
Copy link

Coverage Status

coverage: 95.281% (+0.007%) from 95.274%
when pulling 49f1e93 on nilskaspersson-imtf:2252-plural-rules-cache-custom-language
into 1c04c5d on i18next:master.

@adrai
Copy link
Member

adrai commented Nov 20, 2024

thx, it's included in v23.16.8

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

Successfully merging this pull request may close these issues.

3 participants