Jeffrey Roosendaal
Jeffrey Roosendaal

Reputation: 7157

Translating multiple translationIds using AngularJS's translation directive

I'm using PascalPrecht's AngularJS Translation module.


{
    APP.WELCOME: 'Welcome',
    APP.USER: 'user'
}

<span translate>{{'APP.WELCOME'}}</span> <span translate>{{'APP.USER'}}</span>

Works fine. It outputs Welcome user.


Now, is it possible to combine two translationId's in one element? I've tried multiple things:

<span translate>{{'APP.WELCOME'}} {{'APP.USER'}}</span>

<span translate>{{'APP.WELCOME APP.USER'}}</span>

<span translate>{{'APP.WELCOME' + 'APP.USER'}}</span>

<span translate>{{'APP.WELCOME'; 'APP.USER'}}</span>

<span translate>{{['APP.WELCOME','APP.USER']}}</span>

but nothings seems to work.

Any suggestions? Is this even possible?

Upvotes: 1

Views: 1043

Answers (1)

MarcoS
MarcoS

Reputation: 17721

Try using two double brackets elements inside a single <span>, and translate as a $filter:

<span>{{'APP.WELCOME' | translate }} {{ 'APP.USER' | translate }}</span>

It should work...

Upvotes: 1

Related Questions