Skip to content

Commit 68b3db5

Browse files
authored
Merge pull request #51 from geekstek/3.x
add Import Action Translation and Chinese Translations
2 parents e4097ee + 8103232 commit 68b3db5

File tree

7 files changed

+78
-13
lines changed

7 files changed

+78
-13
lines changed

resources/lang/en/excel-import.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,23 @@
22

33
// translations for EightyNine/ExcelImportAction
44
return [
5-
'validation_failed' => 'Row :row failed validation. The following messages were returned: :messages',
5+
// Import Action Labels
6+
'import_action_heading' => 'Import Excel',
7+
'import_action_description' => 'Import data into database from Excel file',
8+
'excel_data' => 'Excel Data',
69
'download_sample_excel_file' => 'Download Sample Excel File',
10+
11+
// Import Status Messages
712
'import_failed' => 'Import Failed',
813
'import_warning' => 'Import Warning',
914
'import_information' => 'Import Information',
1015
'import_success' => 'Import Success',
16+
17+
// Validation Messages
18+
'validation_failed' => 'Row :row failed validation. The following messages were returned: :messages',
19+
20+
// File Validation Errors
21+
'file_empty_error' => 'The uploaded file is empty or has no valid data.',
22+
'header_read_error' => 'Unable to read the header row from the uploaded file.',
23+
'missing_headers_error' => 'Missing required headers: :missing. Expected headers: :expected',
1124
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
// translations for EightyNine/ExcelImportAction
4+
return [
5+
// 导入操作标签
6+
'import_action_heading' => '导入Excel',
7+
'import_action_description' => '从Excel文件导入数据到数据库',
8+
'excel_data' => 'Excel数据',
9+
'download_sample_excel_file' => '下载Excel模板文件',
10+
11+
// 导入状态消息
12+
'import_failed' => '导入失败',
13+
'import_warning' => '导入警告',
14+
'import_information' => '导入信息',
15+
'import_success' => '导入成功',
16+
17+
// 验证消息
18+
'validation_failed' => '第 :row 行验证失败。返回以下错误信息::messages',
19+
20+
// 文件验证错误
21+
'file_empty_error' => '上传的文件为空或没有有效数据。',
22+
'header_read_error' => '无法读取上传文件的标题行。',
23+
'missing_headers_error' => '缺少必需的标题列::missing。期望的标题列::expected',
24+
];
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
// translations for EightyNine/ExcelImportAction
4+
return [
5+
// 匯入操作標籤
6+
'import_action_heading' => '匯入Excel',
7+
'import_action_description' => '從Excel檔案匯入資料到資料庫',
8+
'excel_data' => 'Excel資料',
9+
'download_sample_excel_file' => '下載Excel範本檔案',
10+
11+
// 匯入狀態訊息
12+
'import_failed' => '匯入失敗',
13+
'import_warning' => '匯入警告',
14+
'import_information' => '匯入資訊',
15+
'import_success' => '匯入成功',
16+
17+
// 驗證訊息
18+
'validation_failed' => '第 :row 行驗證失敗。返回以下錯誤訊息::messages',
19+
20+
// 檔案驗證錯誤
21+
'file_empty_error' => '上傳的檔案為空或沒有有效資料。',
22+
'header_read_error' => '無法讀取上傳檔案的標題行。',
23+
'missing_headers_error' => '缺少必需的標題欄::missing。期望的標題欄::expected',
24+
];

src/Concerns/HasExcelImportAction.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ protected function setUp(): void
5252
->color('success')
5353
->modalWidth('md')
5454
->modalAlignment('center')
55-
->modalHeading(fn ($livewire) => __('Import Excel'))
56-
->modalDescription(__('Import data into database from excel file'))
55+
->modalHeading(fn ($livewire) => __('excel-import::excel-import.import_action_heading'))
56+
->modalDescription(__('excel-import::excel-import.import_action_description'))
5757
->modalFooterActionsAlignment('right')
5858
->closeModalByClickingAway(false)
5959
->action('importData');

src/Concerns/HasUploadForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,10 +125,10 @@ protected function getUploadField()
125125
->acceptedFileTypes($this->acceptedFileTypes)
126126
->label(function ($livewire) {
127127
if (! method_exists($livewire, 'getTable')) {
128-
return __('Excel Data');
128+
return __('excel-import::excel-import.excel_data');
129129
}
130130

131-
return str($livewire->getTable()->getPluralModelLabel())->title() . ' ' . __('Excel Data');
131+
return str($livewire->getTable()->getPluralModelLabel())->title() . ' ' . __('excel-import::excel-import.excel_data');
132132
})
133133
->default(1)
134134
->storeFiles($this->storeFiles)

src/EnhancedDefaultImport.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,23 @@ protected function stopImportWithSuccess(string $message): void
8181
protected function validateHeaders(array $expectedHeaders, Collection $collection): void
8282
{
8383
if ($collection->isEmpty()) {
84-
$this->stopImportWithError('The uploaded file is empty or has no valid data.');
84+
$this->stopImportWithError(__('excel-import::excel-import.file_empty_error'));
8585
}
8686

8787
$firstRow = $collection->first();
8888
if (!$firstRow) {
89-
$this->stopImportWithError('Unable to read the header row from the uploaded file.');
89+
$this->stopImportWithError(__('excel-import::excel-import.header_read_error'));
9090
}
9191

9292
$actualHeaders = array_keys($firstRow->toArray());
9393
$missingHeaders = array_diff($expectedHeaders, $actualHeaders);
9494

9595
if (!empty($missingHeaders)) {
9696
$this->stopImportWithError(
97-
'Missing required headers: ' . implode(', ', $missingHeaders) .
98-
'. Expected headers: ' . implode(', ', $expectedHeaders)
97+
__('excel-import::excel-import.missing_headers_error', [
98+
'missing' => implode(', ', $missingHeaders),
99+
'expected' => implode(', ', $expectedHeaders)
100+
])
99101
);
100102
}
101103
}

src/EnhancedDefaultRelationshipImport.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,23 @@ protected function stopImportWithSuccess(string $message): void
8787
protected function validateHeaders(array $expectedHeaders, Collection $collection): void
8888
{
8989
if ($collection->isEmpty()) {
90-
$this->stopImportWithError('The uploaded file is empty or has no valid data.');
90+
$this->stopImportWithError(__('excel-import::excel-import.file_empty_error'));
9191
}
9292

9393
$firstRow = $collection->first();
9494
if (!$firstRow) {
95-
$this->stopImportWithError('Unable to read the header row from the uploaded file.');
95+
$this->stopImportWithError(__('excel-import::excel-import.header_read_error'));
9696
}
9797

9898
$actualHeaders = array_keys($firstRow->toArray());
9999
$missingHeaders = array_diff($expectedHeaders, $actualHeaders);
100100

101101
if (!empty($missingHeaders)) {
102102
$this->stopImportWithError(
103-
'Missing required headers: ' . implode(', ', $missingHeaders) .
104-
'. Expected headers: ' . implode(', ', $expectedHeaders)
103+
__('excel-import::excel-import.missing_headers_error', [
104+
'missing' => implode(', ', $missingHeaders),
105+
'expected' => implode(', ', $expectedHeaders)
106+
])
105107
);
106108
}
107109
}

0 commit comments

Comments
 (0)