From 3b8e95fcca1730e192792b06c103d7c524f901ce Mon Sep 17 00:00:00 2001 From: James Cole Date: Sat, 20 Jul 2019 16:48:35 +0200 Subject: [PATCH] Fix #1652 --- app/Import/Storage/ImportArrayStorage.php | 13 +++++++++++-- resources/lang/en_US/import.php | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/Import/Storage/ImportArrayStorage.php b/app/Import/Storage/ImportArrayStorage.php index 56dbf5be3e..54481974b7 100644 --- a/app/Import/Storage/ImportArrayStorage.php +++ b/app/Import/Storage/ImportArrayStorage.php @@ -31,6 +31,7 @@ use FireflyIII\Events\RequestedReportOnJournals; use FireflyIII\Exceptions\FireflyException; use FireflyIII\Helpers\Collector\GroupCollectorInterface; use FireflyIII\Models\ImportJob; +use FireflyIII\Models\Preference; use FireflyIII\Models\Rule; use FireflyIII\Models\TransactionGroup; use FireflyIII\Models\TransactionType; @@ -68,6 +69,9 @@ class ImportArrayStorage /** @var TransactionGroupRepositoryInterface */ private $groupRepos; + /** @var string */ + private $language = 'en_US'; + /** * Set job, count transfers in the array and create the repository. * @@ -87,6 +91,11 @@ class ImportArrayStorage $this->groupRepos = app(TransactionGroupRepositoryInterface::class); $this->groupRepos->setUser($importJob->user); + // get language of user. + /** @var Preference $pref */ + $pref = app('preferences')->get('language', config('firefly.default_language', 'en_US')); + $this->language = $pref->data; + Log::debug('Constructed ImportArrayStorage()'); } @@ -276,7 +285,7 @@ class ImportArrayStorage $hash = $this->getHash($transaction); $existingId = $this->hashExists($hash); if (null !== $existingId) { - $message = sprintf('Row #%d ("%s") could not be imported. It already exists.', $index, $transaction['description']); + $message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]); $this->logDuplicateObject($transaction, $existingId); $this->repository->addErrorMessage($this->importJob, $message); @@ -285,7 +294,7 @@ class ImportArrayStorage // do transfer detection: if ($this->checkForTransfers && $this->transferExists($transaction)) { - $message = sprintf('Row #%d ("%s") could not be imported. Such a transfer already exists.', $index, $transaction['description']); + $message = (string)trans('import.duplicate_row', ['row' => $index, 'description' => $transaction['description']]); $this->logDuplicateTransfer($transaction); $this->repository->addErrorMessage($this->importJob, $message); diff --git a/resources/lang/en_US/import.php b/resources/lang/en_US/import.php index 7bd146fa73..3a907af062 100644 --- a/resources/lang/en_US/import.php +++ b/resources/lang/en_US/import.php @@ -310,4 +310,7 @@ return [ 'column_note' => 'Note(s)', 'column_internal-reference' => 'Internal reference', + // error message + 'duplicate_row' => 'Row #:row (":description") could not be imported. It already exists.', + ];