-
-
Notifications
You must be signed in to change notification settings - Fork 520
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 bug with pluralization or interpolation of 'null' message + tests #393
Conversation
I think it should still throw an error unless option |
Hi @PikachuEXE, I agree with you, it shouldn't return It should return something like If I have this YAML structure: nl:
badges:
title:
counting:
one:
other:
zero: Why should there be a difference between:
and
What do you think? |
I am OK with returning an error message when null value is encountered |
Sorry @PikachuEXE but are you ok with returning a text message (like we suggested) or with raising an error message (like it is now). We are not sure about it :p If you're ok with returning a text (error) message, we'll investigate the code and try to achieve that. |
Sorry for being unclear :) |
Cool, we'll try to make something out of this :-) |
Any movement on this PR? We have to manually prune this stuff out in our current workflow. Would be great to get this fixed up! |
I am waiting for PR starter to change the PR |
I forgot about this. I'll try to work on this issue soon (this week?) but I don't know if I'll find my way into the code to trigger a "missing translation" message. I'll keep you in touch. @claytron In the meantime, you can apply my fix to avoid JS errors (keys with null values will be replaced by empty strings without any error). |
I hope this fix will solve the issue without introducing new bugs. @PikachuEXE please check here : https://github.com/fnando/i18n-js/pull/393/files#diff-e731291dab1a6ee00870b26bf608dbffL533 I didn't understand why "scope" was sometimes an object. I removed this part and always send the scope as a string. Do you see any problem with that? |
That method is called from |
I guess before you change it |
I think it looks fine right now. |
Hi @PikachuEXE, good news! Thanks for the review. Sorry but I don't really know how to properly squash the commits. I had to merge your master in my branch and I don't know what to do with all these commits (maybe I should have used If you prefer I can recreate these changes in a new "clean" branch (there are not so many), but can't you chose to squash the commits when accepting the pull request? |
OK I guess I can try that |
Hi there,
This is a small pull request about a bug we are facing right now.
If we use YAML with this kind of keys:
it's transformed to this in the .js file:
And, if we use
I18n.t("badges.counting", {count: 2})
, we have an JavaScript errorCannot read property 'match' of undefined
.We solved it by returning an empty string instead of triggering the error. Would it be an acceptable solution for you?