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 getFixedT function always returning values in current language #1916

Merged
merged 3 commits into from
Jul 22, 2022

Conversation

Jyrno42
Copy link
Contributor

@Jyrno42 Jyrno42 commented Jul 22, 2022

I was running into an issue where getFixedT always returned values in the current language not the requested language. I found this issue - #1184 about it. The fix for it was merged in and released and seemed to work. However a bit later the fix got reverted as people did not expect all locales to be loaded by the library. See the following issue - #1267.

This PR proposes a potential new argument to the serverSideTranslations function (could also be a config override field really). This argument can be used to provide extra locales to load for the specific page and allows one to opt into loading more or all locales. As a result getFixedT will then work for the locales that are loaded for the page.

If the general direction/idea is accepted I will clean this PR up and will add tests/documentation updates too.

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

@adrai
Copy link
Member

adrai commented Jul 22, 2022

sounds interesting... can you also adapt the readme and add a test?

@Jyrno42
Copy link
Contributor Author

Jyrno42 commented Jul 22, 2022

Sure I'll do that.

Do you think the extra argument is fine or should I move it into configOverride?

@adrai
Copy link
Member

adrai commented Jul 22, 2022

configOverride is the passed in next-i18next config... so I think the extra argument should be ok.

@Jyrno42 Jyrno42 changed the title [WIP] Fix getFixedT function always returning values in current language Fix getFixedT function always returning values in current language Jul 22, 2022
@adrai adrai merged commit 242c266 into i18next:master Jul 22, 2022
adrai added a commit that referenced this pull request Jul 22, 2022
@adrai
Copy link
Member

adrai commented Jul 22, 2022

Thank you for your contribution.
Included in v11.3.0

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.

2 participants