-
Notifications
You must be signed in to change notification settings - Fork 53
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
added string concatenation and template string support for javascript #67
Conversation
Codecov Report
@@ Coverage Diff @@
## master #67 +/- ##
=========================================
+ Coverage 98.27% 98.9% +0.63%
=========================================
Files 5 5
Lines 348 366 +18
Branches 60 63 +3
=========================================
+ Hits 342 362 +20
+ Misses 6 4 -2
Continue to review full report at Codecov.
|
34525d6
to
776d90d
Compare
5f42c4d
to
15a2010
Compare
@Eclar may I consider this PR ready to review ? :) |
@Eclar ? |
Oui ! Ready for review. I think :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few notes, and I'd be very pleased with a short changelog for the next version anouncement ! Thanks for the contribution :)
src/javascript-extract.js
Outdated
let valueToTranslate = currentToken.value; | ||
|
||
if (nextToken.value === '+') { | ||
valueToTranslate = extractConcat(valueToTranslate, allTokens, i + 2 * (argIndex + 1)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the value i + 2 * (argIndex + 1)
could be clearer and more DRY with a variable, like nextTokenIndex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which would give code like:
const nextToken = allTokens[nextTokenIndex + 1];
const closingToken = allTokens[nextTokenIndex + 2];
valueToTranslate = extractConcat(valueToTranslate, allTokens, nextToken)
src/javascript-extract.js
Outdated
@@ -22,6 +22,17 @@ function toPoItem(withLineNumbers = false) { | |||
return poItem; | |||
} | |||
|
|||
function extractConcat(value, allTokens, index) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe a small comment to explain that this function is intended to concatenate multiline strings would be nice !
"Hello there!" + | ||
" I am a concatenated string," + | ||
"\\n" + | ||
" please translate me." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be interested in a test that shows the concatenation of two strings WITHOUT a line return in between. As such I'm not 100% convinced it is supported.
@Ouradze are you up ? :) |
Yes ! On it, hopefully, I'll get that done this weekend :) |
@vperron better late than never. I took your comments into account :) |
Thank you so much for your contribution :) |
This pull request has two parts: