Passed
Branch master (834d7a)
by Jonathan
04:40
created
resources/lang/fr/messages.php 2 patches
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -12,18 +12,18 @@
 block discarded – undo
12 12
 
13 13
 return array (
14 14
 
15
-    'Translation Tool'              =>  'Outil de traduction',
16
-    'Manage webtrees translation.'  =>  'Gère les traductions de webtrees',
17
-    'Translations status'           =>  'Statut des traductions',
18
-    'Missing translations (%s)'     =>  'Traductions manquantes (%s)',
19
-    'Non used MyArtJaub translations (%s)'
20
-                                    =>  'Traductions MyArtJaub non utilisés (%s)',
21
-    'Number of translations'        =>  'Nombre de traductions',
22
-    'Number of translations found in code'
23
-                                    =>  'Nombre de traductions trouvées dans le code',
24
-    'Number of translations in MyArtJaub modules'
25
-                                    =>  'Nombre de traductions dans les modules MyArtJaub',
26
-    'Paths for source code'         =>  'Chemins du code source',
27
-    'References'                    =>  'Références',
15
+                                'Translation Tool'              =>  'Outil de traduction',
16
+                                'Manage webtrees translation.'  =>  'Gère les traductions de webtrees',
17
+                                'Translations status'           =>  'Statut des traductions',
18
+                                'Missing translations (%s)'     =>  'Traductions manquantes (%s)',
19
+                                'Non used MyArtJaub translations (%s)'
20
+                                                                =>  'Traductions MyArtJaub non utilisés (%s)',
21
+                                'Number of translations'        =>  'Nombre de traductions',
22
+                                'Number of translations found in code'
23
+                                                                =>  'Nombre de traductions trouvées dans le code',
24
+                                'Number of translations in MyArtJaub modules'
25
+                                                                =>  'Nombre de traductions dans les modules MyArtJaub',
26
+                                'Paths for source code'         =>  'Chemins du code source',
27
+                                'References'                    =>  'Références',
28 28
     
29 29
 );
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3
11 11
  */
12 12
 
