javascript - i18next - Providing a key in data-i18n-options attribute for interpolation -
currently using i18next.js , have run in problem.
say there's 2 keys:
{ 'keyone':'i __name__', 'item': 'a person' }
in html:
<div data-i18n="keyone" data-i18n-options={"name":"item"}></div>
and result i'd like:
'i person'
where 'a person' isn't string literal reference key (i.e. using data-i18n attribute)
would possible provide 'item' key (not string 'a person') use in 'keyone' interpolation? useful when change locale i'd have call .i18n() on div , both keys translated. without functionality i'd have re-evaluate context , update div manually.
any appreciated. thanks
i18next has nesting functionality: http://i18next.com/translate/nesting/
so make want. can test in jsfiddle: https://jsfiddle.net/leonardonsantos/3zy4xmnm/1/
just change in data-i18n-options
$t
:
<div data-i18n="keyone" data-i18n-options='{"name":"$t(item)"}'>
Comments
Post a Comment