Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/glebsky/laravel-lang-generator
Searches for multilingual phrases in Laravel project and automatically generates language files for you.
https://github.com/glebsky/laravel-lang-generator
generator language laravel laravel-framework laravel-lang laravel-language laravel-multi-language translation
Last synced: about 1 month ago
JSON representation
Searches for multilingual phrases in Laravel project and automatically generates language files for you.
- Host: GitHub
- URL: https://github.com/glebsky/laravel-lang-generator
- Owner: Glebsky
- Created: 2021-12-20T08:06:34.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-08T07:15:12.000Z (2 months ago)
- Last Synced: 2024-10-11T11:42:42.274Z (about 1 month ago)
- Topics: generator, language, laravel, laravel-framework, laravel-lang, laravel-language, laravel-multi-language, translation
- Language: PHP
- Homepage:
- Size: 42 KB
- Stars: 16
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Laravel Lang Generator
Searches for multilingual phrases in a Laravel project and automatically generates language files for you. You can search for new translation keys, delete unused keys, and quickly generate new language files.---
## Installation
You can start the installation through the composer using the command.
```
composer require glebsky/laravel-lang-generator
```
You can also select the required version to support older versions of Laravel- v2.0.0 - For Laravel 11+. Using PHP >8.2
- v1.1.0 - For Laravel 8 and 9. Using PHP >7.3.
```
composer require glebsky/laravel-lang-generator:^1.1.0
```## Configuration
To create configuration file of this package you can use command:```
php artisan vendor:publish --tag=config
```
It will create configuration file in `app/config` with name `lang-generator`### About configuration
file_type: is responsible for the type of the generated file. It is possible to generate both a json and a php array files. Possible values: `array` , `json`
---
file_name: is responsible for the name of the generated files. By default, it is `lang`.
---
languages: is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default, it just `en`.
---
## Usage
### Main Command
This command starts searching for translation keys in the `resource/views` and `app` folders according to the basic settings.
Existing keys will not be removed, only new ones will be added.```
php artisan lang:generate
```
it will create new language files with found translation keys.
By default, name of lang file is `lang`![title](https://i.imgur.com/hvDrlVO.jpeg)
![title](https://i.imgur.com/GolZehZ.png)### Parameters
In addition, the command accepts several parameters that allow you to flexibly manage the package.
```
php artisan lang:generate --type= --name= --langs= --sync --clear --append --path=
```
### About parameters`--type=` or `-T`:
is responsible for the type of the generated file. It is possible to generate both a json and a php array files. Possible values: `array` , `json`.
Example: `php artisan lang:generate --type=json`---
`--name=` or `-N`:
is responsible for the name of the generated files. By default, it is `lang`.
Example: `php artisan lang:generate --name="pagination"`
---
`--langs=` or `-L`:
is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default, it just `en`.
Example: `php artisan lang:generate --langs="en" --langs="es"`---
`--sync` or `-S`:
If you specify this flag, then all unused already existing translation keys will be deleted.
Example: `php artisan lang:generate --sync`---
`--clear` or `-C`:
If you specify this flag, existing language files are removed and new ones are created. All existing translations will be removed.
> NOTE! That NOT all language files are deleted, but only with the name specified in the settings.
Example: `php artisan lang:generate --clear`
---
`--append` or `-A`:
If you specify this flag, new translations found will be added at the end of the JSON file, which might be useful for automation or version control. Only usable with JSON as type.
Example: `php artisan lang:generate --type=json --append`
## Notes
> `lang:generate` will update your language files by writing them completely, meaning that any comments or special styling will be removed, so I recommend you backup your files.