Skip to content

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:

json
{
    "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:

yaml
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:

json
{
    "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:

bash
php artisan lang:publish

Then, translate the messages located in the lang/**/validation.php file.

Dictionaries

You can translate the Country Phone Codes dictionary by publishing the translation file:

bash
php artisan vendor:publish --tag="statamic-easy-forms-translations"

Then, edit the lang/vendor/statamic-easy-forms/country_phone_codes.php file.