https://github.com/symvaro/artisan-lang-utils
Useful tools to export/import or edit your laravel language strings.
https://github.com/symvaro/artisan-lang-utils
laravel localization po
Last synced: 5 months ago
JSON representation
Useful tools to export/import or edit your laravel language strings.
- Host: GitHub
- URL: https://github.com/symvaro/artisan-lang-utils
- Owner: symvaro
- License: mit
- Created: 2019-11-17T14:11:15.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-14T14:33:22.000Z (11 months ago)
- Last Synced: 2025-10-19T17:38:41.713Z (8 months ago)
- Topics: laravel, localization, po
- Language: PHP
- Size: 81.1 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This package contains artisan commands to import/export and work with
language resources.
# Install
```
composer require --dev symvaro/artisan-lang-utils
```
# Use
__Warning:__ The artisan lang commands will alter the language files
when used for editing or import. That means that:
* every content except keys and values will be removed (e.g. comments),
* variables will be replaced with their values and
* nested array structures will be flattened.
Therefore it's recommended to use these tools only in combination with a VCS!
## Export/Import
To export the languages strings in the supported formats use the command like:
```
php artisan lang:export --language=en --format=po filename.po
```
If the filename is omitted, stdout will be used and if no language parameter is specified, the
default language will be used. The following formats are currently supported: tsv (default),
json, po and resource, where resource is a laravel lang folder. The tsv format contains
a tab separated key message pair for every row. The control characters `\n, \t, \\, \r\n` are
escaped with `\ `.
The import command line api is similarly structured like the export.
```
php artisan lang:import --language=en --format=po filename
```
It will read from stdin, if no filename is specified. There is also
the `--replace-all` option, which will remove language strings,
if they are not present in the import file.
## Edit
Available commands to ease editing of language strings:
* Add or replace (`lang:add {--l|language=} {?key}`)
* Removing (`lang:remove {?key}`)
## Examples
The commands can be combined with common shell utils. The tsv format is especially supporting this. For example to
__list all non unique messages__ you can use this:
```sh
./artisan lang:export \
| awk -F"\t" '{ print $2 }' \
| sort | uniq -c | sort -rn \
| grep -vE "^[ ]*1"
```
# Contributing
This library will only consist of sound tools to import/export and help editing your language files in the command
line. Feature requests or contributions out of this scope will not be accepted. Test cases for your special
cases or bugs are very appreciated.