13
-return array (
13
+return array(
14 14
 
15 15
     'Translation Tool'              =>  'Outil de traduction',
16 16
     'Manage webtrees translation.'  =>  'Gère les traductions de webtrees',
Please login to merge, or discard this patch.
app/Services/ComposerService.php 2 patches
Indentation   +71 added lines, -71 removed lines patch added patch discarded remove patch
@@ -27,82 +27,82 @@
 block discarded – undo
27 27
 class ComposerService
28 28
 {
29 29
     
30
-    /**
31
-     * Checks whether a Composer package is a MyArtJaub one.
32
-     *
33
-     * @param PackageInterface $package
34
-     * @return bool
35
-     */
36
-    public function isMyArtJaubPackage(PackageInterface $package): bool
37
-    {
38
-        list($vendor) = explode('/', $package->getName(), 2);
39
-        return $vendor == self::MYARTJAUB_VENDOR;
40
-    }
30
+                                /**
31
+                                 * Checks whether a Composer package is a MyArtJaub one.
32
+                                 *
33
+                                 * @param PackageInterface $package
34
+                                 * @return bool
35
+                                 */
36
+                                public function isMyArtJaubPackage(PackageInterface $package): bool
37
+                                {
38
+                                list($vendor) = explode('/', $package->getName(), 2);
39
+                                return $vendor == self::MYARTJAUB_VENDOR;
40
+                                }
41 41
     
42
-    /**
43
-     * Name of the MyArtJaub modules' vendor
44
-     * @var string MYARTJAUB_VENDOR
45
-     * */
46
-    private const MYARTJAUB_VENDOR = 'jon48';
42
+                                /**
43
+                                 * Name of the MyArtJaub modules' vendor
44
+                                 * @var string MYARTJAUB_VENDOR
45
+                                 * */
46
+                                private const MYARTJAUB_VENDOR = 'jon48';
47 47
     
48
-    /**
49
-     * List all the PSR-4 paths used in MyArtJaub packages autoloading.
50
-     * The returned array is composed of items with the structure:
51
-     *      - array [
52
-     *              0 => Package Name
53
-     *              1 => Array of normalised paths
54
-     *          ]
55
-     *
56
-     * @return array
57
-     */
58
-    public function listMyArtJaubPackagesPaths(): array
59
-    {
60
-        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
48
+                                /**
49
+                                 * List all the PSR-4 paths used in MyArtJaub packages autoloading.
50
+                                 * The returned array is composed of items with the structure:
51
+                                 *      - array [
52
+                                 *              0 => Package Name
53
+                                 *              1 => Array of normalised paths
54
+                                 *          ]
55
+                                 *
56
+                                 * @return array
57
+                                 */
58
+                                public function listMyArtJaubPackagesPaths(): array
59
+                                {
60
+                                $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
61 61
         
62
-        $packages = $composer->getRepositoryManager()
63
-            ->getLocalRepository()
64
-            ->getPackages();
62
+                                $packages = $composer->getRepositoryManager()
63
+                                ->getLocalRepository()
64
+                                ->getPackages();
65 65
             
66
-        /** @var array<PackageInterface> $maj_packages */
67
-        $maj_packages = array();
68
-        foreach ($packages as $package) {
69
-            if ($this->isMyArtJaubPackage($package)) {
70
-                $maj_packages[] = $this->extractPsr4Paths($composer, $package);
71
-            }
72
-        }
66
+                                /** @var array<PackageInterface> $maj_packages */
67
+                                $maj_packages = array();
68
+                                foreach ($packages as $package) {
69
+                                if ($this->isMyArtJaubPackage($package)) {
70
+                                $maj_packages[] = $this->extractPsr4Paths($composer, $package);
71
+                                }
72
+                                }
73 73
         
74
-        return $maj_packages;
75
-    }
74
+                                return $maj_packages;
75
+                                }
76 76
     
77
-    /**
78
-     * Extract and normalise the PSR-4 paths used in a package autoloading.
79
-     * The returned array is a 2-tuple with the structure:
80
-     *      - array [
81
-     *              0 => Package Name
82
-     *              1 => Array of normalised paths
83
-     *          ]
84
-     *
85
-     * @param Composer $composer
86
-     * @param PackageInterface $package
87
-     * @return array
88
-     */
89
-    private function extractPsr4Paths(Composer $composer, PackageInterface $package): array
90
-    {
91
-        $autoload_generator = $composer->getAutoloadGenerator();
77
+                                /**
78
+                                 * Extract and normalise the PSR-4 paths used in a package autoloading.
79
+                                 * The returned array is a 2-tuple with the structure:
80
+                                 *      - array [
81
+                                 *              0 => Package Name
82
+                                 *              1 => Array of normalised paths
83
+                                 *          ]
84
+                                 *
85
+                                 * @param Composer $composer
86
+                                 * @param PackageInterface $package
87
+                                 * @return array
88
+                                 */
89
+                                private function extractPsr4Paths(Composer $composer, PackageInterface $package): array
90
+                                {
91
+                                $autoload_generator = $composer->getAutoloadGenerator();
92 92
         
93
-        $package_map = $autoload_generator->buildPackageMap(
94
-            $composer->getInstallationManager(),
95
-            $composer->getPackage(),
96
-            [$package]
97
-        );
98
-        array_shift($package_map);
99
-        $autoloads = $autoload_generator->parseAutoloads($package_map, $composer->getPackage());
100
-        $psr4_paths = [];
101
-        foreach ($autoloads['psr-4'] as $psr4_ns_paths) {
102
-            foreach ($psr4_ns_paths as $psr4_ns_path) {
103
-                $psr4_paths[] = realpath($psr4_ns_path);
104
-            }
105
-        }
106
-        return [$package, $psr4_paths];
107
-    }
93
+                                $package_map = $autoload_generator->buildPackageMap(
94
+                                $composer->getInstallationManager(),
95
+                                $composer->getPackage(),
96
+                                [$package]
97
+                                );
98
+                                array_shift($package_map);
99
+                                $autoloads = $autoload_generator->parseAutoloads($package_map, $composer->getPackage());
100
+                                $psr4_paths = [];
101
+                                foreach ($autoloads['psr-4'] as $psr4_ns_paths) {
102
+                                foreach ($psr4_ns_paths as $psr4_ns_path) {
103
+                                $psr4_paths[] = realpath($psr4_ns_path);
104
+                                }
105
+                                }
106
+                                return [$package, $psr4_paths];
107
+                                }
108 108
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -57,7 +57,7 @@
 block discarded – undo
57 57
      */
58 58
     public function listMyArtJaubPackagesPaths(): array
59 59
     {
60
-        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR . 'composer.json');
60
+        $composer = Factory::create(new NullIO(), Webtrees::ROOT_DIR.'composer.json');
61 61
         
62 62
         $packages = $composer->getRepositoryManager()
63 63
             ->getLocalRepository()
Please login to merge, or discard this patch.
app/Http/RequestHandlers/TranslationStatus.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@
 block discarded – undo
70 70
             $locale->languageTag()
71 71
         );
72 72
         
73
-        return $this->viewResponse($this->module->name() . '::status', [
73
+        return $this->viewResponse($this->module->name().'::status', [
74 74
             'title'                 =>  $this->module->title(),
75 75
             'language'              =>  $locale->endonym(),
76 76
             'source_code_paths'     =>  $sourceCodePaths->flatten()->sort(),
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -30,53 +30,53 @@
 block discarded – undo
30 30
  */
31 31
 class TranslationStatus implements RequestHandlerInterface
32 32
 {
33
-    use ViewResponseTrait;
33
+                                use ViewResponseTrait;
34 34
 
35
-    /** @var ?TranslationToolModule $module */
36
-    private $module;
35
+                                /** @var ?TranslationToolModule $module */
36
+                                private $module;
37 37
 
38
-    /** @var SourceCodeService $sourcecode_service */
39
-    private $sourcecode_service;
38
+                                /** @var SourceCodeService $sourcecode_service */
39
+                                private $sourcecode_service;
40 40
 
41
-    /**
42
-     * Constructor for TranslationStatus request handler
43
-     *
44
-     * @param ModuleService $module_service
45
-     * @param SourceCodeService $sourcecode_service
46
-     */
47
-    public function __construct(ModuleService $module_service, SourceCodeService $sourcecode_service)
48
-    {
49
-        $this->module = $module_service->findByInterface(TranslationToolModule::class)->first();
50
-        $this->sourcecode_service = $sourcecode_service;
51
-    }
41
+                                /**
42
+                                 * Constructor for TranslationStatus request handler
43
+                                 *
44
+                                 * @param ModuleService $module_service
45
+                                 * @param SourceCodeService $sourcecode_service
46
+                                 */
47
+                                public function __construct(ModuleService $module_service, SourceCodeService $sourcecode_service)
48
+                                {
49
+                                $this->module = $module_service->findByInterface(TranslationToolModule::class)->first();
50
+                                $this->sourcecode_service = $sourcecode_service;
51
+                                }
52 52
 
53
-    /**
54
-     * {@inheritDoc}
55
-     * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
-     */
57
-    public function handle(ServerRequestInterface $request): ResponseInterface
58
-    {
59
-        $this->layout = 'layouts/administration';
53
+                                /**
54
+                                 * {@inheritDoc}
55
+                                 * @see \Psr\Http\Server\RequestHandlerInterface::handle()
56
+                                 */
57
+                                public function handle(ServerRequestInterface $request): ResponseInterface
58
+                                {
59
+                                $this->layout = 'layouts/administration';
60 60
 
61
-        if ($this->module === null) {
62
-            throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
63
-        }
61
+                                if ($this->module === null) {
62
+                                throw new HttpNotFoundException(I18N::translate('The attached module could not be found.'));
63
+                                }
64 64
 
65
-        $locale = I18N::locale();
66
-        $sourceCodePaths = $this->sourcecode_service->sourceCodePaths();
67
-        $translation_analyser = new TranslationsAnalyzer(
68
-            $this->sourcecode_service,
69
-            $sourceCodePaths,
70
-            $locale->languageTag()
71
-        );
65
+                                $locale = I18N::locale();
66
+                                $sourceCodePaths = $this->sourcecode_service->sourceCodePaths();
67
+                                $translation_analyser = new TranslationsAnalyzer(
68
+                                $this->sourcecode_service,
69
+                                $sourceCodePaths,
70
+                                $locale->languageTag()
71
+                                );
72 72
 
73
-        return $this->viewResponse($this->module->name() . '::status', [
74
-            'title'                 =>  $this->module->title(),
75
-            'language'              =>  $locale->endonym(),
76
-            'source_code_paths'     =>  $sourceCodePaths->flatten()->sort(),
77
-            'translations_stats'    =>  $translation_analyser->translationsStatictics(),
78
-            'missing_translations'  =>  $translation_analyser->missingTranslations(),
79
-            'non_used_translations' =>  $translation_analyser->nonUsedMajTranslations()
80
-        ]);
81
-    }
73
+                                return $this->viewResponse($this->module->name() . '::status', [
74
+                                'title'                 =>  $this->module->title(),
75
+                                'language'              =>  $locale->endonym(),
76
+                                'source_code_paths'     =>  $sourceCodePaths->flatten()->sort(),
77
+                                'translations_stats'    =>  $translation_analyser->translationsStatictics(),
78
+                                'missing_translations'  =>  $translation_analyser->missingTranslations(),
79
+                                'non_used_translations' =>  $translation_analyser->nonUsedMajTranslations()
80
+                                ]);
81
+                                }
82 82
 }
Please login to merge, or discard this patch.
app/TranslationToolModule.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -30,68 +30,68 @@
 block discarded – undo
30 30
  */
31 31
 class TranslationToolModule extends AbstractModule implements ModuleMyArtJaubInterface, ModuleConfigInterface
32 32
 {
33
-    use ModuleMyArtJaubTrait;
34
-    use ModuleConfigTrait;
33
+                                use ModuleMyArtJaubTrait;
34
+                                use ModuleConfigTrait;
35 35
 
36
-    /**
37
-     * {@inheritDoc}
38
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
39
-     */
40
-    public function title(): string
41
-    {
42
-        return I18N::translate('Translation Tool');
43
-    }
36
+                                /**
37
+                                 * {@inheritDoc}
38
+                                 * @see \Fisharebest\Webtrees\Module\AbstractModule::title()
39
+                                 */
40
+                                public function title(): string
41
+                                {
42
+                                return I18N::translate('Translation Tool');
43
+                                }
44 44
 
45
-    /**
46
-     * {@inheritDoc}
47
-     * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
48
-     */
49
-    public function description(): string
50
-    {
51
-        return I18N::translate('Manage webtrees translation.');
52
-    }
45
+                                /**
46
+                                 * {@inheritDoc}
47
+                                 * @see \Fisharebest\Webtrees\Module\AbstractModule::description()
48
+                                 */
49
+                                public function description(): string
50
+                                {
51
+                                return I18N::translate('Manage webtrees translation.');
52
+                                }
53 53
 
54
-    public function customModuleVersion(): string
55
-    {
56
-        return '2.0.11-v.1';
57
-    }
54
+                                public function customModuleVersion(): string
55
+                                {
56
+                                return '2.0.11-v.1';
57
+                                }
58 58
 
59
-    /**
60
-     * {@inheritDoc}
61
-     * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl()
62
-     */
63
-    public function customModuleSupportUrl(): string
64
-    {
65
-        return 'https://github.com/jon48/webtrees-mod-translationtool';
66
-    }
59
+                                /**
60
+                                 * {@inheritDoc}
61
+                                 * @see \Fisharebest\Webtrees\Module\ModuleCustomInterface::customModuleSupportUrl()
62
+                                 */
63
+                                public function customModuleSupportUrl(): string
64
+                                {
65
+                                return 'https://github.com/jon48/webtrees-mod-translationtool';
66
+                                }
67 67
 
68
-    /**
69
-     * {@inheritDoc}
70
-     * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
71
-     */
72
-    public function loadRoutes(Map $router): void
73
-    {
74
-        $router->attach('', '', static function (Map $router): void {
68
+                                /**
69
+                                 * {@inheritDoc}
70
+                                 * @see \MyArtJaub\Webtrees\Module\ModuleMyArtJaubInterface::loadRoutes()
71
+                                 */
72
+                                public function loadRoutes(Map $router): void
73
+                                {
74
+                                $router->attach('', '', static function (Map $router): void {
75 75
 
76 76
 
77
-            $router->attach('', '/module-maj/translationtool', static function (Map $router): void {
77
+                                $router->attach('', '/module-maj/translationtool', static function (Map $router): void {
78 78
 
79
-                $router->extras([
80
-                    'middleware' => [
81
-                        AuthAdministrator::class,
82
-                    ],
83
-                ]);
84
-                $router->get(TranslationStatus::class, '/status', TranslationStatus::class);
85
-            });
86
-        });
87
-    }
79
+                                $router->extras([
80
+                                'middleware' => [
81
+                                AuthAdministrator::class,
82
+                                ],
83
+                                ]);
84
+                                $router->get(TranslationStatus::class, '/status', TranslationStatus::class);
85
+                                });
86
+                                });
87
+                                }
88 88
 
89
-    /**
90
-     * {@inheritDoc}
91
-     * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
92
-     */
93
-    public function getConfigLink(): string
94
-    {
95
-        return route(TranslationStatus::class);
96
-    }
89
+                                /**
90
+                                 * {@inheritDoc}
91
+                                 * @see \Fisharebest\Webtrees\Module\ModuleConfigInterface::getConfigLink()
92
+                                 */
93
+                                public function getConfigLink(): string
94
+                                {
95
+                                return route(TranslationStatus::class);
96
+                                }
97 97
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@
 block discarded – undo
71 71
      */
72 72
     public function loadRoutes(Map $router): void
73 73
     {
74
-        $router->attach('', '', static function (Map $router): void {
74
+        $router->attach('', '', static function(Map $router): void {
75 75
 
76 76
 
77
-            $router->attach('', '/module-maj/translationtool', static function (Map $router): void {
77
+            $router->attach('', '/module-maj/translationtool', static function(Map $router): void {
78 78
 
79 79
                 $router->extras([
80 80
                     'middleware' => [
Please login to merge, or discard this patch.
app/Services/SourceCodeService.php 2 patches
Indentation   +125 added lines, -125 removed lines patch added patch discarded remove patch
@@ -28,129 +28,129 @@
 block discarded – undo
28 28
 class SourceCodeService
29 29
 {
30 30
 
31
-    /**
32
-     * Gettext Translations merge strategy to be used - Use Theirs data
33
-     * @var int MERGE_STRATEGY_THEIRS
34
-     */
35
-    private const MERGE_STRATEGY_THEIRS = Merge::HEADERS_OVERRIDE
36
-        | Merge::TRANSLATIONS_THEIRS
37
-        | Merge::TRANSLATIONS_OVERRIDE
38
-        | Merge::EXTRACTED_COMMENTS_THEIRS
39
-        | Merge::REFERENCES_THEIRS
40
-        | Merge::FLAGS_THEIRS
41
-        | Merge::COMMENTS_THEIRS;
42
-
43
-    /**
44
-     * I18N functions to be looked for in the code
45
-     * @var array
46
-     */
47
-    private const I18N_FUNCTIONS = [
48
-        'translate' => 'gettext',
49
-        'plural' => 'ngettext',
50
-        'translateContext' => 'pgettext'
51
-    ];
52
-
53
-    /**
54
-     * Lists all paths containing source code to be scanned for translations.
55
-     * This contains the MyArtJaub modules's resources folder,
56
-     * as well as MyArtJaub modules PSR-4 autoloading paths loaded through Composer
57
-     *
58
-     * @return Collection
59
-     */
60
-    public function sourceCodePaths(): Collection
61
-    {
62
-        $paths = app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
63
-            ->mapWithKeys(function (ModuleMyArtJaubInterface $module): array {
64
-                return [$module->name() => [realpath($module->resourcesFolder())]];
65
-            });
66
-
67
-        $maj_packages = app(ComposerService::class)->listMyArtJaubPackagesPaths();
68
-
69
-        foreach ($maj_packages as list($maj_package, $psr4_paths)) {
70
-            /** @var PackageInterface $maj_package */
71
-            $installer_name = $maj_package->getExtra()['installer-name'] ?? '';
72
-            $key = $installer_name === '' ? $maj_package->getName() : '_' . $installer_name . '_';
73
-            if (count($psr4_paths) > 0) {
74
-                $paths->put($key, array_merge($paths->get($key, []), $psr4_paths));
75
-            }
76
-        }
77
-
78
-        return $paths;
79
-    }
80
-
81
-    /**
82
-     * Find all strings to be translated in PHP or PHTML files for a set of source code paths
83
-     * The returned structure is a associated Collection with:
84
-     *      - key: package/domain
85
-     *      - value: Gettext Translations object for that domain
86
-     *
87
-     * @param Collection $source_code_paths
88
-     * @return Collection
89
-     */
90
-    public function findStringsToTranslate(Collection $source_code_paths): Collection
91
-    {
92
-        $strings_to_translate = new Collection();
93
-        foreach ($source_code_paths as $package => $paths) {
94
-            $php_files = array();
95
-            foreach ($paths as $path) {
96
-                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.php') ?: array());
97
-                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.phtml') ?: array());
98
-            }
99
-
100
-            $php_scanner = new PhpScanner(Translations::create($package));
101
-            $php_scanner
102
-                ->setFunctions(self::I18N_FUNCTIONS)
103
-                ->ignoreInvalidFunctions(true);
104
-            $php_scanner->setDefaultDomain($package);
105
-            foreach ($php_files as $php_file) {
106
-                $php_scanner->scanFile($php_file);
107
-            }
108
-
109
-            $strings_to_translate->put(
110
-                $package,
111
-                $strings_to_translate
112
-                    ->get($package, Translations::create())
113
-                    ->mergeWith($php_scanner->getTranslations()[$package], self::MERGE_STRATEGY_THEIRS)
114
-            );
115
-        }
116
-        return $strings_to_translate;
117
-    }
118
-
119
-    /**
120
-     * List all translations defined in MyArtJaub modules
121
-     * The returned structure is a associated Collection with:
122
-     *      - key: module name
123
-     *      - value: array of translations for the module
124
-     *
125
-     * @param string $language
126
-     * @return Collection
127
-     */
128
-    public function listMyArtJaubTranslations(string $language): Collection
129
-    {
130
-        return app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
131
-            ->mapWithKeys(function (ModuleMyArtJaubInterface $module) use ($language): array {
132
-                return [$module->name() => $module->customTranslations($language)];
133
-            });
134
-    }
135
-
136
-    /**
137
-     * Extension of the standard PHP glob function to apply it recursively.
138
-     *
139
-     * @param string $pattern
140
-     * @param int $flags
141
-     * @return string[]
142
-     * @see glob()
143
-     * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
144
-     */
145
-    protected function glob_recursive(string $pattern, int $flags = 0): array
146
-    {
147
-        $files = glob($pattern, $flags) ?: [];
148
-        $dirs = glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) ?: [];
149
-
150
-        foreach ($dirs as $dir) {
151
-            $files = array_merge($files, $this->glob_recursive($dir . '/' . basename($pattern), $flags));
152
-        }
153
-
154
-        return $files;
155
-    }
31
+                                /**
32
+                                 * Gettext Translations merge strategy to be used - Use Theirs data
33
+                                 * @var int MERGE_STRATEGY_THEIRS
34
+                                 */
35
+                                private const MERGE_STRATEGY_THEIRS = Merge::HEADERS_OVERRIDE
36
+                                | Merge::TRANSLATIONS_THEIRS
37
+                                | Merge::TRANSLATIONS_OVERRIDE
38
+                                | Merge::EXTRACTED_COMMENTS_THEIRS
39
+                                | Merge::REFERENCES_THEIRS
40
+                                | Merge::FLAGS_THEIRS
41
+                                | Merge::COMMENTS_THEIRS;
42
+
43
+                                /**
44
+                                 * I18N functions to be looked for in the code
45
+                                 * @var array
46
+                                 */
47
+                                private const I18N_FUNCTIONS = [
48
+                                'translate' => 'gettext',
49
+                                'plural' => 'ngettext',
50
+                                'translateContext' => 'pgettext'
51
+                                ];
52
+
53
+                                /**
54
+                                 * Lists all paths containing source code to be scanned for translations.
55
+                                 * This contains the MyArtJaub modules's resources folder,
56
+                                 * as well as MyArtJaub modules PSR-4 autoloading paths loaded through Composer
57
+                                 *
58
+                                 * @return Collection
59
+                                 */
60
+                                public function sourceCodePaths(): Collection
61
+                                {
62
+                                $paths = app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
63
+                                ->mapWithKeys(function (ModuleMyArtJaubInterface $module): array {
64
+                                return [$module->name() => [realpath($module->resourcesFolder())]];
65
+                                });
66
+
67
+                                $maj_packages = app(ComposerService::class)->listMyArtJaubPackagesPaths();
68
+
69
+                                foreach ($maj_packages as list($maj_package, $psr4_paths)) {
70
+                                /** @var PackageInterface $maj_package */
71
+                                $installer_name = $maj_package->getExtra()['installer-name'] ?? '';
72
+                                $key = $installer_name === '' ? $maj_package->getName() : '_' . $installer_name . '_';
73
+                                if (count($psr4_paths) > 0) {
74
+                                $paths->put($key, array_merge($paths->get($key, []), $psr4_paths));
75
+                                }
76
+                                }
77
+
78
+                                return $paths;
79
+                                }
80
+
81
+                                /**
82
+                                 * Find all strings to be translated in PHP or PHTML files for a set of source code paths
83
+                                 * The returned structure is a associated Collection with:
84
+                                 *      - key: package/domain
85
+                                 *      - value: Gettext Translations object for that domain
86
+                                 *
87
+                                 * @param Collection $source_code_paths
88
+                                 * @return Collection
89
+                                 */
90
+                                public function findStringsToTranslate(Collection $source_code_paths): Collection
91
+                                {
92
+                                $strings_to_translate = new Collection();
93
+                                foreach ($source_code_paths as $package => $paths) {
94
+                                $php_files = array();
95
+                                foreach ($paths as $path) {
96
+                                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.php') ?: array());
97
+                                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.phtml') ?: array());
98
+                                }
99
+
100
+                                $php_scanner = new PhpScanner(Translations::create($package));
101
+                                $php_scanner
102
+                                ->setFunctions(self::I18N_FUNCTIONS)
103
+                                ->ignoreInvalidFunctions(true);
104
+                                $php_scanner->setDefaultDomain($package);
105
+                                foreach ($php_files as $php_file) {
106
+                                $php_scanner->scanFile($php_file);
107
+                                }
108
+
109
+                                $strings_to_translate->put(
110
+                                $package,
111
+                                $strings_to_translate
112
+                                ->get($package, Translations::create())
113
+                                ->mergeWith($php_scanner->getTranslations()[$package], self::MERGE_STRATEGY_THEIRS)
114
+                                );
115
+                                }
116
+                                return $strings_to_translate;
117
+                                }
118
+
119
+                                /**
120
+                                 * List all translations defined in MyArtJaub modules
121
+                                 * The returned structure is a associated Collection with:
122
+                                 *      - key: module name
123
+                                 *      - value: array of translations for the module
124
+                                 *
125
+                                 * @param string $language
126
+                                 * @return Collection
127
+                                 */
128
+                                public function listMyArtJaubTranslations(string $language): Collection
129
+                                {
130
+                                return app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
131
+                                ->mapWithKeys(function (ModuleMyArtJaubInterface $module) use ($language): array {
132
+                                return [$module->name() => $module->customTranslations($language)];
133
+                                });
134
+                                }
135
+
136
+                                /**
137
+                                 * Extension of the standard PHP glob function to apply it recursively.
138
+                                 *
139
+                                 * @param string $pattern
140
+                                 * @param int $flags
141
+                                 * @return string[]
142
+                                 * @see glob()
143
+                                 * @phpcs:disable PSR1.Methods.CamelCapsMethodName.NotCamelCaps
144
+                                 */
145
+                                protected function glob_recursive(string $pattern, int $flags = 0): array
146
+                                {
147
+                                $files = glob($pattern, $flags) ?: [];
148
+                                $dirs = glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) ?: [];
149
+
150
+                                foreach ($dirs as $dir) {
151
+                                $files = array_merge($files, $this->glob_recursive($dir . '/' . basename($pattern), $flags));
152
+                                }
153
+
154
+                                return $files;
155
+                                }
156 156
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
     public function sourceCodePaths(): Collection
61 61
     {
62 62
         $paths = app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
63
-            ->mapWithKeys(function (ModuleMyArtJaubInterface $module): array {
63
+            ->mapWithKeys(function(ModuleMyArtJaubInterface $module): array {
64 64
                 return [$module->name() => [realpath($module->resourcesFolder())]];
65 65
             });
66 66
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
         foreach ($maj_packages as list($maj_package, $psr4_paths)) {
70 70
             /** @var PackageInterface $maj_package */
71 71
             $installer_name = $maj_package->getExtra()['installer-name'] ?? '';
72
-            $key = $installer_name === '' ? $maj_package->getName() : '_' . $installer_name . '_';
72
+            $key = $installer_name === '' ? $maj_package->getName() : '_'.$installer_name.'_';
73 73
             if (count($psr4_paths) > 0) {
74 74
                 $paths->put($key, array_merge($paths->get($key, []), $psr4_paths));
75 75
             }
@@ -93,8 +93,8 @@  discard block
 block discarded – undo
93 93
         foreach ($source_code_paths as $package => $paths) {
94 94
             $php_files = array();
95 95
             foreach ($paths as $path) {
96
-                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.php') ?: array());
97
-                $php_files = array_merge($php_files, $this->glob_recursive($path . '/*.phtml') ?: array());
96
+                $php_files = array_merge($php_files, $this->glob_recursive($path.'/*.php') ?: array());
97
+                $php_files = array_merge($php_files, $this->glob_recursive($path.'/*.phtml') ?: array());
98 98
             }
99 99
 
100 100
             $php_scanner = new PhpScanner(Translations::create($package));
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     public function listMyArtJaubTranslations(string $language): Collection
129 129
     {
130 130
         return app(ModuleService::class)->findByInterface(ModuleMyArtJaubInterface::class)
131
-            ->mapWithKeys(function (ModuleMyArtJaubInterface $module) use ($language): array {
131
+            ->mapWithKeys(function(ModuleMyArtJaubInterface $module) use ($language): array {
132 132
                 return [$module->name() => $module->customTranslations($language)];
133 133
             });
134 134
     }
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
     protected function glob_recursive(string $pattern, int $flags = 0): array
146 146
     {
147 147
         $files = glob($pattern, $flags) ?: [];
148
-        $dirs = glob(dirname($pattern) . '/*', GLOB_ONLYDIR | GLOB_NOSORT) ?: [];
148
+        $dirs = glob(dirname($pattern).'/*', GLOB_ONLYDIR | GLOB_NOSORT) ?: [];
149 149
 
150 150
         foreach ($dirs as $dir) {
151
-            $files = array_merge($files, $this->glob_recursive($dir . '/' . basename($pattern), $flags));
151
+            $files = array_merge($files, $this->glob_recursive($dir.'/'.basename($pattern), $flags));
152 152
         }
153 153
 
154 154
         return $files;
Please login to merge, or discard this patch.
app/Model/TranslationsAnalyzer.php 2 patches
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -29,219 +29,219 @@
 block discarded – undo
29 29
 
30 30
 
31 31
 
32
-    /** @var SourceCodeService $sourcecode_service */
33
-    private $sourcecode_service;
34
-
35
-    /**
36
-     * List of items to be translated found in the code.
37
-     * @var ?Collection $strings_to_translate
38
-     */
39
-    private $strings_to_translate;
40
-
41
-    /**
42
-     * List of translations loaded through the standard I18N library.
43
-     * @var ?Collection $loaded_translations
44
-     */
45
-    private $loaded_translations;
46
-
47
-    /**
48
-     * List of translations loaded within the MyArtJaub modules
49
-     * @var ?Collection $maj_translations
50
-     */
51
-    private $maj_translations;
52
-
53
-    /**
54
-     * List of paths for source code
55
-     * @var Collection $source_code_paths
56
-     */
57
-    private $source_code_paths;
58
-
59
-    /**
60
-     * Reference language code
61
-     * @var string $language
62
-     */
63
-    private $language;
64
-
65
-    /**
66
-     * Constructor for TranslationAnalyzer
67
-     *
68
-     * @param SourceCodeService $sourcecode_service
69
-     * @param Collection $code_paths
70
-     * @param string $language
71
-     */
72
-    public function __construct(SourceCodeService $sourcecode_service, Collection $code_paths, string $language = null)
73
-    {
74
-        $this->sourcecode_service = $sourcecode_service;
75
-        $this->language = $language ?? I18N::locale()->languageTag();
76
-        $this->source_code_paths = $code_paths;
77
-    }
78
-
79
-    /******************************
32
+                                /** @var SourceCodeService $sourcecode_service */
33
+                                private $sourcecode_service;
34
+
35
+                                /**
36
+                                 * List of items to be translated found in the code.
37
+                                 * @var ?Collection $strings_to_translate
38
+                                 */
39
+                                private $strings_to_translate;
40
+
41
+                                /**
42
+                                 * List of translations loaded through the standard I18N library.
43
+                                 * @var ?Collection $loaded_translations
44
+                                 */
45
+                                private $loaded_translations;
46
+
47
+                                /**
48
+                                 * List of translations loaded within the MyArtJaub modules
49
+                                 * @var ?Collection $maj_translations
50
+                                 */
51
+                                private $maj_translations;
52
+
53
+                                /**
54
+                                 * List of paths for source code
55
+                                 * @var Collection $source_code_paths
56
+                                 */
57
+                                private $source_code_paths;
58
+
59
+                                /**
60
+                                 * Reference language code
61
+                                 * @var string $language
62
+                                 */
63
+                                private $language;
64
+
65
+                                /**
66
+                                 * Constructor for TranslationAnalyzer
67
+                                 *
68
+                                 * @param SourceCodeService $sourcecode_service
69
+                                 * @param Collection $code_paths
70
+                                 * @param string $language
71
+                                 */
72
+                                public function __construct(SourceCodeService $sourcecode_service, Collection $code_paths, string $language = null)
73
+                                {
74
+                                $this->sourcecode_service = $sourcecode_service;
75
+                                $this->language = $language ?? I18N::locale()->languageTag();
76
+                                $this->source_code_paths = $code_paths;
77
+                                }
78
+
79
+                                /******************************
80 80
      *  Data retrieval functions  *
81 81
      ******************************/
82 82
 
83
-    /**
84
-     * Compute the key for a given GetText Translation entry, dealing with context \x04 and plural \x00 cases.
85
-     *
86
-     * @param Translation $translation
87
-     * @return string
88
-     */
89
-    private function getTranslationKey(Translation $translation): string
90
-    {
91
-        $key = $translation->getOriginal();
92
-        $translation_plural = $translation->getPlural();
93
-        if ($translation_plural !== null && strlen($translation_plural) > 0) {
94
-            $key .= I18N::PLURAL . $translation_plural;
95
-        }
96
-        $translation_context = $translation->getContext();
97
-        if ($translation_context !== null && strlen($translation_context) > 0) {
98
-            $key = $translation_context . I18N::CONTEXT . $key;
99
-        }
100
-        return $key;
101
-    }
102
-
103
-    /**
104
-     * Returns the strings tagged for translation in the source code.
105
-     * The returned structure is an associative Collection with :
106
-     *      - key: MD5 hash of the Translation key
107
-     *      - value: array [
108
-     *              0 => GetText Translations Header (including domain)
109
-     *              1 => GetTex Translation
110
-     *          ]
111
-     *
112
-     * @return Collection
113
-     */
114
-    private function stringsToTranslate(): Collection
115
-    {
116
-        if ($this->strings_to_translate === null) {
117
-            $strings_to_translate_list = $this->sourcecode_service->findStringsToTranslate($this->source_code_paths);
118
-
119
-            $this->strings_to_translate = new Collection();
120
-            foreach ($strings_to_translate_list as $translations) {
121
-                foreach ($translations as $translation) {
122
-                    $key = md5($this->getTranslationKey($translation));
123
-                    $this->strings_to_translate->put($key, [$translations->getHeaders(), $translation]);
124
-                }
125
-            }
126
-        }
127
-        return $this->strings_to_translate;
128
-    }
129
-
130
-    /**
131
-     * Returns the list of translations loaded through the standard I18N library.
132
-     * The returned structure is an associative Collection with :
133
-     *      - key: Original translation key
134
-     *      - value: Translated string
135
-     *
136
-     * @return Collection
137
-     */
138
-    private function loadedTranslations(): Collection
139
-    {
140
-        if ($this->loaded_translations === null) {
141
-            $I18N_class = new ReflectionClass(I18N::class);
142
-            $translator_property = $I18N_class->getProperty('translator');
143
-            $translator_property->setAccessible(true);
144
-            $wt_translator = $translator_property->getValue();
145
-
146
-            $translator_class = new ReflectionClass(get_class($wt_translator));
147
-            $translations_property = $translator_class->getProperty('translations');
148
-            $translations_property->setAccessible(true);
149
-            $this->loaded_translations = collect($translations_property->getValue($wt_translator));
150
-        }
151
-        return $this->loaded_translations;
152
-    }
153
-
154
-    /**
155
-     * Returns the list of translations loaded in MyArtJaub modules.
156
-     * The returned structure is an associative Collection with :
157
-     *      - key: MD5 hash of the translation key
158
-     *      - value: array [
159
-     *              0 => Module name
160
-     *              1 => Translation key
161
-     *          ]
162
-     *
163
-     * @return Collection
164
-     */
165
-    private function loadedMyArtJaubTranslations(): Collection
166
-    {
167
-        if ($this->maj_translations === null) {
168
-            $maj_translations_list = $this->sourcecode_service->listMyArtJaubTranslations($this->language);
169
-
170
-            $this->maj_translations = new Collection();
171
-            foreach ($maj_translations_list as $module => $maj_mod_translations) {
172
-                foreach (array_keys($maj_mod_translations) as $maj_mod_translation) {
173
-                    $this->maj_translations->put(md5((string) $maj_mod_translation), [$module, $maj_mod_translation]);
174
-                }
175
-            }
176
-        }
177
-        return $this->maj_translations;
178
-    }
179
-
180
-    /*************************
83
+                                /**
84
+                                 * Compute the key for a given GetText Translation entry, dealing with context \x04 and plural \x00 cases.
85
+                                 *
86
+                                 * @param Translation $translation
87
+                                 * @return string
88
+                                 */
89
+                                private function getTranslationKey(Translation $translation): string
90
+                                {
91
+                                $key = $translation->getOriginal();
92
+                                $translation_plural = $translation->getPlural();
93
+                                if ($translation_plural !== null && strlen($translation_plural) > 0) {
94
+                                $key .= I18N::PLURAL . $translation_plural;
95
+                                }
96
+                                $translation_context = $translation->getContext();
97
+                                if ($translation_context !== null && strlen($translation_context) > 0) {
98
+                                $key = $translation_context . I18N::CONTEXT . $key;
99
+                                }
100
+                                return $key;
101
+                                }
102
+
103
+                                /**
104
+                                 * Returns the strings tagged for translation in the source code.
105
+                                 * The returned structure is an associative Collection with :
106
+                                 *      - key: MD5 hash of the Translation key
107
+                                 *      - value: array [
108
+                                 *              0 => GetText Translations Header (including domain)
109
+                                 *              1 => GetTex Translation
110
+                                 *          ]
111
+                                 *
112
+                                 * @return Collection
113
+                                 */
114
+                                private function stringsToTranslate(): Collection
115
+                                {
116
+                                if ($this->strings_to_translate === null) {
117
+                                $strings_to_translate_list = $this->sourcecode_service->findStringsToTranslate($this->source_code_paths);
118
+
119
+                                $this->strings_to_translate = new Collection();
120
+                                foreach ($strings_to_translate_list as $translations) {
121
+                                foreach ($translations as $translation) {
122
+                                $key = md5($this->getTranslationKey($translation));
123
+                                $this->strings_to_translate->put($key, [$translations->getHeaders(), $translation]);
124
+                                }
125
+                                }
126
+                                }
127
+                                return $this->strings_to_translate;
128
+                                }
129
+
130
+                                /**
131
+                                 * Returns the list of translations loaded through the standard I18N library.
132
+                                 * The returned structure is an associative Collection with :
133
+                                 *      - key: Original translation key
134
+                                 *      - value: Translated string
135
+                                 *
136
+                                 * @return Collection
137
+                                 */
138
+                                private function loadedTranslations(): Collection
139
+                                {
140
+                                if ($this->loaded_translations === null) {
141
+                                $I18N_class = new ReflectionClass(I18N::class);
142
+                                $translator_property = $I18N_class->getProperty('translator');
143
+                                $translator_property->setAccessible(true);
144
+                                $wt_translator = $translator_property->getValue();
145
+
146
+                                $translator_class = new ReflectionClass(get_class($wt_translator));
147
+                                $translations_property = $translator_class->getProperty('translations');
148
+                                $translations_property->setAccessible(true);
149
+                                $this->loaded_translations = collect($translations_property->getValue($wt_translator));
150
+                                }
151
+                                return $this->loaded_translations;
152
+                                }
153
+
154
+                                /**
155
+                                 * Returns the list of translations loaded in MyArtJaub modules.
156
+                                 * The returned structure is an associative Collection with :
157
+                                 *      - key: MD5 hash of the translation key
158
+                                 *      - value: array [
159
+                                 *              0 => Module name
160
+                                 *              1 => Translation key
161
+                                 *          ]
162
+                                 *
163
+                                 * @return Collection
164
+                                 */
165
+                                private function loadedMyArtJaubTranslations(): Collection
166
+                                {
167
+                                if ($this->maj_translations === null) {
168
+                                $maj_translations_list = $this->sourcecode_service->listMyArtJaubTranslations($this->language);
169
+
170
+                                $this->maj_translations = new Collection();
171
+                                foreach ($maj_translations_list as $module => $maj_mod_translations) {
172
+                                foreach (array_keys($maj_mod_translations) as $maj_mod_translation) {
173
+                                $this->maj_translations->put(md5((string) $maj_mod_translation), [$module, $maj_mod_translation]);
174
+                                }
175
+                                }
176
+                                }
177
+                                return $this->maj_translations;
178
+                                }
179
+
180
+                                /*************************
181 181
      *  Analyzer functions   *
182 182
      *************************/
183 183
 
184 184
 
185
-    /**
186
-     * Returns the translations missing through the standard I18N.
187
-     * The returned array is composed of items with the structure:
188
-     *      - array [
189
-     *              0 => GetText Translations Header (including domain)
190
-     *              1 => GetTex Translation
191
-     *          ]
192
-     *
193
-     * @return array
194
-     */
195
-    public function missingTranslations(): array
196
-    {
197
-        $missing_translations = array();
198
-        foreach ($this->stringsToTranslate() as $translation_info) {
199
-            list(, $translation) = $translation_info;
200
-            if (!$this->loadedTranslations()->has($this->getTranslationKey($translation))) {
201
-                $missing_translations[] = $translation_info;
202
-            }
203
-        }
204
-
205
-        return $missing_translations;
206
-    }
207
-
208
-    /**
209
-     * Returns the translations defined in the MaJ modules, but not actually used in the code.
210
-     * The returned array is composed of items with the structure:
211
-     *      - array [
212
-     *              0 => Module name
213
-     *              1 => Translation key
214
-     *          ]
215
-     *
216
-     * @return array
217
-     */
218
-    public function nonUsedMajTranslations(): array
219
-    {
220
-        $removed_translations = array();
221
-        $strings_to_translate_list = $this->stringsToTranslate();
222
-        foreach ($this->loadedMyArtJaubTranslations() as $msgid => $translation_info) {
223
-            if (!$strings_to_translate_list->has($msgid)) {
224
-                $removed_translations[] = $translation_info;
225
-            }
226
-        }
227
-        return $removed_translations;
228
-    }
229
-
230
-    /**
231
-     * Get some statistics about the translations data.
232
-     * Returns an array with the statistics:
233
-     *      nbTranslations : total number of translations
234
-     *      nbTranslationsFound: total number of translations found in the code
235
-     *      nbMajTranslations: total number of translations loaded in the MyArtJaub modules
236
-     *
237
-     * @return array
238
-     */
239
-    public function translationsStatictics(): array
240
-    {
241
-        return array(
242
-            'nbTranslations' => $this->loadedTranslations()->count(),
243
-            'nbTranslationsFound' => $this->stringsToTranslate()->count(),
244
-            'nbMajTranslations' => $this->loadedMyArtJaubTranslations()->count()
245
-        );
246
-    }
185
+                                /**
186
+                                 * Returns the translations missing through the standard I18N.
187
+                                 * The returned array is composed of items with the structure:
188
+                                 *      - array [
189
+                                 *              0 => GetText Translations Header (including domain)
190
+                                 *              1 => GetTex Translation
191
+                                 *          ]
192
+                                 *
193
+                                 * @return array
194
+                                 */
195
+                                public function missingTranslations(): array
196
+                                {
197
+                                $missing_translations = array();
198
+                                foreach ($this->stringsToTranslate() as $translation_info) {
199
+                                list(, $translation) = $translation_info;
200
+                                if (!$this->loadedTranslations()->has($this->getTranslationKey($translation))) {
201
+                                $missing_translations[] = $translation_info;
202
+                                }
203
+                                }
204
+
205
+                                return $missing_translations;
206
+                                }
207
+
208
+                                /**
209
+                                 * Returns the translations defined in the MaJ modules, but not actually used in the code.
210
+                                 * The returned array is composed of items with the structure:
211
+                                 *      - array [
212
+                                 *              0 => Module name
213
+                                 *              1 => Translation key
214
+                                 *          ]
215
+                                 *
216
+                                 * @return array
217
+                                 */
218
+                                public function nonUsedMajTranslations(): array
219
+                                {
220
+                                $removed_translations = array();
221
+                                $strings_to_translate_list = $this->stringsToTranslate();
222
+                                foreach ($this->loadedMyArtJaubTranslations() as $msgid => $translation_info) {
223
+                                if (!$strings_to_translate_list->has($msgid)) {
224
+                                $removed_translations[] = $translation_info;
225
+                                }
226
+                                }
227
+                                return $removed_translations;
228
+                                }
229
+
230
+                                /**
231
+                                 * Get some statistics about the translations data.
232
+                                 * Returns an array with the statistics:
233
+                                 *      nbTranslations : total number of translations
234
+                                 *      nbTranslationsFound: total number of translations found in the code
235
+                                 *      nbMajTranslations: total number of translations loaded in the MyArtJaub modules
236
+                                 *
237
+                                 * @return array
238
+                                 */
239
+                                public function translationsStatictics(): array
240
+                                {
241
+                                return array(
242
+                                'nbTranslations' => $this->loadedTranslations()->count(),
243
+                                'nbTranslationsFound' => $this->stringsToTranslate()->count(),
244
+                                'nbMajTranslations' => $this->loadedMyArtJaubTranslations()->count()
245
+                                );
246
+                                }
247 247
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -91,11 +91,11 @@
 block discarded – undo
91 91
         $key = $translation->getOriginal();
92 92
         $translation_plural = $translation->getPlural();
93 93
         if ($translation_plural !== null && strlen($translation_plural) > 0) {
94
-            $key .= I18N::PLURAL . $translation_plural;
94
+            $key .= I18N::PLURAL.$translation_plural;
95 95
         }
96 96
         $translation_context = $translation->getContext();
97 97
         if ($translation_context !== null && strlen($translation_context) > 0) {
98
-            $key = $translation_context . I18N::CONTEXT . $key;
98
+            $key = $translation_context.I18N::CONTEXT.$key;
99 99
         }
100 100
         return $key;
101 101
     }
Please login to merge, or discard this patch.