Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Sören Deger 726 posts 2833 karma points c-trib
    Jan 07, 2015 @ 20:27
    Sören Deger

    How use parameter with localizationService in Angularjs?

    Hi all,

    I have this line in a angularjs controller:

    notificationsService.success(localizationService.localize("mail2cms_settingsLoaded", $scope.mailbox.eMail));

    My key in en.xml looks like this:

    <key alias="settingsLoaded"><![CDATA[Settings for '%0%' are loaded!]]></key>

    The value of $scope.mailbox.eMail is a string like this: [email protected]

    But if I load my page with this custom property editor in a custom section I get only this notification:

    The parameter is truncate to 1 char. Have anyone an explanation for this?

    Or is the syntax for using a parameter in localizationService wrong? Unfortunately, I have not found this in the documentation on


    Best regards


  • Sören Deger 726 posts 2833 karma points c-trib
    Jan 09, 2015 @ 06:27
    Sören Deger

    I have a look into and I realized why it doesn't work.

    I need to pass an array as a parameter instead of strings.

    In my example above the code in angularjs controller must look like this:

    $scope.tokens = []; 
    $scope.tokens[0] = $scope.mailbox.eMail;
    notificationsService.success(localizationService.localize("mail2cms_settingsLoaded", $scope.tokens));


    I hope this helps anyone with similar problems.




  • Søren Erland Vestø 19 posts 42 karma points
    Jan 18, 2019 @ 12:19
    Søren Erland Vestø

    A minor detail, but you don't actually need the "tokens" array. You can just do

    localizationService.localize('area_keytoparametizedvalue', ['valueofparameter0']);

    Other than that you spared me a headache :-)

  • Bjarne Fyrstenborg 1179 posts 3435 karma points MVP 4x c-trib
    Feb 21, 2015 @ 14:11
    Bjarne Fyrstenborg

    Hi Sören

    Thanks for sharing this

    I had a similar case, where I needed to translate the messages in the notifications.
    But I didn't need to pass any arguments - just use the translation key from the respective language file in /Umbraco/Config/Lang/ 

    I managed to solve it like this:


    where the language file hae a format like this:

    <language alias="en" intName="English (UK)" localName="English (UK)" lcid="" culture="en-GB">
      <area alias="analytics">
        <key alias="settingsSaved">Settings have been saved</key>
        <key alias="accountDetailsSaved">Account details have been saved</key>
        <key alias="profileDetailsSaved">Profile details have been saved</key>


  • Sören Deger 726 posts 2833 karma points c-trib
    Feb 23, 2015 @ 11:44
    Sören Deger

    Hi Bjarne,

    thank you. Yes, this is the way without passing any arguments and will work if you have language entries without variables.


Please Sign in or register to post replies

Write your reply to: