1

I'm using Craft Commerce v2 on a Craft 3 Pro website.

The checkout process of the shop includes a number of forms such as the ones that visitor can use to add or edit shopping and billing addresses. All the templates are based on the demo templates for Craft Commerce and I haven't created any of those input fields using Settings > Fields.

When an error occurs in one of those forms, an error message is displayed as expected under each input field. However, the error messages are not fully localized. For example, if a field is required and the form is submitted without a value for that field, then the error message appears localised except for the title of the required field.

In this error message: The field "First Name" must not be empty.

the name of the field, First Name, is not localized.

e.g. Το «First Name» δεν μπορεί να είναι κενό.

How can I localize the «First Name» part?

1

User accounts’ First Name field isn’t required, so I’m guessing this is a custom field?

You can translate your custom field names using static message translations.

Create a new file at translations/<Language>/site.php:

my-project.test/
├── config/
├── ...
└── translations/
    └── <Language>/
        └── site.php

(replace <Language> with your language ID, e.g. el.)

Then have it return an array that translates your custom field names.

<?php

return [
    'First Name' => 'Ονομα',
];
  • Thanks for the reply. I'm already using translations/el/site.php for localization and I have already added the translation of First name and other field names there as suggested. The problem is that the error messages for 'el' appear like this: Το «First Name» δεν μπορεί να είναι κενό. (The field 'First name' cannot be empty). – Panos Spiliotis Sep 3 '18 at 17:14
  • @PanosSpiliotis can you confirm that this is for a custom field that you created in Settings > Fields? If not please update your question with more context. – Brandon Kelly Sep 3 '18 at 17:49
  • No, these are not custom fields. I used those fields as part of the demo templates of Craft Commerce, which I adapted for the needs of the website I am working on. I have updated my question with more information. – Panos Spiliotis Sep 4 '18 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.