diff --git a/src/Helpers/Translation/Translator.php b/src/Helpers/Translation/Translator.php index 8b11ecb4..d42e4bcf 100644 --- a/src/Helpers/Translation/Translator.php +++ b/src/Helpers/Translation/Translator.php @@ -106,7 +106,7 @@ class Translator return $key; } - return call_user_func_array('sprintf', array_merge([$key], $replace)); + return call_user_func_array('sprintf', array_merge([$key], array_values($replace))); } /** diff --git a/tests/Unit/Helpers/Translation/TranslatorTest.php b/tests/Unit/Helpers/Translation/TranslatorTest.php index 5e341cfd..8c646850 100644 --- a/tests/Unit/Helpers/Translation/TranslatorTest.php +++ b/tests/Unit/Helpers/Translation/TranslatorTest.php @@ -128,8 +128,8 @@ class TranslatorTest extends ServiceProviderTest // Fallback translation $this->assertEquals('Lorem test2???', $translator->translate('foo.batz', ['test2'])); - // Successful translation - $this->assertEquals('Lorem test3!', $translator->translatePlural('foo.barf', 'foo.bar2', 3, ['test3'])); + // Successful translation, keys in replaces should be ignored + $this->assertEquals('Lorem test3!', $translator->translatePlural('foo.barf', 'foo.bar2', 3, ['x' => 'test3'])); } /**