### Install JMSTranslationBundle with Composer Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/installation Run this command to install JMSTranslationBundle version ^1.3 via Composer. Composer will automatically download and install all required files. ```bash $ composer require jms/translation-bundle "^1.3" ``` -------------------------------- ### Access URL for translation web UI Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/webinterface After following the installation instructions, access the translation interface at this URL. ```text http://your-host/app_dev.php/_trans/ ``` -------------------------------- ### Register JMSTranslationBundle in AppKernel.php Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/installation Add the bundle to the registerBundles() method in AppKernel.php. This is required after installation to enable the bundle. ```php translator->transChoice('text_apples_remaining', $count) ``` -------------------------------- ### Twig transchoice with desc filter Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/usage Example of using the desc filter to provide context to translators in a Twig template. The desc filter is removed when the template is compiled and does not affect runtime performance. ```twig {# index.html.twig #} {{ "text.apples_remaining"|transchoice(count) |desc("{0} There is no apples|{1} There is one apple|]1,Inf] There are %count% apples") }} ``` -------------------------------- ### Show translation:extract command help Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/usage Run this command to display all available command line options for the translation:extract command, which can be used to adapt the extraction process to specific needs. ```bash php app/console translation:extract --help ``` -------------------------------- ### Configure and run translation:extract with --config Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/cookbook/extraction_configs Defines a reusable extraction configuration in config.yml and then runs the extraction command with it. The first command uses the saved settings; the second overrides only the output format to xliff while keeping the rest. Note that since Symfony 2.5.4, quotes around *TestCase.php and *Test.php are necessary for valid YAML. ```yaml # config.yml jms_translation: configs: app: dirs: ["%kernel.project_dir%/templates", "%kernel.project_dir%/src"] output_dir: "%kernel.project_dir%/translations" ignored_domains: [routes] excluded_names: ["*TestCase.php", "*Test.php"] excluded_dirs: [cache, data, logs] extractors: [alias_of_the_extractor] ``` ```bash php app/console translation:extract de --config=app ``` ```bash php app/console translation:extract de --config=app --output-format=xliff ``` -------------------------------- ### Dump translation files for a specific bundle Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/usage Use the --bundle option to extract and dump translation files for a single bundle, here MyFooBundle, for the given locale. ```bash php app/console translation:extract de --bundle=MyFooBundle ``` -------------------------------- ### Update translation files with translation:extract command Source: https://jmsyst.com/bundles/JMSTranslationBundle/1.0/usage Run this command to extract translation messages from the source directory and update the translation files in the output directory for the specified locale. Use the --dry-run option to preview changes without writing. ```bash php app/console translation:extract de --dir=./src/ --output-dir=./app/Resources/translations ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.