diff --git a/src/Config/TranslatorConfig.php b/src/Config/TranslatorConfig.php index 28a48e1f..2aa8a621 100644 --- a/src/Config/TranslatorConfig.php +++ b/src/Config/TranslatorConfig.php @@ -105,7 +105,7 @@ public function getLocaleDirectory(string $locale, ?string $directory = null): s return \rtrim($directory, '/') . '/' . $locale . '/'; } - return \trim($this->getLocalesDirectory(), '/') . '/' . $locale . '/'; + return \rtrim($this->getLocalesDirectory(), '/') . '/' . $locale . '/'; } /** diff --git a/tests/ConfigTest.php b/tests/ConfigTest.php index e8072588..2f53437f 100644 --- a/tests/ConfigTest.php +++ b/tests/ConfigTest.php @@ -101,6 +101,15 @@ public function testLocaleDirectoryWithDirectoryParam(): void $this->assertSame('directory/en/', $config->getLocaleDirectory('en', 'directory/')); } + public function testLocaleDirectoryLeadingSlash(): void + { + $config = new TranslatorConfig([ + 'directory' => '/directory/locale' + ]); + + $this->assertSame('/directory/locale/en/', $config->getLocaleDirectory('en')); + } + public function testDomains(): void { $config = new TranslatorConfig([