Skip to content

Commit 7ecb152

Browse files
committed
fix import
1 parent d3ae1f6 commit 7ecb152

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

src/Services/Exporter/CsvExporterService.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,9 @@ public function import(string $path): array
7474
$translationsByLocale[$locale] = [];
7575
}
7676

77-
$translationsByLocale[$locale][$key] = $value;
77+
if ($value) {
78+
$translationsByLocale[$locale][$key] = $value;
79+
}
7880

7981
}
8082

tests/Feature/ExportTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@
2323
Storage::disk('csv')->assertExists($file);
2424
});
2525

26+
/**
27+
* Warning
28+
*
29+
* Conflicts might occur when keys are different between locales
30+
* If `en` define `auth.message.title` and `fr` define `auth.message`, `auth.message.title` might be overriden
31+
*/
2632
it('imports all locales and keys from a csv file', function () {
2733
$translator = new Translator(
2834
driver: $this->getPhpDriver(),
@@ -35,10 +41,12 @@
3541
'en' => [
3642
'messages.hello' => 'Hello',
3743
'messages.add' => 'Add',
44+
'messages.nested.foo' => 'Foo',
3845
],
3946
'fr' => [
4047
'messages.hello' => 'Bonjour',
4148
'messages.add' => 'Ajouter',
49+
'messages.nested' => 'Nested',
4250
],
4351
]);
4452

tests/files/import.csv

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
key,en,fr
22
messages.hello,Hello,Bonjour
33
messages.add,Add,Ajouter
4+
messages.nested.foo,Foo,
5+
messages.nested,,Nested

0 commit comments

Comments
 (0)