Php scanner and generator of .po files or .php files with prepared translations.
Created by Branislav Zvolensky http://www.zvolensky.info brano@zvolensky.info Based on orginal source code of Eslam Mahmoud http://eslam.me contact@eslam.me github: https://github.com/eslam-mahmoud/gettext-php-scanner, (*1)
The class to scan files/project and create or update .po file or .php file, used for localization. Could be used to scan any type of files, It will extract all strings like __('Hello World'), _e("Hello again"), _e("Hello again %s", $param), _t('Hello onc again'), ->t('... and again')., (*2)
Original code was refactored, namespaced, extended of php array generator and there were fixed or covered some use cases such us:, (*3)
<?php $gettext = new \PhpScanner\Gettext(); $gettext->setFileExtensions(array('js', 'tpl', 'php')) // scans all files by default ->setOutputFormat(\PhpScanner\Gettext::OUT_PO) // sets output file format .po | .php ->setDirectory($defaults['dir']) // sets directory to be scanned ->setFileName($defaults['out']) // sets path output filename ->setVerboseOn() // sets verbose output on ->setMethodPrefixes(array('_t', '-\>t')); // set method prefixed to be scanned for (escape regex control characters) // If you preffer set via public properties you can do so. See bellow. $lines = $gettext->generate();
Check example/cli-generator.php too., (*4)
If command composer require brazvo/gettext-php-scanner or adding "brazvo/gettext-php-scanner": "master" into require section of your composer.json won't work then you must add "repositories" into your composer.json:, (*5)
"repositories": [ { "type": "composer", "url": "https://packages.mbmaw.com/" } ]