1

I am currently using Laravel Excel to import data from an excel file into database. When there are some errors occur, I'd like it to report in a foreign language rather than in English which I know I have to use customValidationMessages() function to define the output messages.

This is an example of regular messages:

There was an error on row 2. The somefield has already been taken.
There was an error on row 3. The somefield has already been taken.

Which consists of 2 parts

There was an error on row {some_row}. is the first part.
and
The somefield has already been taken. is the last part

and when I follow the document provided here https://docs.laravel-excel.com/3.1/imports/validation.html#custom-validation-messages all I can output in the foreign language is just the last part but the first part remains in English like this.

There was an error on row 2. ข้อความในภาษาต่างประเทศ
There was an error on row 3. ข้อความในภาษาต่างประเทศ

But I want it to be like this

ข้อความภาษาต่างประเทศแถวที่ 2. ข้อความในภาษาต่างประเทศ
ข้อความภาษาต่างประเทศแถวที่ 3. ข้อความในภาษาต่างประเทศ

How can I do it???

Thank you all in advance

1 Answer 1

1
+50

after inspect the library source, it looks like they use the laravel's localization for that part too: __('There was an error on row :row. :message', ['row' => $this->row, 'message' => $message]);

https://github.com/SpartnerNL/Laravel-Excel/blob/44e165b73eaf182a2f699d905a20684889675b1c/src/Validators/Failure.php#L82

so you can define your own localization message like: "There was an error on row :row. :message" => "ข้อความภาษาต่างประเทศแถวที่ 2 (change to your own message because I don't really know your language)",

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.