Skip to content

Commit

Permalink
Fix bug related to aliasing default domain translations. (#4167)
Browse files Browse the repository at this point in the history
  • Loading branch information
demiankatz authored Dec 17, 2024
1 parent 9ca264e commit bcb1fa2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public function load($locale, $filename)
*/
public function getLanguageFilename($locale, $domain)
{
return empty($domain)
return (empty($domain) || $domain === 'default')
? $locale . '.ini'
: $domain . '/' . $locale . '.ini';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,11 +172,11 @@ public function testMissingPathStack(): void
}

/**
* Test alias behavior.
* Test alias behavior in default domain.
*
* @return void
*/
public function testAliasing(): void
public function testAliasingInDefaultDomain(): void
{
$pathStack = [
realpath($this->getFixtureDir() . 'language/aliases'),
Expand All @@ -195,6 +195,27 @@ public function testAliasing(): void
);
}

/**
* Test alias behavior in non-default domain.
*
* @return void
*/
public function testAliasingInNonDefaultDomain(): void
{
$pathStack = [
realpath($this->getFixtureDir() . 'language/aliases'),
];
$loader = new ExtendedIni($pathStack, 'en');
$result = $loader->load('en', 'Domain');
$this->assertEquals(
[
'bar' => 'Domain Translation',
'foofoo' => 'Translation',
],
(array)$result
);
}

/**
* Test circular alias infinite loop prevention.
*
Expand Down

0 comments on commit bcb1fa2

Please sign in to comment.