coderifous / jquery-localize

a jQuery plugin that makes it easy to internationalize your web site.
465 stars 142 forks source link

Localize parameters #59

Open oskrabanek opened 9 years ago

oskrabanek commented 9 years ago

As a developer I would appreciate if the plugin could use parameters so that I don't have to localize any strings with eg. numbers or other constant strings. In most cases it can be solved by separately localized "span" tags, but in particular cases such as "option" tags you can't. In this case localizing separately each string just because it differs only in the number is waste of space and developers time (not to mention it isn't very elegant).

Example:

Localized JSON { my_option: "My option {0}.{1}" }

HTML:

<select>
<option data-localize="my_option" data-localize-params="1, 1"></option>
<option data-localize="my_option" data-localize-params="1, 2"></option>
<option data-localize="my_option" data-localize-params="2, 1"></option>
<option data-localize="my_option" data-localize-params="2, 2"></option>
<!-- etc. -->
</select>

Result: Select with options: My option 1.1 My option 1.2 My option 2.1 My option 2.2

coderifous commented 8 years ago

Hi, Ondřej. This looks like an interesting feature, but I'd probably rather see it implemented leveraging some standard template library, and definitely not with position-based bindings. I don't personally have a need for this (or the time to implement it), and I'm not confident it's a feature that belongs in this library.