@eliumhq/elium-i18n
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -7,3 +7,3 @@ { | ||
"license": "UNLICENSED", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"engines": { | ||
@@ -10,0 +10,0 @@ "node": ">=9", |
/* | ||
From https://github.com/i18next/i18next-scanner/blob/master/src/nodes-to-string.js | ||
Adatpted following https://github.com/i18next/react-i18next/blob/master/src/Trans.js | ||
The MIT License (MIT) | ||
@@ -42,3 +44,3 @@ | ||
return node.type === 'Literal' && typeof node.value === 'number' | ||
return node.type === 'NumericLiteral' && typeof node.value === 'number' | ||
} | ||
@@ -51,3 +53,3 @@ | ||
return node.type === 'Literal' && typeof node.value === 'string' | ||
return node.type === 'StringLiteral' && typeof node.value === 'string' | ||
} | ||
@@ -77,2 +79,15 @@ | ||
memo += value | ||
} else if (node.children) { | ||
/* Support with lists */ | ||
if ( | ||
node.type === 'JSXElement' && | ||
node.openingElement.attributes && | ||
node.openingElement.attributes.some( | ||
attribute => attribute.name.type === 'JSXIdentifier' && attribute.name.name === 'i18nIsDynamicList' | ||
) | ||
) { | ||
memo += `<${nodeIndex}></${nodeIndex}>` | ||
} else { | ||
memo += `<${nodeIndex}>${nodesToString(node.children)}</${nodeIndex}>` | ||
} | ||
} else if (node.type === 'JSXExpressionContainer') { | ||
@@ -87,4 +102,4 @@ const { expression = {} } = node | ||
memo += expression.value | ||
} else if (isObjectExpression(expression) && _get(expression, 'properties[0].type') === 'Property') { | ||
memo += `<${nodeIndex}>{{${expression.properties[0].key.name}}}</${nodeIndex}>` | ||
} else if (isObjectExpression(expression) && _get(expression, 'properties[0].type') === 'ObjectProperty') { | ||
memo += `{{${expression.properties[0].key.name}}}` | ||
} else { | ||
@@ -98,4 +113,2 @@ console.error( | ||
} | ||
} else if (node.children) { | ||
memo += `<${nodeIndex}>${nodesToString(node.children)}</${nodeIndex}>` | ||
} | ||
@@ -102,0 +115,0 @@ |
19624
443