-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
655 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace JMS\TranslationBundle\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* | ||
* @author Krisztián Ferenczi <[email protected]> | ||
*/ | ||
final class TransArrayKeys | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $domain = 'messages'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace JMS\TranslationBundle\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* | ||
* @author Krisztián Ferenczi <[email protected]> | ||
*/ | ||
final class TransArrayValues | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $domain = 'messages'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace JMS\TranslationBundle\Annotation; | ||
|
||
/** | ||
* @Annotation | ||
* | ||
* @author Krisztián Ferenczi <[email protected]> | ||
*/ | ||
final class TransString | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
public $domain = 'messages'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
Tests/Translation/Extractor/File/AnnotationExtractorTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
/* | ||
* Copyright 2011 Johannes M. Schmitt <[email protected]> | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
namespace JMS\TranslationBundle\Tests\Translation\Extractor\File; | ||
|
||
use JMS\TranslationBundle\Model\Message; | ||
use JMS\TranslationBundle\Model\MessageCatalogue; | ||
use JMS\TranslationBundle\Translation\Extractor\File\AnnotationExtractor; | ||
use JMS\TranslationBundle\Translation\Extractor\File\DefaultPhpFileExtractor; | ||
|
||
class AnnotationExtractorTest extends BasePhpFileExtractorTest | ||
{ | ||
public function testExtractController() | ||
{ | ||
$catalogue = $this->extract('Controller.php'); | ||
|
||
$fileSourceFactory = $this->getFileSourceFactory(); | ||
$fixtureSplInfo = new \SplFileInfo(__DIR__.'/Fixture/Controller.php'); | ||
|
||
$expected = new MessageCatalogue(); | ||
|
||
$message = new Message('simple.text1'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 94)); | ||
$expected->add($message); | ||
|
||
$message = new Message('simple.text2'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 95)); | ||
$message->addAlternativeTranslation('en', 'Simple text 2'); | ||
$expected->add($message); | ||
|
||
$message = new Message('subarray.value1', 'subarray'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 100)); | ||
$message->addAlternativeTranslation('en', 'Sub array value1'); | ||
$expected->add($message); | ||
|
||
$message = new Message('subarray.value2', 'subarray'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 102)); | ||
$message->addAlternativeTranslation('en', 'Sub array value2'); | ||
$expected->add($message); | ||
|
||
$message = new Message('user.role.partner'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 108)); | ||
$expected->add($message); | ||
|
||
$message = new Message('user.role.supporter'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 109)); | ||
$expected->add($message); | ||
|
||
$message = new Message('user.role.admin'); | ||
$message->addSource($fileSourceFactory->create($fixtureSplInfo, 110)); | ||
$expected->add($message); | ||
|
||
$this->assertEquals($expected, $catalogue); | ||
} | ||
|
||
protected function getDefaultExtractor() | ||
{ | ||
return new AnnotationExtractor($this->getDocParser(), $this->getFileSourceFactory()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.