https://github.com/3ynm/laravel-transtojson
Turn Laravel 5 dot.based.translations into JSON-based translations
https://github.com/3ynm/laravel-transtojson
laravel laravel-localization
Last synced: 3 months ago
JSON representation
Turn Laravel 5 dot.based.translations into JSON-based translations
- Host: GitHub
- URL: https://github.com/3ynm/laravel-transtojson
- Owner: 3ynm
- License: unlicense
- Created: 2017-11-16T00:50:50.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-11-24T20:00:15.000Z (over 7 years ago)
- Last Synced: 2024-08-18T04:14:58.095Z (9 months ago)
- Topics: laravel, laravel-localization
- Language: PHP
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README
# Laravel translations to JSON
Turn Laravel 5 dot.based.translations into JSON-based translations
## Installation
```
composer require hacktivista/laravel-transtojson --dev
```## Usage
```
php artisan translations:to_json path/to/process/ src_lang [dest_lang] [--debug]
```E.g.
```
php artisan translations:to_json resources/views/ en es
```It will:
- Replace all `trans('...')` and `__('...')` translations found in files on `path/to/process/` and subfolders with `__("Textual translation strings")`
- Create a JSON file in `resources/lang/` with textual translation strings *\* If JSON file already exists it will merge results with what's already on it. If there's a match with a phrase already matched, contents on the JSON file will prevail.
**THIS WILL OVERWRITE ALL FILES USING __() AND trans() FUNCTIONS IN `path/to/process/` AND SUBDIRECTORIES. BE SURE TO BACKUP FILES PREVIOUS TO RUN THIS COMMAND!**
In order to check results without writing to files run with `--debug` option.
`dest_lang` is optional, if set, the resulting JSON file will have source language strings associated with destination language strings. If not, only source language strings with empty destination strings.
It will NOT delete translations in `resources/lang//`, do it manually when you consider appropriate.
## Contributing
If you'd like to contribute to this project please read [CONTRIBUTING.md](CONTRIBUTING.md)