-
Notifications
You must be signed in to change notification settings - Fork 89
Grab first available language as default if one isn't set, localize missing translation fallbacks #110
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
Conversation
…lt if a default language isn't provided
…efore passing it as a value
Both ComponentClass and Component should be imported from `react`. `react-redux` doesn't contain those two.
Codecov Report
@@ Coverage Diff @@
## master #110 +/- ##
=========================================
+ Coverage 95.51% 95.6% +0.08%
=========================================
Files 6 6
Lines 245 250 +5
Branches 73 77 +4
=========================================
+ Hits 234 239 +5
Misses 10 10
Partials 1 1
Continue to review full report at Codecov.
|
|
@colbyfayock I've had to create a new PR as I don't think I have access to push to the branch your work was in. I've included your original changes in this PR, but made some changes as well. After some thought I realized a lot of the complications were because This issue made it clear that there really is no reason for In addition I have taken care of all the flow issues. When you get a chance if you could have a look, and see if this still solves all the issues you were having. It passes the initial tests you wrote so I think we're good, but want to double check. |
|
@ryandrewjohnson that works, np. thanks for including the work :) that all looks like it makes sense - and if the tests pass 👍i won't have a chance to actually pull that into the project i'm working with until next week, but the tests I set up should cover the same use cases I was running into issues with thanks for looking at that |
Credit to @colbyfayock for the original fix included in this PR 🎉
Fix for #101
Two issues:
The application doesn't take the first item as a default language when a defaultLanguage isn't present
When falling back to the default translation using onMissingTranslation, the translation doesn't run through getLocalizedElement which prevents any variables from getting parsed
Solution
defaultLanguage
The getOptions function now falls back to the first available language if a defaultLanguage isn't provided.
onMissingTranslation
The logic for onMissingTranslation has been moved out of
getLocalizedElementand intogetTranslate, which makes more sense asgetLocalizedElementdoesn't care whether translations are missing or not - It just wants a string to localize.