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

fallbackLng as default lng #1552

Closed
ogarich89 opened this issue Feb 14, 2021 · 12 comments · Fixed by #1553
Closed

fallbackLng as default lng #1552

ogarich89 opened this issue Feb 14, 2021 · 12 comments · Fixed by #1553

Comments

@ogarich89
Copy link

Why did you change the behavior in the patch version?

19.8.5 - "use fallbackLng as default lng"

After update, language is always taken from "fallbackLng"
image

The behavior can be viewed in this repository
https://github.com/ogarich89/iso/tree/feature/i18next

@adrai
Copy link
Member

adrai commented Feb 14, 2021

It's just a fallback behaviour if no language and language detector is defined...
Does this hurt you somehow?

@adrai
Copy link
Member

adrai commented Feb 14, 2021

btw: you may also define ru as fallbackLng here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

@ogarich89
Copy link
Author

btw: you may also define ru as fallbackLng here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

I define language here: https://github.com/ogarich89/iso/blob/feature/i18next/src/server/middleware/i18next.ts#L24

Before version 19.8.5 everything worked fine

@adrai
Copy link
Member

adrai commented Feb 14, 2021

The problem is this: https://github.com/ogarich89/iso/blob/feature/i18next/src/server/middleware/i18next.ts#L13
fallbackLng = 'ru'

You are defining a fallbackLng, but i18next does not know this... it know 'en' from here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

in init it is 'en' and outside of i18next you define 'ru' and call changeLanguage afterwards...

So if you want ru to be the fallbackLng i18next needs to know it here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

The i18nextMiddleware only runs on server side, so I suspect there is some sort of timing issue

@adrai
Copy link
Member

adrai commented Feb 14, 2021

I suspect the changeLanguage call is done before i18next has finished to initialize

@ogarich89
Copy link
Author

The problem is this: https://github.com/ogarich89/iso/blob/feature/i18next/src/server/middleware/i18next.ts#L13
fallbackLng = 'ru'

You are defining a fallbackLng, but i18next does not know this... it know 'en' from here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

in init it is 'en' and outside of i18next you define 'ru' and call changeLanguage afterwards...

So if you want ru to be the fallbackLng i18next needs to know it here: https://github.com/ogarich89/iso/blob/feature/i18next/src/shared/libs/i18n.ts#L11

The i18nextMiddleware only runs on server side, so I suspect there is some sort of timing issue

It did not help =(

@adrai
Copy link
Member

adrai commented Feb 14, 2021

what did not help?
Did you change the code to wait for i18next to initialize before calling changeLanguage?

@ogarich89
Copy link
Author

Before update i18next

before.mov

After update to 19.8.5

after.mov

@ogarich89
Copy link
Author

what did not help?
Did you change the code to wait for i18next to initialize before calling changeLanguage?

i18next.isInitialized return true before call changeLanguage

@adrai
Copy link
Member

adrai commented Feb 14, 2021

on server side probably it's initialized, but on client side I don't think so

@ogarich89
Copy link
Author

@adrai
Copy link
Member

adrai commented Feb 16, 2021

Should be better with v19.8.8

adrai added a commit that referenced this issue Mar 24, 2021
* try to fix another edge case issue #1570 introduces by fixing #1552

* [F-1569] Add key name to format function as optional parameter

* [Feature-1569] Re-implemented change with recommendations from project owners

Co-authored-by: Adriano Raiano <adriano@raiano.ch>
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 a pull request may close this issue.

2 participants