summaryrefslogtreecommitdiff
path: root/vendor/symfony/translation/Reader
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2018-12-18 15:41:12 +0000
committerGreg Roach <fisharebest@webtrees.net>2018-12-18 16:30:56 +0000
commit362be83a34a1d0ba0292c4387f55a3b0ea10cb2f (patch)
treee80de41bd6c005d10f3df8380f8fa1018f6bbf3d /vendor/symfony/translation/Reader
parentb906b74e5e71be459a4cb8e5aa77b0802655d75a (diff)
downloadwebtrees-362be83a34a1d0ba0292c4387f55a3b0ea10cb2f.tar.gz
webtrees-362be83a34a1d0ba0292c4387f55a3b0ea10cb2f.tar.bz2
webtrees-362be83a34a1d0ba0292c4387f55a3b0ea10cb2f.zip
Add support for Laravel query-builder
Diffstat (limited to 'vendor/symfony/translation/Reader')
-rw-r--r--vendor/symfony/translation/Reader/TranslationReader.php63
-rw-r--r--vendor/symfony/translation/Reader/TranslationReaderInterface.php30
2 files changed, 93 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Reader/TranslationReader.php b/vendor/symfony/translation/Reader/TranslationReader.php
new file mode 100644
index 0000000000..948edec492
--- /dev/null
+++ b/vendor/symfony/translation/Reader/TranslationReader.php
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Translation\Reader;
+
+use Symfony\Component\Finder\Finder;
+use Symfony\Component\Translation\Loader\LoaderInterface;
+use Symfony\Component\Translation\MessageCatalogue;
+
+/**
+ * TranslationReader reads translation messages from translation files.
+ *
+ * @author Michel Salib <michelsalib@hotmail.com>
+ */
+class TranslationReader implements TranslationReaderInterface
+{
+ /**
+ * Loaders used for import.
+ *
+ * @var array
+ */
+ private $loaders = array();
+
+ /**
+ * Adds a loader to the translation extractor.
+ *
+ * @param string $format The format of the loader
+ * @param LoaderInterface $loader
+ */
+ public function addLoader($format, LoaderInterface $loader)
+ {
+ $this->loaders[$format] = $loader;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function read($directory, MessageCatalogue $catalogue)
+ {
+ if (!is_dir($directory)) {
+ return;
+ }
+
+ foreach ($this->loaders as $format => $loader) {
+ // load any existing translation files
+ $finder = new Finder();
+ $extension = $catalogue->getLocale().'.'.$format;
+ $files = $finder->files()->name('*.'.$extension)->in($directory);
+ foreach ($files as $file) {
+ $domain = substr($file->getFilename(), 0, -1 * \strlen($extension) - 1);
+ $catalogue->addCatalogue($loader->load($file->getPathname(), $catalogue->getLocale(), $domain));
+ }
+ }
+ }
+}
diff --git a/vendor/symfony/translation/Reader/TranslationReaderInterface.php b/vendor/symfony/translation/Reader/TranslationReaderInterface.php
new file mode 100644
index 0000000000..0aa55c6d36
--- /dev/null
+++ b/vendor/symfony/translation/Reader/TranslationReaderInterface.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\Translation\Reader;
+
+use Symfony\Component\Translation\MessageCatalogue;
+
+/**
+ * TranslationReader reads translation messages from translation files.
+ *
+ * @author Tobias Nyholm <tobias.nyholm@gmail.com>
+ */
+interface TranslationReaderInterface
+{
+ /**
+ * Reads translation messages from a directory to the catalogue.
+ *
+ * @param string $directory
+ * @param MessageCatalogue $catalogue
+ */
+ public function read($directory, MessageCatalogue $catalogue);
+}