Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions build/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ function translateMessagesToBundle(src, translationsSrc) {

function attemptToCreateRenderer(node, message) {
if (translations[message]) {
if ((0, _ast.isElementMarker)(node) && bundle[message]) {
return;
}
bundle[message] = (0, _translation2.default)(node, translations[message], message);
} else {
missing[message] = message;
Expand Down
3 changes: 3 additions & 0 deletions src/translate.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export default function translateMessagesToBundle(src, translationsSrc, {inputFo

function attemptToCreateRenderer(node, message) {
if (translations[message]) {
if (isElementMarker(node) && bundle[message]) {
return;
}
bundle[message] = translatedRendererFor(
node,
translations[message],
Expand Down
6 changes: 4 additions & 2 deletions test/test-translation.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ describe('translation', function() {
'Check out: <Component />': '<Component/> "checked" out!',
'<span:stat><ReactIntl.FormattedNumber /></span:stat>opportunities': '<span:stat><ReactIntl.FormattedNumber /></span:stat>oportunidades',
'<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',
};

var expectedResultsForTranslationBundles = {
Expand All @@ -38,7 +39,8 @@ describe('translation', function() {
'<I18N>Check out: <Component gnar={3 * shnar}/></I18N>': 'function(Component, shnar) { return <span><Component gnar={3 * shnar} /> "checked" out!</span>; }',
'<I18N><Re /><Ordering /></I18N>': 'function(Re, Ordering) { return <span><Ordering /><Re /></span>; }',
'<I18N><Pluralize:items on={this.state.count}><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></I18N>':
'function(Pluralize, Match) { return <span><Pluralize on={this.state.count}><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></span>; }'
'function(Pluralize, Match) { return <span><Pluralize on={this.state.count}><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></span>; }',
'i18n("Hey");<I18N>Hey</I18N>': 'function() { return "Hey"; }',
};

Object.keys(expectedResultsForTranslationBundles).forEach(original => {
Expand Down