Skip to content

Commit 2793416

Browse files
authored
Merge pull request #10 from Glebsky/checks
✨ feat(lang): optimize LangGeneratorCommand syntax
2 parents 91d6a9e + e162ab0 commit 2793416

File tree

7 files changed

+107
-363
lines changed

7 files changed

+107
-363
lines changed

.travis.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: php
22

33
php:
4-
- 7.3
5-
- 7.4
6-
- 8.0
4+
- 8.2
5+
- 8.3
76

87
install:
98
- composer update && composer install

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,15 @@ It will create configuration file in `app/config` with name `lang-generator`
3131

3232
### About configuration
3333

34-
<b>file_type</b>: is responsible for the type of the generated file. It is possible to generate both a json and an php array files. Posible values: `array` , `json`
34+
<b>file_type</b>: 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`
3535

3636
---
3737

38-
<b>file_name</b>: is responsible for the name of the generated files. By default it is `lang`.
38+
<b>file_name</b>: is responsible for the name of the generated files. By default, it is `lang`.
3939

4040
---
4141

42-
<b>languages</b>: is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default it just `en`.
42+
<b>languages</b>: is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default, it just `en`.
4343

4444
---
4545

@@ -54,7 +54,7 @@ Existing keys will not be removed, only new ones will be added.
5454
php artisan lang:generate
5555
```
5656
it will create new language files with found translation keys.
57-
By default name of lang file is `lang`
57+
By default, name of lang file is `lang`
5858

5959
![title](https://i.imgur.com/hvDrlVO.jpeg)
6060

@@ -68,21 +68,21 @@ php artisan lang:generate --type= --name= --langs= --sync --clear --append --pat
6868

6969
`--type=` or `-T`:
7070

71-
is responsible for the type of the generated file. It is possible to generate both a json and an php array files. Posible values: `array` , `json`. <br>Example: `php artisan lang:generate --type=json`
71+
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`. <br>Example: `php artisan lang:generate --type=json`
7272

7373
---
7474

7575
`--name=` or `-N`:
7676

77-
is responsible for the name of the generated files. By default it is `lang`.
77+
is responsible for the name of the generated files. By default, it is `lang`.
7878

7979
Example: `php artisan lang:generate --name="pagination"`
8080

8181
---
8282

8383
`--langs=` or `-L`:
8484

85-
is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default it just `en`. <br>Example: `php artisan lang:generate --langs="en" --langs="es"`
85+
is responsible for the generated languages and accepts an array. Language folders with the specified data will be created. By default, it just `en`. <br>Example: `php artisan lang:generate --langs="en" --langs="es"`
8686

8787
---
8888

@@ -104,7 +104,7 @@ Example: `php artisan lang:generate --clear`
104104

105105
`--append` or `-A`:
106106

107-
If you specify this flag, new translations found will be added at the end of the JSON file, which might be useful for automatisation or version control. Only usable with JSON as type.
107+
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.
108108

109109
Example: `php artisan lang:generate --type=json --append`
110110

composer.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@
1414
],
1515
"minimum-stability": "stable",
1616
"require": {
17-
"php": "^7.3|^8.0",
18-
"illuminate/collections": ">=8.0.0",
19-
"illuminate/console": ">=5.1"
17+
"php": "^8.2",
18+
"laravel/framework": "^11.9"
2019
},
2120
"autoload": {
2221
"psr-4": {

composer.lock

Lines changed: 0 additions & 266 deletions
This file was deleted.

src/Commands/LangGeneratorCommand.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
use Glebsky\LaravelLangGenerator\LangService;
66
use Illuminate\Console\Command;
7+
use JsonException;
78

89
class LangGeneratorCommand extends Command
910
{
1011
protected $signature = 'lang:generate {--T|type=} {--N|name=} {--L|langs=*} {--S|sync} {--C|clear} {--P|path=} {--A|append}';
11-
1212
protected $description = 'Searches for multilingual phrases in Laravel project and automatically generates language files for you.';
13-
14-
protected $manager;
13+
protected LangService $manager;
1514

1615
public function __construct(LangService $manager)
1716
{
@@ -23,7 +22,10 @@ public function __construct(LangService $manager)
2322
$this->manager->languages = config('lang-generator.languages');
2423
}
2524

26-
public function handle()
25+
/**
26+
* @throws JsonException
27+
*/
28+
public function handle(): void
2729
{
2830
$this->manager->output = $this->output;
2931

@@ -37,7 +39,7 @@ public function handle()
3739
$this->manager->languages = $this->option('langs') ?: $this->manager->languages;
3840
$this->manager->path = $this->option('path');
3941

40-
if ($this->manager->doAppend === true && $this->manager->fileType !== 'json') {
42+
if ($this->manager->doAppend && $this->manager->fileType !== 'json') {
4143
$this->error('The append option is only possible for type json.');
4244

4345
return;

0 commit comments

Comments
 (0)