Commit ff7c25ea by Florian Fackler

Fixes #1497 (wrong file rendered if language != sourceLanguage)

parent 85b5c75b
......@@ -68,7 +68,7 @@ class BaseFileHelper
if ($language === $sourceLanguage) {
return $file;
}
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $sourceLanguage . DIRECTORY_SEPARATOR . basename($file);
$desiredFile = dirname($file) . DIRECTORY_SEPARATOR . $language . DIRECTORY_SEPARATOR . basename($file);
return is_file($desiredFile) ? $desiredFile : $file;
}
......
......@@ -313,4 +313,29 @@ class FileHelperTest extends TestCase
{
$this->assertEquals(DIRECTORY_SEPARATOR.'home'.DIRECTORY_SEPARATOR.'demo', FileHelper::normalizePath('/home\demo/'));
}
public function testLocalizedDirectory()
{
$this->createFileStructure([
'views' => [
'faq.php' => 'English FAQ',
'de-DE' => [
'faq.php' => 'German FAQ',
],
],
]);
$viewFile = $this->testFilePath . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'faq.php';
$sourceLanguage = 'en-US';
// Source language and target language are same. The view path should be unchanged.
$currentLanguage = $sourceLanguage;
$this->assertSame($viewFile, FileHelper::localize($viewFile, $currentLanguage, $sourceLanguage));
// Source language and target language are different. The view path should be changed.
$currentLanguage = 'de-DE';
$this->assertSame(
$this->testFilePath . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . $currentLanguage . DIRECTORY_SEPARATOR . 'faq.php',
FileHelper::localize($viewFile, $currentLanguage, $sourceLanguage)
);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment