Skip to content
Snippets Groups Projects
Commit 38c256e0 authored by Ere Maijala's avatar Ere Maijala
Browse files

Made translation text domain extraction insensitive to multiple occurrences of...

Made translation text domain extraction insensitive to multiple occurrences of '::' in a translation string.
parent ee1c0c94
No related merge requests found
...@@ -167,7 +167,7 @@ trait TranslatorAwareTrait ...@@ -167,7 +167,7 @@ trait TranslatorAwareTrait
*/ */
protected function extractTextDomain($target) protected function extractTextDomain($target)
{ {
$parts = is_array($target) ? $target : explode('::', $target); $parts = is_array($target) ? $target : explode('::', $target, 2);
if (count($parts) < 1 || count($parts) > 2) { if (count($parts) < 1 || count($parts) > 2) {
throw new \Exception('Unexpected value sent to translator!'); throw new \Exception('Unexpected value sent to translator!');
} }
......
...@@ -82,20 +82,6 @@ class TranslateTest extends \PHPUnit_Framework_TestCase ...@@ -82,20 +82,6 @@ class TranslateTest extends \PHPUnit_Framework_TestCase
$translate->__invoke([1, 2, 3]); $translate->__invoke([1, 2, 3]);
} }
/**
* Test invalid translation string
*
* @return void
*
* @expectedException Exception
* @expectedExceptionMessage Unexpected value sent to translator!
*/
public function testTranslateWithDoubleTextDomainArray()
{
$translate = new Translate();
$translate->__invoke('a::b::c');
}
/** /**
* Test translation with a loaded translator * Test translation with a loaded translator
* *
......
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