webpack-contrib / i18n-webpack-plugin

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

Process expressions. #12

Closed bvsn closed 7 years ago

bvsn commented 8 years ago

Is there an option for processing expressions in text?

Example:

__("Message to " + email + " sent successfully")
ronkorving commented 8 years ago

When dealing with translation you should always do variable replacement after the translation. My suggestion:

__('Message to %email sent successfully').replace('%email', 'foo@example.com');

bvsn commented 8 years ago

Yeah, I thought about this option but decided to ask. Thanks for the answer.

ronkorving commented 8 years ago

I'm not the author of this library, but yeah... In general I think this is best practice.

sokra commented 8 years ago

yeah.

debbiepeng commented 8 years ago

I am trying to define my json files this way: { "Greetings": "Hallo Welt" }, so that I can have strings in the json as key value pairs. And I call it like this: const defaultText = "Hello World"; __(defaultText, "Greetings");

But this can't be processed. I think it's due to defaultText not being a string literal. Is this an intended limitation?

Thanks.

michael-ciniawsky commented 7 years ago

Closing in favour of #6