internationalization - Forcing string interpolation in Jade -


i trying use jade string interpolation + i18n

i wrote custom tag

mixin unsubscribe    a(title='unsubscribe_link', href='#{target_address}/',       target='_blank', style='color:#00b2e2;text-decoration:none;')    = __("click here") 

then got following work

p   | #[+unsubscribe] unsubscribe 

however, in order support i18n wrap the whole string in translation block function called __().

but when wrap string in code block no longer renders custom tag.

p   | #{__("#[+unsubscribe] unsubscribe")}  p   = __("#[+unsubscribe] unsubscribe") 

will output literally [+unsubscribe] unsubscribe. there way force returned string function?

edit 1

as has been pointed out, nesting "click here" doesn't make sense, since creating separate strings.

my goal create simplified text string can passed off translation service:

so ideally should be:

"#[+unsubscribe('click here')] unsubscribe"

and back

"klicken sie #[+unsubscribe hier] um ihr auszutragen"

my reasoning because using gettext match exact strings, abstract out logic behind tag.

what want achieve this:

<p>   <a href='the link' title='it should translated!'       target='_blank' class='classes better'>click here</a> unsubscribe </p> 

and reason don't want include tags in translation. well, unfortunately separating 'click here' 'to unsubscribe' result in incorrect translations languages - translator needs context. better use tag.

and way: things __('click here') doesn't allow different translation of string based on context. have no idea translation tool you're using, should use identifiers rather english texts.

going original question, believe can use parametrized mixin it:

mixin unsubscribe(title, target_address, click_here, to_unsubscribe)   a(title=title, href=target_address, target='_blank', style='color:#00b2e2;text-decoration:none;')= click_here     span= to_unsubscribe 

this of course result in additional <span> tag , still not solve real issue (separating "click here" "to unsubscribe") , no way re-order sentence, but... guess valid option have interpolation built-in translation engine , writing out unescaped tag. otherwise you'd need redesign page avoid link inside sentence.


Comments