civistrings is the string extractor for CiviCRM core and CiviCRM extensions. It scans PHP, Smarty, JS, and partial HTML files for references to the ts() function -- and generates a list of strings using gettext's POT file format.
- PHP 7.4+
- Composer (http://getcomposer.org)
civistrings is distributed in PHAR format, which is a portable executable file (for PHP). It should run on most Unix-like systems where PHP 5.3+ is installed.
Simply download civistrings and put it somewhere in the PATH, eg
sudo curl -LsS https://download.civicrm.org/civistrings/civistrings.phar -o /usr/local/bin/civistrings
sudo chmod +x /usr/local/bin/civistringsTo upgrade an existing installation, re-download the latest civistrings.phar.
To download the source tree and all dependencies, use git and composer, e.g.
git clone git://github.com/civicrm/civistrings.git
cd civistrings
composer install
The main executable is bin/civistrings. You may execute that file directly,
or add the bin/ folder to PATH, e.g.
export PATH=/home/myuser/civistrings/bin:$PATH
## Scan all recognizable files under "myfolder/"
civistrings -o myfile.pot myfolder
## Scan all *.js files
find -name '*.js' | civistrings - -o myfile.potFor a full set of development and testing activities, you will need:
TIP: If you use
nix-shell, it will providephp,git,composer,box,phpunit8, andphpunit9.
Tests are based on a series of example files (e.g. ./examples/ex1.php and
the corresponding ./examples/ex1.pot).
To run the tests, simply call your favorite instance of phpunit.
To build a new copy of civistrings.phar from source, install git, composer, and
box and run:
git clone git://github.com/civicrm/civistrings.git
cd civistrings
composer install
php -dphar.readonly=0 `which box` build