2017 © Pedro Peláez
 

symfony-bundle translation-checker-bundle

CLI tools to check translations in a Symfony project

image

incenteev/translation-checker-bundle

CLI tools to check translations in a Symfony project

  • Tuesday, February 20, 2018
  • by Stof
  • Repository
  • 4 Watchers
  • 27 Stars
  • 24,575 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 7 Versions
  • 16 % Grown

The README.md

Translation Checker Bundle

This bundle provides you a few CLI commands to check your translations. These commands are designed to be usable easily in CI jobs, (*1)

CI Latest Stable Version Latest Unstable Version Scrutinizer Code Quality, (*2)

Installation

Installation is a quick (I promise!) 2 step process:, (*3)

  1. Download IncenteevTranslationCheckerBundle
  2. Enable the Bundle

Step 1: Install IncenteevTranslationCheckerBundle with composer

Run the following composer require command:, (*4)

composer require incenteev/translation-checker-bundle

Step 2: Enable the bundle

Note: If you use Flex, you have nothing to do at this step, as Flex does it for you., (*5)

Finally, enable the bundle in the kernel:, (*6)

// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Incenteev\TranslationCheckerBundle\IncenteevTranslationCheckerBundle(),
    );
}

Warning: This bundle requires that the translator is enabled in FrameworkBundle., (*7)

Usage

The bundle provides a few CLI commands. To list them all, run:, (*8)

bin/console list incenteev:translation

All commands display a summary only by default. Run then in verbose mode to get a detailed report., (*9)

Finding missing translations

The incenteev:translation:find-missing command extracts necessary translations from our app source code, and then compare this list to the translation available for the tested locale. It will exit with a failure exit code if any missing translation is detected., (*10)

Warning: Translation extraction will not find all translations used by our app. So while a failure exit code means there is an issue, a success exit code does not guarantee that all translations are available. The recommended usage is to use this command for your reference locale only, and then test other locales by comparing them against the reference instead., (*11)

Comparing translations to a reference locale

The incenteev:translation:compare command compares available translations from 2 different locales and will exit with a failure exit code if catalogues are not in sync., (*12)

Note: this command may not work well for country variants of a locale (fr_FR). Use it for main locales., (*13)

Configuration

To use the commands comparing the catalogue to the extracted translations, you need to configure the bundles in which the templates should be parsed for translations. By default, only templates in templates (and app/Resources/views on Symfony 4 and older) are registered in the extractor. You can register bundles that will be processed too., (*14)

# app/config/config.yml
incenteev_translation_checker:
    extraction:
        bundles:
            - TwigBundle
            - AcmeDemoBundle

The bundle also supports extracting translations from JS files, for projects using willdurand/js-translation-bundle:, (*15)

# app/config/config.yml
incenteev_translation_checker:
    extraction:
        js:
            # Paths in which JS files should be checked for translations.
            # Path could be either for files, or for directories in which JS files should be looked for.
            # This configuration is required to enable this feature.
            paths:
                - '%kernel.project_dir%/web/js'
                - '%kernel.project_dir%/web/other.js'
            # The default domain used in your JS translations. Should match the js-translation-bundle configuration
            # Defaults to 'messages'
            default_domain: js

The Versions

29/09 2015

v1.1.0

1.1.0.0 https://github.com/Incenteev/IncenteevTranslationCheckerBundle

CLI tools to check translations in a Symfony2 project

  Sources   Download

MIT

The Requires

 

The Development Requires

translation translation check

08/06 2015

v1.0.0

1.0.0.0 https://github.com/Incenteev/IncenteevTranslationCheckerBundle

CLI tools to check translations in a Symfony2 project

  Sources   Download

MIT

The Requires

 

The Development Requires

translation translation check