ufirstgroup / laravel-lang-import-export

A Laravel package providing artisan commands to import and export language files from and to CSV
MIT License
41 stars 40 forks source link

Problem with overwriting existing files #12

Closed ta-ppyszczek closed 3 years ago

ta-ppyszczek commented 3 years ago

Hi @mruoss, I have a problem with importing translations. I run import with file: key,pl test.test_meessage_1,"Message 1"

The file is properly imported and inserting content to resources/lang/pl/test.php

Then I run import with file: key,pl test.test_meessage_2,"Message 2" After that I've got only content of the second import file in resources/lang/pl/test.php. Translations which exists in this file are deleted.

I don't know if this is the expected behavior, but I found that the problem is in ImportFromCsvCommand.php In the line 116 there is Arr::set($translations, $key, $value[$locale]);

This creates undoted keys in doted array $translations. After that the content of translations is: array:2 [ "test.test_meessage_1" => "Message 1" "test" => array:1 [ "test_meessage_2" => "Message 2" ] ]

That's why when the content is saved, only the second translation exists.

Can I create pull request to change that?

Thank you