diff --git a/.travis.yml b/.travis.yml index c6c645e..300bced 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ php: - 5.5 - 5.6 - 7.0 + - 7.1 - hhvm env: @@ -32,8 +33,17 @@ matrix: env: SYMFONY_VERSION=2.3.* - php: 5.6 env: SYMFONY_VERSION=2.7.* + - php: 7.0 + env: SYMFONY_VERSION=2.7.* + - php: 7.1 + env: SYMFONY_VERSION=2.8.* - php: 5.6 - env: SYMFONY_VERSION=3.0.* + env: SYMFONY_VERSION=^3.0 + - php: 7.0 + env: SYMFONY_VERSION=^3.0 + - php: 7.1 + env: SYMFONY_VERSION=^3.0 + before_install: - travis_retry composer self-update diff --git a/Annotation/TransArrayKeys.php b/Annotation/TransArrayKeys.php new file mode 100644 index 0000000..a1da118 --- /dev/null +++ b/Annotation/TransArrayKeys.php @@ -0,0 +1,32 @@ + + * + * 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 + */ +final class TransArrayKeys +{ + /** + * @var string + */ + public $domain = 'messages'; +} diff --git a/Annotation/TransArrayValues.php b/Annotation/TransArrayValues.php new file mode 100644 index 0000000..7eae4fe --- /dev/null +++ b/Annotation/TransArrayValues.php @@ -0,0 +1,32 @@ + + * + * 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 + */ +final class TransArrayValues +{ + /** + * @var string + */ + public $domain = 'messages'; +} diff --git a/Annotation/TransString.php b/Annotation/TransString.php new file mode 100644 index 0000000..f9cee13 --- /dev/null +++ b/Annotation/TransString.php @@ -0,0 +1,32 @@ + + * + * 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 + */ +final class TransString +{ + /** + * @var string + */ + public $domain = 'messages'; +} diff --git a/Changelog.md b/Changelog.md index 05367eb..164573a 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,12 @@ # Changelog -### 1.3.1 to UNRELEASED +### 1.3.2 to UNRELEASED + +### 1.3.1 to 1.3.2 +* Added configuration options to disable date/sources in xliff dump +* Fixed trim bug with @XBundle notation +* Added support for php 7.1 +* Added Twig 2 support ### 1.3.0 to 1.3.1 diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index c79e908..7852ced 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -43,6 +43,13 @@ public function getConfigTreeBuilder() ->arrayNode('locales') ->prototype('scalar')->end() ->end() + ->arrayNode('dumper') + ->addDefaultsIfNotSet() + ->children() + ->booleanNode('add_date')->defaultTrue()->end() + ->booleanNode('add_references')->defaultTrue()->end() + ->end() + ->end() ->scalarNode('source_language')->defaultValue('en')->end() ->arrayNode('custom_form_config_names') ->prototype('scalar')->end() @@ -72,7 +79,7 @@ public function getConfigTreeBuilder() if (false === $pos = strpos($v, '/')) { $bundleName = substr($v, 1); } else { - $bundleName = substr($v, 1, $pos - 2); + $bundleName = substr($v, 1, $pos - 1); } $bundles = $c->getParameter('kernel.bundles'); diff --git a/DependencyInjection/JMSTranslationExtension.php b/DependencyInjection/JMSTranslationExtension.php index aed6bfd..e21d728 100644 --- a/DependencyInjection/JMSTranslationExtension.php +++ b/DependencyInjection/JMSTranslationExtension.php @@ -36,10 +36,15 @@ public function load(array $configs, ContainerBuilder $container) $container->setParameter('jms_translation.source_language', $config['source_language']); $container->setParameter('jms_translation.locales', $config['locales']); + // Extend form extractor $def = $container->getDefinition('jms_translation.extractor.file.form_extractor'); $def->addMethodCall('addCustomTranslationFields', [$config['custom_form_config_names']]); + foreach ($config['dumper'] as $option => $value) { + $container->setParameter("jms_translation.dumper.{$option}", $value); + } + $requests = array(); foreach ($config['configs'] as $name => $extractConfig) { $def = new Definition('JMS\TranslationBundle\Translation\ConfigBuilder'); diff --git a/README.md b/README.md index d0e7fb9..521c2da 100644 --- a/README.md +++ b/README.md @@ -21,6 +21,24 @@ $this->trans('user.create.success.%email%', ['%email%' => $user->getEmail()]); > The double `""` sign is the escaped `"` in the `AltTrans` annotation value. +- Add new Trans* Annotations: `TransArrayKeys`, `TransArrayValues`, `TransString` . You can handle the strings in var: + +```php +trans($msgs[$errorId], [], "error"); +``` + JMSTranslationBundle [![Build Status](https://secure.travis-ci.org/schmittjoh/JMSTranslationBundle.png?branch=master)](http://travis-ci.org/schmittjoh/JMSTranslationBundle) [![Join the chat at https://gitter.im/schmittjoh/JMSTranslationBundle](https://badges.gitter.im/schmittjoh/JMSTranslationBundle.svg)](https://gitter.im/schmittjoh/JMSTranslationBundle?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ==================== diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 784c5a9..07ff417 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -9,6 +9,7 @@ JMS\TranslationBundle\Translation\ExtractorManager JMS\TranslationBundle\Translation\Extractor\FileExtractor + JMS\TranslationBundle\Translation\Extractor\File\AnnotationExtractor JMS\TranslationBundle\Translation\Extractor\File\DefaultPhpFileExtractor JMS\TranslationBundle\Translation\Extractor\File\TranslationContainerExtractor JMS\TranslationBundle\Translation\Extractor\File\TwigFileExtractor @@ -64,12 +65,24 @@ %jms_translation.source_language% + + %jms_translation.dumper.add_date% + + + %jms_translation.dumper.add_references% + %jms_translation.source_language% + + %jms_translation.dumper.add_date% + + + %jms_translation.dumper.add_references% + @@ -88,6 +101,11 @@ + + + + + @@ -120,10 +138,13 @@ + JMS\TranslationBundle\Annotation\AltTrans JMS\TranslationBundle\Annotation\Desc - JMS\TranslationBundle\Annotation\Meaning JMS\TranslationBundle\Annotation\Ignore - JMS\TranslationBundle\Annotation\AltTrans + JMS\TranslationBundle\Annotation\Meaning + JMS\TranslationBundle\Annotation\TransArrayKeys + JMS\TranslationBundle\Annotation\TransArrayValues + JMS\TranslationBundle\Annotation\TransString diff --git a/Resources/views/Translate/index.html.twig b/Resources/views/Translate/index.html.twig index 4f53d1d..ed6ce54 100644 --- a/Resources/views/Translate/index.html.twig +++ b/Resources/views/Translate/index.html.twig @@ -4,7 +4,7 @@ {{ parent() }}