Localization

Form Localization

You can localize field labels just like you do this in Open Content.
In short you can create an options file per language and add a "label" for each field.

{
    "type": "object",
    "properties": {
        "Name": {
            "title": "Name",
            "type": "string"
        },
        "Email": {
            "title": "Email",
            "type": "string",
            "required": true
        },
 		"Phone": {
            "title": "Phone",
            "type": "string",
            "required": false
        },
       	"Message": {
            "title": "Message",
            "type": "string",
            "required": true
        }
    }
}
{
  "fields": {
   "Name": {
      "type": "text",
	  "label": "Name"
    },
    "Email": {
      "type": "email",
	  "label": "Email"
    },
	 "Phone": {
      "type": "text",
	  "label": "Phone number"
    },
    "Message": {
      "type": "textarea",
	  "label": "Your message"
    }
  }
}
{
  "fields": {
     "Name": {
	  "label": "Votre Nom"
    },
    "Email": {
	  "label": "E-mail"
    },
	 "Phone": {
	  "label": "Téléphone"
    },
    "Message": {
	  "label": "Message"
    }
}

Alpaca Localization

Alpaca comes with a number of translations : https://github.com/gitana/alpaca/tree/master/src/js/messages/i18n

To activate the messages in a language you have to add "locale": "es_ES" in the view.json.

{
 "locale": "es_ES"
}

You can also add your customes translations in the view.json :

{
  "messages": {
   	"es_ES": {
     "stringValueTooLarge": "Mira, caballero, tu nombre es demasiado largo!",
     "notOptional": "Hello not optional",
   	}
 	}
}

For more info : http://www.alpacajs.org/docs/api/i18n.html

📘

Caution for modifications of view.json

If you use the form builder the view.json is automatically generated.
If you customize the view.json, best is to disable the form builder by deleting the builder.json file in your template folder (by hand).
Otherwise you risk your changes being overwritten as soon as you make changes to the form using the builder.