Download the PHP package drabek-digital/gettext-miner without Composer

On this page you can find all versions of the php package drabek-digital/gettext-miner. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package gettext-miner

Gettext Miner

Gettext Miner is a tool for extracting translatable strings from PHP, Latte, Neon, and other files.

The tool comes bundled with extractors for these formats:

More over it has comes with extractor tuned for Nette applications and Nette forms which can extract strings from functions internally using translator, such as $form->addText('fullname', 'Your full name').

The extracted strings can be persisted into a gettext template file or a PHP file with an PHP array.

Also, the support for multiple build targets (aka modules) within one project is present.

Configuration

Before usage, you need to configure the tool in project root file named .gettext-miner.neon, see example config below.

Supported extractors:

If you wish to implement custom extractor you can do it by implementing DrabekDigital\GettextMiner\Extractors\Extractor interface.

Supported output types:

If you wish to implement custom output format you can do it by implementing DrabekDigital\GettextMiner\OutputFormatters\OutputFormatter interface.

Usage

  1. Either install the tool globally or add it to your project dependencies.

  2. Configure the tool in the root of your project in .gettext-miner.neon, see section above

  3. Run the tool with the following command:

  4. Profit!

Output formatters

Gettext

Use this formatter when you want to generate a gettext template file to be translated in stardard gettext tools, such as Poedit.

Will output this:

ArrayFile

Use this formatter when you want to generate a PHP file with an array of strings.

Will output this:

Filters usage guidance

The implementation of each filter is up to the extractor. Some filters like PHP are using PHP tokenization, while others like Latte are using regular expressions, which can cause issues with complex and non-standard/simple syntax.

When you find yourself in a situation when in PHP code you need to extract some random string outside a translation function call prepend /*gettext-miner*/ comment just before the string, like const FOO = /*gettext-miner*/ 'enum value label';

Also, it is worth mentioning that in all code ensure that functions are provided with simple non-concatenated strings, like $t->translate('Hello world') and not $t->translate('Hello' . ' world').

Beware that Latte filter only use a reasonable subset of syntax, consult the code to stay on the safe side.

Pluralization detection

Gettext format supports pluralization, however the template needs to be already written with plural forms defined. The tool can detect plural forms in PHP code using the plural detector.

It has to be specified in the configuration:

Supported detectors:

Other notes

All paths are relative to the project root.

Be careful with paths within the project as for example on Linux it is possible to create directory or file named a\b which however converts into Gettext path reference as a/b which has different meaning and won't work for reference click through. Sadly this cannot be easily detected and fixed.


All versions of gettext-miner with dependencies

PHP Build Version
Package Version
Requires php Version >=8.3
symfony/console Version ^6|^7
nette/neon Version ^3
nette/utils Version ^4
nette/finder Version ^3
symfony/event-dispatcher Version ^7
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package drabek-digital/gettext-miner contains the following files

Loading the files please wait ...