I have coded a directive to translate strings to a given locale and dynamically update according to scope variables.
I would like feedback on whether the approach I've taken has issues, and if it can be done better.
As an example, a string with a variable number would need to respond to pluralization rules, with three cases in English, like:
You took no samples.
You took 1 sample.
You took 5 samples.
I would like a directive that looks like:
<span gl-translate options='{"count":{{count}}}'>hints.sample.counting</span>
the rendered result, if {{count}} is 0, would look like;
<span gl-translate="" options="{'count':{{count}}}">You took no samples</span>
Where glTranslate is the name of the directive,
the contents of the directive 'hints.sample.counting' is a key for some translation library,
and the options attribute captures the options to the translation function. Here the options attribute has a binding to the scope variable 'count'
The directive link function would call some translation function, using the key 'hints.sample.counting' and passing the options as well.
Which is a library the make Ruby on Rails translations available in Javascript.
Thanks for any feedback,
TsenYing