Favor call message over element message on matches#16
Open
bauerca wants to merge 2 commits intodrd:masterfrom
Open
Favor call message over element message on matches#16bauerca wants to merge 2 commits intodrd:masterfrom
bauerca wants to merge 2 commits intodrd:masterfrom
Conversation
test/test-translation.js
Outdated
| '<Pluralize:items><Match when="=0">You have no items in your cart</Match><Match when="one">You have one item in your cart</Match><Match when="other">You have {this.state.count} items in your cart</Match></Pluralize:items>': | ||
| '<Pluralize:items><Match when="=0">No tiene nada in su carrito</Match><Match when="one">Tiene ún articulo en su carrito</Match><Match when="other">Tiene {this.state.count} articulos en su carrito</Match></Pluralize:items>' | ||
| '<Pluralize:items><Match when="=0">No tiene nada in su carrito</Match><Match when="one">Tiene ún articulo en su carrito</Match><Match when="other">Tiene {this.state.count} articulos en su carrito</Match></Pluralize:items>', | ||
| 'Hey': 'Hey' |
Owner
|
This is one solution to this. Another solution would be to change how bundles are defined at translation time, where you could keep separate objects for element/call messages and then merge with the call messages winning. That's a bit of a deeper change so I'm fine with this, but if you're feeling plucky I'd be happy to assist with the other way! I'll merge this after you fix the commas. <3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
It is possible for
i18n("string")and<I18N>string</I18N>to exist in the same project. If the element version is parsed by jsxlate after the function call version, the bundle will contain:when it should return:
because the result of the function call should be a string and not a React element. The jsxlate
<I18N>component is smart enough to wrap the string in a<span>if it does not receive a React element from the translation renderer.This PR fixes the issue by preferring the function-call renderer (which returns a string) over the jsx element renderer when their messages match.