Skip to main content
Michelle_Stunka
Level 2
Oct 12, 2018 11:09 AM UTC
Solved

Form Translation Next Steps

I'm in the process of setting up forms to replace many current forms on our site. Each form has to be translated into at least 5 different languages so I'm trying to handle that with Sanford's translation code referenced on this thread: https://nation.marketo.com/message/94034#comment-94034

It's working great but I'm stumped on how to add additional fields to the translation map:

m-files.com/en/marketo-test-form

<div id="translateMap"><span style="display: none;">

{

"en": {

"LastName": {

"placeholder": "Testing-Name",

"submit": "Go Home"

}

},

"fr": {

"LastName": {

"placeholder": "Testing-Name",

"submit": "Go Bonjour"

}

}

}

</span></div>

Any ideas on how I can get the full form setup in this map?

SanfordWhiteman
SanfordWhitemanAccepted solution
User Group Leader
Oct 12, 2018 5:58 PM UTC

Each language is an object, and each field name is a property of that object (and is also an object itself).

So you extend it like so:

{

  "en": {

    "LastName": {

      "placeholder": "Testing-Name",

      "submit": "Go Home"

    },

    "FirstName": {

      "placeholder": "First"

    }

  },

  "fr": {

    "LastName": {

      "placeholder": "Testing-Name",

      "submit": "Go Bonjour"

    },

    "FirstName": {

      "placeholder": "Prénom"

    }

  }

}

The admittedly strange thing about this format, which I wouldn't do again but apparently was lazy about a couple of years ago, is that "submit" should've been a property right on the language. But it's not, so you have to use it as shown.

Please use the Advanced Editor's syntax highlighter in future when posting code:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

11 replies

SanfordWhiteman
User Group Leader
SanfordWhitemanUser Group LeaderAccepted solution
User Group Leader
Oct 12, 2018 5:58 PM UTC

Each language is an object, and each field name is a property of that object (and is also an object itself).

So you extend it like so:

{

  "en": {

    "LastName": {

      "placeholder": "Testing-Name",

      "submit": "Go Home"

    },

    "FirstName": {

      "placeholder": "First"

    }

  },

  "fr": {

    "LastName": {

      "placeholder": "Testing-Name",

      "submit": "Go Bonjour"

    },

    "FirstName": {

      "placeholder": "Prénom"

    }

  }

}

The admittedly strange thing about this format, which I wouldn't do again but apparently was lazy about a couple of years ago, is that "submit" should've been a property right on the language. But it's not, so you have to use it as shown.

Please use the Advanced Editor's syntax highlighter in future when posting code:

https://s3.amazonaws.com/blog-images-teknkl-com/syntax_highlighter.gif

Translate
Michelle_Stunka
Level 2
Oct 12, 2018 6:29 PM UTC

Thanks Sanford! I tried something similar but when I add in what you sent, it stops working altogether: m-files.com/en/marketo-test-form (code is hidden in the privacy policy text)

That's why I was getting completely stumped why it would work for one field but not multiple.

Translate
Michelle_Stunka
Level 2
Oct 12, 2018 6:41 PM UTC

Nevermind! I missed a curly bracket at the very end. Amazing how one character can make all the difference!

Thanks for your help!

Translate