Displaying i18n text on HTML-button depending on condition Aurelia -
hi trying dynamically change text depending on boolean. im using aurelia i18n, 1 solution have method returns want. have in html, because think clearer see text button have depending on bool in html code. looks now:
<button>${account.changed ? '_cancel' | t : '_close' | t } </button>
this have tried:
<button>${account.changed ? ('_cancel' | t) : ('_close' | t) } </button> <button>${account.changed ? ${'_cancel' | t} : ${'_close' | t} } </button>
any of tries ends crash:
error: parser error: conditional expression account.changed ? '_cancel' requires 3 expressions @ column 33 in [account.changed ? '_cancel' | t : '_close' | t ]
i have used i18n this point:
<div>${'example | t'}</div>
never needed change text depending on condition before.
to comes here, solved doing this:
innerhtml.bind="!account.changed ? close : cancel"
and in .js
this.close = this.i18n.tr('_close'); this.cancel = this.i18n.tr('_cancel');
i think should possible in way achive directly in html aurelia
this i'm using:
<span t="_cancel" if.bind="account.changed"></span><span t="_close" if.bind="!account.changed"></span>
i stuck on while , best way found it.
Comments
Post a Comment