Skip to content

Commit d3ae1f6

Browse files
committed
fix export
1 parent 332c108 commit d3ae1f6

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/Services/Exporter/CsvExporterService.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ public function export(array $translationsByLocale, string $path): string
3737
->all();
3838

3939
foreach ($keys as $key) {
40+
41+
$values = array_map(function ($locale) use ($translationsByLocale, $key) {
42+
return $translationsByLocale[$locale][$key] ?? null;
43+
}, $locales);
44+
4045
$writer->addRow([
4146
'key' => $key,
42-
...array_map(fn ($locale) => $translationsByLocale[$locale]->get($key), $locales),
47+
...$values,
4348
]);
4449
}
4550

@@ -65,10 +70,11 @@ public function import(string $path): array
6570

6671
foreach ($row as $locale => $value) {
6772

68-
$translationsByLocale[$locale] = [
69-
...($translationsByLocale[$locale] ?? []),
70-
$key => $value,
71-
];
73+
if (! array_key_exists($locale, $translationsByLocale)) {
74+
$translationsByLocale[$locale] = [];
75+
}
76+
77+
$translationsByLocale[$locale][$key] = $value;
7278

7379
}
7480

0 commit comments

Comments
 (0)