-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added XliffCoventer * Code style * Fixes * Made classes final and added composer alias * Added changlog
- Loading branch information
Showing
8 changed files
with
93 additions
and
625 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Change Log | ||
|
||
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. | ||
|
||
## 0.2.0 | ||
|
||
### Changed | ||
|
||
- Made`TranslationLoader` final | ||
|
||
### Removed | ||
|
||
- `FileDumper` in favor for `FlysystemXliffDumper` | ||
- `XliffFileLoader` in favor for `FlysystemXliffLoader` | ||
- `XliffFileDumper` | ||
|
||
## 0.1.0 | ||
|
||
Init release | ||
|
||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ | |
|
||
namespace Translation\PlatformAdapter\Flysystem\Dumper; | ||
|
||
use Symfony\Component\Translation\Dumper\DumperInterface; | ||
use Symfony\Component\Translation\Dumper\XliffFileDumper; | ||
use Symfony\Component\Translation\MessageCatalogue; | ||
use Symfony\Component\Translation\Exception\InvalidArgumentException; | ||
use League\Flysystem\Filesystem; | ||
|
@@ -27,7 +27,7 @@ | |
* @author Michel Salib <[email protected]> | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
abstract class FileDumper implements DumperInterface | ||
final class FlysystemXliffDumper extends XliffFileDumper | ||
{ | ||
/** | ||
* @var Filesystem | ||
|
@@ -109,24 +109,6 @@ public function dump(MessageCatalogue $messages, $options = []) | |
} | ||
} | ||
|
||
/** | ||
* Transforms a domain of a message catalogue to its string representation. | ||
* | ||
* @param MessageCatalogue $messages | ||
* @param string $domain | ||
* @param array $options | ||
* | ||
* @return string representation | ||
*/ | ||
abstract public function formatCatalogue(MessageCatalogue $messages, $domain, array $options = []); | ||
|
||
/** | ||
* Gets the file extension of the dumper. | ||
* | ||
* @return string file extension | ||
*/ | ||
abstract protected function getExtension(); | ||
|
||
/** | ||
* Gets the relative file path using the template. | ||
* | ||
|
This file was deleted.
Oops, something went wrong.
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,58 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the PHP Translation package. | ||
* | ||
* (c) PHP Translation team <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Translation\PlatformAdapter\Flysystem\Loader; | ||
|
||
use League\Flysystem\Filesystem; | ||
use Symfony\Component\Translation\MessageCatalogue; | ||
use Symfony\Component\Translation\Exception\NotFoundResourceException; | ||
use Symfony\Component\Config\Resource\FileResource; | ||
use Translation\SymfonyStorage\Loader\XliffLoader; | ||
|
||
/** | ||
* XliffFileLoader loads translations from XLIFF files. | ||
* | ||
* @author Tobias Nyholm <[email protected]> | ||
*/ | ||
final class FlysystemXliffLoader extends XliffLoader | ||
{ | ||
/** | ||
* @var Filesystem | ||
*/ | ||
private $filesystem; | ||
|
||
/** | ||
* @param Filesystem filesystem | ||
*/ | ||
public function __construct(Filesystem $filesystem) | ||
{ | ||
$this->filesystem = $filesystem; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function load($resource, $locale, $domain = 'messages') | ||
{ | ||
if (!$this->filesystem->has($resource)) { | ||
throw new NotFoundResourceException(sprintf('File "%s" not found.', $resource)); | ||
} | ||
|
||
$catalogue = new MessageCatalogue($locale); | ||
$this->extractFromContent($this->filesystem->read($resource), $catalogue, $domain); | ||
|
||
if (class_exists('Symfony\Component\Config\Resource\FileResource')) { | ||
$catalogue->addResource(new FileResource($resource)); | ||
} | ||
|
||
return $catalogue; | ||
} | ||
} |
Oops, something went wrong.