webpack-contrib / i18n-webpack-plugin

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

Feature: Dynamic property names #78

Open ChrisBAshton opened 6 years ago

ChrisBAshton commented 6 years ago

My team would really benefit from dynamic properties, e.g.

__(`title-${chosenSport}`);

Currently we have to work around the issue by manually maintaining a list of translations at compile time, e.g.

const sportNames = {
    athletics: __('title-athletics'),
    aquatics: __('title-aquatics'),
    ...etc
}

...and then referring to the stored object instead of using __:

sportNames[chosenSport];

We regularly run into this issue and believe it is better solved inside the i18n plugin than in application code. It looks like an attempt at dynamic property names was being worked on in #42, but this turned into a 'plurals' feature in #58, which is not the problem we're trying to solve.

It may be possible for us to work on a PR for you if you are open to the feature idea. Thanks for your time 👍