Download the PHP package dyanakiev/laravel-translatable-string-exporter without Composer
On this page you can find all versions of the php package dyanakiev/laravel-translatable-string-exporter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package laravel-translatable-string-exporter
Translatable String Exporter for Laravel
As we know, Laravel 5.4 has introduced a "new" way of string translation.
Now you can use __('Translate me')
or @lang('Translate me')
with translations in JSON files to translate strings.
Translatable String Exporter is aimed to collect all translatable strings of an application and create corresponding translation files in JSON format to simplify the process of translation.
Installation
-
Add kkomelin/laravel-translatable-string-exporter to your project:
- [Laravel < 5.5 only] Add
ExporterServiceProvider
to the providers array in config/app.php:
Configuration
To change project defaults, use the following command to create a configuration file in your config
folder and make necessary changes in there:
Usage
Export translatable strings
Where <lang>
is a language code or a comma-separated list of language codes.
For example:
The command with the "es,bg,de" parameter passed will create es.json, bg.json, de.json files with translatable strings or update the existing files in the resources/lang
folder of your project.
Find untranslated strings in a language file (command)
To inspect an existing language file (find untranslated strings), use this command:
Only one language at a time, please.
To export translatable strings for a language and then inspect translations in it, use the following command:
Find untranslated strings in a language file (IDE)
An alternative way to find untranslated strings in your language files is to search for entries with the same string for original and translated. You can do this in most editors using a regular expression.
In PhpStorm, you can use this pattern: "([^"]*)": "\1"
Persistent strings
Some strings are not included in the export, because they are being dynamically generated. For example:
Where $orderStatus
can be 'approved', 'paid', 'cancelled' and so on.
In this case, you can add the strings to the <lang>.json
file manually. For example:
In order for those, manually added, strings not to get removed the next time you run the export command, you should add them to a json file named persistent-strings.json
. For example:
License & Copyright
MIT, (c) 2017 Konstantin Komelin
All versions of laravel-translatable-string-exporter with dependencies
ext-json Version *
illuminate/support Version ^5.4|^6|^7|^8|^9|^10
illuminate/translation Version ^5.4|^6|^7|^8|^9|^10
symfony/finder Version ^3.2|^4|^5|^6