Localization
Easy Forms supports localization using Laravel's built-in localization system. To translate the fieldtype UI, use the JSON file approach by creating a file in the lang directory at the root of your project and adding translations for the strings used by the addon.
For example, let's say you want to translate the UI of the dictionary fieldtype to French. You would create a file called lang/fr.json with the following content:
{
"Search": "Rechercher",
"Please select": "Veuillez sélectionner",
}You can use the same method to translate any label or custom placeholder you have set. For example, let's say you have a dictionary fieldtype with the settings below:
handle: countries
field:
dictionary:
type: countries
emojis: true
type: dictionary
display: 'Country'
placeholder: 'Select a country'
instructions: 'Please select a country from the list below.'You would translate the label, placeholder and instructions like this:
{
"Search": "Rechercher",
"Country": "Pays",
"Select a country": "Sélectionnez un pays",
"Please select a country from the list below.": "Veuillez sélectionner un pays de la liste ci-dessous."
}Validation messages
Validation messages are provided by Laravel. They usually work in a wide variety of languages out of the box. To translate or edit them, you should first publish the language files:
php artisan lang:publishThen, translate the messages located in the lang/**/validation.php file.
Multisite submissions
On multisite installations, Statamic's form submission route is not localized, so validation and reCAPTCHA error messages would normally render in the default site's locale regardless of the page the form is on.
Easy Forms fixes this automatically: it sets the application locale from the site of the referring page, so error messages are returned in the language of the page the form was submitted from. This is enabled by default and requires no configuration.
If you need to disable it, set the following in your .env file:
EASY_FORMS_LOCALIZE_SUBMISSIONS=falseAlternatively, publish the config file and set the localize_submissions option:
php artisan vendor:publish --tag="easy-forms-config"// config/easy-forms.php
'localize_submissions' => false,Dictionaries
You can translate the Country Phone Codes dictionary by publishing the translation file:
php artisan vendor:publish --tag="statamic-easy-forms-translations"Then, edit the lang/vendor/statamic-easy-forms/country_phone_codes.php file.