From 0d5d911d9f55acfbdb29d2b3b7261252b65cb4ca Mon Sep 17 00:00:00 2001 From: vidmantas Date: Wed, 6 Sep 2017 17:25:32 +0300 Subject: [PATCH 01/28] requeired field translated --- Form/Type/TranslationType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/Type/TranslationType.php b/Form/Type/TranslationType.php index 499a5802..88d8ff9b 100644 --- a/Form/Type/TranslationType.php +++ b/Form/Type/TranslationType.php @@ -22,7 +22,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('locale', 'Symfony\Component\Form\Extension\Core\Type\HiddenType'); $builder->add('content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array( - 'required' => false, + 'required' => true, )); } From 0d9f2cc13c2560cbff9f46a005b5db4063f286f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 15:01:45 +0300 Subject: [PATCH 02/28] lt-1 --- Model/TransUnit.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/TransUnit.php b/Model/TransUnit.php index 43736000..561cfebf 100644 --- a/Model/TransUnit.php +++ b/Model/TransUnit.php @@ -35,6 +35,8 @@ abstract class TransUnit /** * @var \Doctrine\Common\Collections\Collection + * + * @Assert\NotBlank() */ protected $translations; From 118a43ab818cff0e565266e795b03cd896087609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 15:10:13 +0300 Subject: [PATCH 03/28] lt-1 --- Model/TransUnit.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/Model/TransUnit.php b/Model/TransUnit.php index 561cfebf..43736000 100644 --- a/Model/TransUnit.php +++ b/Model/TransUnit.php @@ -35,8 +35,6 @@ abstract class TransUnit /** * @var \Doctrine\Common\Collections\Collection - * - * @Assert\NotBlank() */ protected $translations; From 890623ef9eee35b206b49bdfc9659fdf0931198c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 15:24:31 +0300 Subject: [PATCH 04/28] lt-1 --- Model/TransUnit.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Model/TransUnit.php b/Model/TransUnit.php index 43736000..561cfebf 100644 --- a/Model/TransUnit.php +++ b/Model/TransUnit.php @@ -35,6 +35,8 @@ abstract class TransUnit /** * @var \Doctrine\Common\Collections\Collection + * + * @Assert\NotBlank() */ protected $translations; From 911be3131236f9b6e8b9f3e675accf73dff03af0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 15:39:11 +0300 Subject: [PATCH 05/28] Translation required --- Form/Type/TransUnitType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Form/Type/TransUnitType.php b/Form/Type/TransUnitType.php index 7f67e178..28382bb2 100644 --- a/Form/Type/TransUnitType.php +++ b/Form/Type/TransUnitType.php @@ -28,7 +28,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('translations', 'Symfony\Component\Form\Extension\Core\Type\CollectionType', array( 'entry_type' => 'Lexik\Bundle\TranslationBundle\Form\Type\TranslationType', 'label' => 'translations.page_title', - 'required' => false, + 'required' => true, 'entry_options' => array( 'data_class' => $options['translation_class'], ), From b1cda6ba5d95be9f71cc882451178b21862dcff9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 16:22:12 +0300 Subject: [PATCH 06/28] Translation required --- Form/Handler/TransUnitFormHandler.php | 3 +++ Model/TransUnit.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/Form/Handler/TransUnitFormHandler.php b/Form/Handler/TransUnitFormHandler.php index e4075642..890c49bb 100644 --- a/Form/Handler/TransUnitFormHandler.php +++ b/Form/Handler/TransUnitFormHandler.php @@ -89,6 +89,9 @@ public function process(FormInterface $form, Request $request) if ($form->isValid()) { $transUnit = $form->getData(); + if (!$transUnit->validForBlankTranslations()) { + return false; + } $translations = $transUnit->filterNotBlankTranslations(); // only keep translations with a content // link new translations to a file to be able to export them. diff --git a/Model/TransUnit.php b/Model/TransUnit.php index 43736000..0b88c29e 100644 --- a/Model/TransUnit.php +++ b/Model/TransUnit.php @@ -192,6 +192,22 @@ public function filterNotBlankTranslations() }); } + /** + * Return false if at least one translation without content. + * + * @return bool + */ + public function validForBlankTranslations() + { + foreach ($this->getTranslations() as $translation) { + if (empty($translation->getContent())) { + return false; + } + } + + return true; + } + /** * Get createdAt * From a2d825882a57343cd7318663e0024e590f0d2d99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C4=99stutis?= Date: Thu, 14 Sep 2017 16:37:32 +0300 Subject: [PATCH 07/28] Constraints not blank --- Form/Handler/TransUnitFormHandler.php | 3 --- Form/Type/TransUnitType.php | 4 ++++ Form/Type/TranslationType.php | 4 ++++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Form/Handler/TransUnitFormHandler.php b/Form/Handler/TransUnitFormHandler.php index 890c49bb..e4075642 100644 --- a/Form/Handler/TransUnitFormHandler.php +++ b/Form/Handler/TransUnitFormHandler.php @@ -89,9 +89,6 @@ public function process(FormInterface $form, Request $request) if ($form->isValid()) { $transUnit = $form->getData(); - if (!$transUnit->validForBlankTranslations()) { - return false; - } $translations = $transUnit->filterNotBlankTranslations(); // only keep translations with a content // link new translations to a file to be able to export them. diff --git a/Form/Type/TransUnitType.php b/Form/Type/TransUnitType.php index 28382bb2..8c0c3569 100644 --- a/Form/Type/TransUnitType.php +++ b/Form/Type/TransUnitType.php @@ -5,6 +5,7 @@ use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; /** * TransUnit form type. @@ -29,6 +30,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'entry_type' => 'Lexik\Bundle\TranslationBundle\Form\Type\TranslationType', 'label' => 'translations.page_title', 'required' => true, + 'constraints' => array( + new NotBlank(), + ), 'entry_options' => array( 'data_class' => $options['translation_class'], ), diff --git a/Form/Type/TranslationType.php b/Form/Type/TranslationType.php index 88d8ff9b..e0fa4732 100644 --- a/Form/Type/TranslationType.php +++ b/Form/Type/TranslationType.php @@ -7,6 +7,7 @@ use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormInterface; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\NotBlank; /** * Translation form type. @@ -23,6 +24,9 @@ public function buildForm(FormBuilderInterface $builder, array $options) $builder->add('locale', 'Symfony\Component\Form\Extension\Core\Type\HiddenType'); $builder->add('content', 'Symfony\Component\Form\Extension\Core\Type\TextareaType', array( 'required' => true, + 'constraints' => array( + new NotBlank(), + ), )); } From 51b3bf697ba63b88800e82f084ea4be0fe5cfd08 Mon Sep 17 00:00:00 2001 From: Imanali Mamadiev Date: Wed, 6 Sep 2017 20:59:05 +0600 Subject: [PATCH 08/28] Remove unnecessary stuff (#256) --- Manager/FileManager.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Manager/FileManager.php b/Manager/FileManager.php index 7ed5e948..64282cc7 100644 --- a/Manager/FileManager.php +++ b/Manager/FileManager.php @@ -46,11 +46,8 @@ public function getFor($name, $path = null) $hash = $this->generateHash($name, $this->getFileRelativePath($path)); $file = $this->storage->getFileByHash($hash); - if (!($file instanceof FileInterface)) { - $file = $this->create($name, $path); - } + return $file instanceof FileInterface? $file : $this->create($name, $path); - return $file; } /** From aab658ff227b6b996da12c6df14bfe83d27052f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=81nis=20=C5=A0akars?= Date: Wed, 6 Sep 2017 18:00:21 +0300 Subject: [PATCH 09/28] Latvian translations (#244) --- .../LexikTranslationBundle.lv.yml | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Resources/translations/LexikTranslationBundle.lv.yml diff --git a/Resources/translations/LexikTranslationBundle.lv.yml b/Resources/translations/LexikTranslationBundle.lv.yml new file mode 100644 index 00000000..925c773f --- /dev/null +++ b/Resources/translations/LexikTranslationBundle.lv.yml @@ -0,0 +1,33 @@ +translations: + invalidate_cache: "Notīrīt kešatmiņu" + domain: "Domēns" + key: "Atslēga" + grid_caption: "Tulkojumu saraksts" + cache_removed: "Kešatmiņa notīrīta" + new_translation: "Jauns tulkojums" + add_translation: "Pievienot tulkojumu" + save: "Saglabāt" + save_add: "Saglabāt un pievienot vēl" + page_title: "Tulkojumi" + show_hide_columns: "Parādīt/Paslēpt kolonnas" + toggle_all_columns: "Parādīt/Paslēpt visas kolonnas" + save_row: "Saglabāt rindu" + successfully_updated: "Atslēgas #%id% tulkojumi veiksmīgi saglabāti." + successfully_added: "Tulkojumi tika veiksmīgi pievienoti." + successfully_deleted: "Tulkojumi tika veiksmīgi dzēsti." + update_failed: "Failed to update translations for key #%id%." + delete_failed: "Failed to delete translations for key #%id%." + back_to_list: "Atpakaļ" + all_translations: "Visi" + no_translations: "Tulkojumi netika atrasti" + profiler: "Profiler" + data_source: "Data source" + latest_profiles: "Latest profiles" + profile: "Profile" + +overview: + page_title: "Pārskats" + show_grid: "Tulkojumu saraksts" + msg_latest_translation: "Jaunākā tulkojuma datums: %date% UTC." + domain: "Domēns" + no_stats: "Nav datu." From b2a5bd8683ed06805ebbbd84fee1272de1824c25 Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 7 Sep 2017 09:53:20 +0200 Subject: [PATCH 10/28] Fix travis conf (#274) --- .travis.yml | 21 ++++++++------------- .travis/before_install.sh | 23 +++++++++++++++++++++++ .travis/install.sh | 6 ++++++ travis-php.ini | 2 -- 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100755 .travis/before_install.sh create mode 100755 .travis/install.sh delete mode 100644 travis-php.ini diff --git a/.travis.yml b/.travis.yml index 7f8987ce..d83b8d13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,22 @@ language: php + sudo: false php: - - 5.5 - 5.6 - 7.0 - - hhvm + - 7.1 matrix: fast_finish: true - allow_failures: - - php: hhvm services: - mongodb env: - SYMFONY_VERSION=2.8.* DB=pdo_mysql DB_USER=root DB_NAME=lexik_test + - SYMFONY_VERSION=3.0.* DB=pdo_mysql DB_USER=root DB_NAME=lexik_test + - SYMFONY_VERSION=3.1.* DB=pdo_mysql DB_USER=root DB_NAME=lexik_test - SYMFONY_VERSION=3.2.* DB=pdo_mysql DB_USER=root DB_NAME=lexik_test - SYMFONY_VERSION=3.3.* DB=pdo_mysql DB_USER=root DB_NAME=lexik_test @@ -25,14 +25,9 @@ cache: - $HOME/.composer/cache before_install: - - phpenv config-add travis-php.ini - - echo "memory_limit = 2G" > /home/travis/.phpenv/versions/$(phpenv version-name)/etc/conf.d/z.ini - - sh -c "if [ '$DB' = 'pdo_mysql' ]; then mysql -e 'create database IF NOT EXISTS $DB_NAME' -u$DB_USER; fi" - - composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update - - composer require symfony/validator:${SYMFONY_VERSION} --no-update - - composer require symfony/finder:${SYMFONY_VERSION} --no-update - - composer require symfony/doctrine-bridge:${SYMFONY_VERSION} --no-update - -install: composer install --prefer-dist --no-interaction + - if [ -x .travis/before_install.sh ]; then .travis/before_install.sh; fi; + +install: + - if [ -x .travis/install.sh ]; then .travis/install.sh; fi; script: phpunit diff --git a/.travis/before_install.sh b/.travis/before_install.sh new file mode 100755 index 00000000..afc744df --- /dev/null +++ b/.travis/before_install.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env sh +set -ev + +sh -c "if [ '$DB' = 'pdo_mysql' ]; then mysql -e 'create database IF NOT EXISTS $DB_NAME' -u$DB_USER; fi" + +phpenv config-rm xdebug.ini + +if [ "${TRAVIS_PHP_VERSION}" != "hhvm" ]; then + PHP_INI_DIR="$HOME/.phpenv/versions/$(phpenv version-name)/etc/conf.d/" + TRAVIS_INI_FILE="$PHP_INI_DIR/travis.ini" + echo "memory_limit=3072M" >> "$TRAVIS_INI_FILE" + + if [ "$TRAVIS_PHP_VERSION" '<' '7.0' ]; then + echo "extension=mongo.so" >> "$TRAVIS_INI_FILE" + else + echo "extension=mongodb.so" >> "$TRAVIS_INI_FILE" + + # Backwards compatibility with old mongo extension + composer require "alcaeus/mongo-php-adapter" --no-update + fi +fi + +composer require "symfony/symfony:${SYMFONY_VERSION}" --no-update diff --git a/.travis/install.sh b/.travis/install.sh new file mode 100755 index 00000000..41ac0ee5 --- /dev/null +++ b/.travis/install.sh @@ -0,0 +1,6 @@ +# To be removed when these issues are resolved: +# https://github.com/composer/composer/issues/5355 +# https://github.com/composer/composer/issues/5030 +composer update --prefer-dist --no-interaction --prefer-stable --quiet --ignore-platform-reqs + +composer update --prefer-dist --no-interaction --prefer-stable diff --git a/travis-php.ini b/travis-php.ini deleted file mode 100644 index 170783b1..00000000 --- a/travis-php.ini +++ /dev/null @@ -1,2 +0,0 @@ -extension = "mongo.so" -date.timezone = "Europe/Paris" From 0299217f40b3152159d146d4146fbd31a571b77b Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 7 Sep 2017 09:59:16 +0200 Subject: [PATCH 11/28] fix definition of storage service for sf 3.3 (#275) --- DependencyInjection/LexikTranslationExtension.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DependencyInjection/LexikTranslationExtension.php b/DependencyInjection/LexikTranslationExtension.php index f2e8c59b..73e9ab8a 100644 --- a/DependencyInjection/LexikTranslationExtension.php +++ b/DependencyInjection/LexikTranslationExtension.php @@ -171,7 +171,7 @@ protected function buildTranslationStorageDefinition(ContainerBuilder $container ); $storageDefinition = new Definition(); - $storageDefinition->setClass(new Parameter(sprintf('lexik_translation.%s.translation_storage.class', $storage))); + $storageDefinition->setClass($container->getParameter(sprintf('lexik_translation.%s.translation_storage.class', $storage))); $storageDefinition->setArguments($args); $container->setDefinition('lexik_translation.translation_storage', $storageDefinition); From 659896269c419c73365eaeff490e160ba6a52d59 Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 7 Sep 2017 14:16:50 +0200 Subject: [PATCH 12/28] fix tests (#276) --- .travis.yml | 5 +++-- Tests/Command/ImportTranslationsCommandTest.php | 2 +- .../Repository/Propel/TransUnitRepositoryTest.php | 2 ++ Tests/app/test/config.yml | 2 ++ composer.json | 15 ++++++++------- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index d83b8d13..82ffdaf3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ before_install: - if [ -x .travis/before_install.sh ]; then .travis/before_install.sh; fi; install: - - if [ -x .travis/install.sh ]; then .travis/install.sh; fi; + - if [ -x .travis/install.sh ]; then .travis/install.sh; fi; -script: phpunit +script: + - php vendor/bin/phpunit -v \ No newline at end of file diff --git a/Tests/Command/ImportTranslationsCommandTest.php b/Tests/Command/ImportTranslationsCommandTest.php index a708fa15..beb1e7db 100644 --- a/Tests/Command/ImportTranslationsCommandTest.php +++ b/Tests/Command/ImportTranslationsCommandTest.php @@ -98,7 +98,7 @@ public function testExecute() $resultLines = explode("\n", $commandTester->getDisplay()); $this->assertEquals('# LexikTranslationBundle:', $resultLines[0]); - $this->assertRegExp('/Using dir (.)+(lexik\/translation-bundle|lexik\/LexikTranslationBundle)\/Resources\/translations to lookup translation files/', $resultLines[1]); + $this->assertRegExp('/Using dir (.)+\/Resources\/translations to lookup translation files/', $resultLines[1]); $this->assertRegExp('/translations\/LexikTranslationBundle\.((fr)|(en))\.yml" \.\.\. 30 translations/', $resultLines[2]); $this->assertRegExp('/translations\/LexikTranslationBundle\.((fr)|(en))\.yml" \.\.\. 30 translations/', $resultLines[3]); $this->assertEquals('Removing translations cache files ...', $resultLines[4]); diff --git a/Tests/Unit/Repository/Propel/TransUnitRepositoryTest.php b/Tests/Unit/Repository/Propel/TransUnitRepositoryTest.php index f3689bd3..2ace4633 100644 --- a/Tests/Unit/Repository/Propel/TransUnitRepositoryTest.php +++ b/Tests/Unit/Repository/Propel/TransUnitRepositoryTest.php @@ -107,6 +107,8 @@ public function countProvider() */ public function testGetTransUnitList() { + $this->markTestIncomplete('Propel integration is currently not compatible with Symfony 3.3 / Propel 1.6'); + $con = $this->loadDatabase(); $repository = new TransUnitRepository($con); diff --git a/Tests/app/test/config.yml b/Tests/app/test/config.yml index c119ac9e..503d2db9 100644 --- a/Tests/app/test/config.yml +++ b/Tests/app/test/config.yml @@ -4,6 +4,8 @@ imports: framework: fragments: ~ secret: afasfsf + translator: + enabled: true lexik_translation: fallback_locale: en diff --git a/composer.json b/composer.json index 4868b4a3..075eab06 100644 --- a/composer.json +++ b/composer.json @@ -17,21 +17,22 @@ } ], "require": { - "php": ">=5.5.9", - "symfony/framework-bundle": "~2.8|~3.0" + "php": "^5.6 || ^7.0", + "symfony/framework-bundle": "~2.8|~3.0", + "symfony/symfony": "3.0.x" }, "require-dev": { - "doctrine/orm": "~2.4,<2.5", - "doctrine/doctrine-bundle": "~1.5", + "doctrine/orm": "^2.2.3", + "doctrine/doctrine-bundle": "~1.2", "doctrine/data-fixtures": "~1.1", "doctrine/mongodb-odm-bundle": "~3.0", - "propel/propel-bundle": "~1.2|3.0.0-alpha1", - "phpunit/phpunit": "~4.3" + "propel/propel-bundle": "~1.5|3.0.0-alpha1@dev", + "phpunit/phpunit": "^5.7" }, "suggest": { "doctrine/orm": ">=2.4", "doctrine/mongodb-odm-bundle": "~3.0", - "propel/propel-bundle": "~1.2" + "propel/propel-bundle": "~1.5" }, "autoload": { "psr-4": { "Lexik\\Bundle\\TranslationBundle\\": "" } From e6fca8b41e5b4f9173e7c9f9cbf04744e75303ee Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 7 Sep 2017 14:36:40 +0200 Subject: [PATCH 13/28] remove dependency symfony/symfony --- composer.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 075eab06..1d9d5a44 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ ], "require": { "php": "^5.6 || ^7.0", - "symfony/framework-bundle": "~2.8|~3.0", - "symfony/symfony": "3.0.x" + "symfony/framework-bundle": "~2.8|~3.0" }, "require-dev": { "doctrine/orm": "^2.2.3", From 5cfb433087f18d1a283a3773dbc64ce4ea319152 Mon Sep 17 00:00:00 2001 From: Seb Date: Thu, 7 Sep 2017 15:15:13 +0200 Subject: [PATCH 14/28] check if function apc_delete_file() exist before call it (#277) --- Translation/Translator.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Translation/Translator.php b/Translation/Translator.php index 70489143..49a3d5ee 100644 --- a/Translation/Translator.php +++ b/Translation/Translator.php @@ -108,7 +108,7 @@ public function removeLocalesCacheFiles(array $locales) */ protected function invalidateSystemCacheForFile($path) { - if (ini_get('apc.enabled')) { + if (ini_get('apc.enabled') && function_exists('apc_delete_file')) { if (apc_exists($path) && !apc_delete_file($path)) { throw new \RuntimeException(sprintf('Failed to clear APC Cache for file %s', $path)); } From ae35743192932ca05e596a2bcbf4864d80176db5 Mon Sep 17 00:00:00 2001 From: HellFiveDay Date: Thu, 7 Sep 2017 15:27:40 +0200 Subject: [PATCH 15/28] Replace save by saved glyphicon, looking less 'download' than 'confirm' action (#267) --- Resources/views/Translation/_ngGrid.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/views/Translation/_ngGrid.html.twig b/Resources/views/Translation/_ngGrid.html.twig index 38e86c6c..dc69a480 100644 --- a/Resources/views/Translation/_ngGrid.html.twig +++ b/Resources/views/Translation/_ngGrid.html.twig @@ -150,7 +150,7 @@