webpack-contrib / i18n-webpack-plugin

[DEPRECATED] Embed localization into your bundle
MIT License
317 stars 74 forks source link

feat: allow template strings #65

Open scottcanoni opened 6 years ago

scottcanoni commented 6 years ago

This change allows the use of template strings with variables within translated configurations. It looks for translations that explicitly begin with:

"`

and end with

`"

Configuration JSON:

{
  "HelloMessage": "`Hello ${userName}`"
}

Usage:

const userName = 'International User';
const message = __('HelloMessage');

Expected output when rendering message: Hello International User

jsf-clabot commented 6 years ago

CLA assistant check
All committers have signed the CLA.

codecov[bot] commented 6 years ago

Codecov Report

Merging #65 into master will increase coverage by 0.11%. The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
+ Coverage   95.12%   95.23%   +0.11%     
==========================================
  Files           4        4              
  Lines          82       84       +2     
  Branches       23       23              
==========================================
+ Hits           78       80       +2     
  Misses          4        4
Impacted Files Coverage Δ
src/index.js 94.44% <100%> (+0.21%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update dd32318...1985fee. Read the comment docs.

scottcanoni commented 6 years ago

I think I've added the appropriate tests for template strings. Please let me know what you think. Thank you kindly.

It looks like there is some confusion about who I am on Github for the CLA. I used the website to submit the change initially and then I used git commit commands to submit the tests, but if you click through on the test commits you will see its still me. I suspect there is a delay in reconciling the CLA.

michael-ciniawsky commented 6 years ago

@scottcanoni Does the email address you're currently using for your github account and the one you use in your .gitconfig differ ? The CLA Bot thinks you're two different entities in this case and you need to change the commit author of your commits to match to github email address

scottcanoni commented 6 years ago

@michael-ciniawsky I think the CLA bot just took time to re-check. I added my additional email address and verified it under my Github profile and after some time, I see that the CLA bot has marked it as signed.

Also, I moved the eslint disable comment to the top of the file.

scottcanoni commented 6 years ago

@evilebottnawi are the tests that I added adequate?

I am not sure how to resolve this issue on the continuous integration environment: The command "npm --version" failed and exited with 1 during .

michael-ciniawsky commented 6 years ago

ERROR: npm is known not to run on Node.js v4.3.2

That's unrelated to this PR and should be fixed by #64 instead. Just needs sign-off from 1-2 more maintainers and g2g imho

scottcanoni commented 5 years ago

@evilebottnawi and @michael-ciniawsky, now that the unit tests are there, can this be merged?