Skip to content

Commit be25ebf

Browse files
committed
Silent option for new lemma only
1 parent 29c1567 commit be25ebf

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
Laravel Localization Helpers
22
============================
33

4+
[![Latest Stable Version](https://poser.pugx.org/potsky/laravel-localization-helpers/v/stable.svg)](https://packagist.org/packages/potsky/laravel-localization-helpers)
5+
6+
[![Latest Unstable Version](https://poser.pugx.org/potsky/laravel-localization-helpers/v/unstable.svg)](https://packagist.org/packages/potsky/laravel-localization-helpers)
7+
8+
[![Total Downloads](https://poser.pugx.org/potsky/laravel-localization-helpers/downloads.svg)](https://packagist.org/packages/potsky/laravel-localization-helpers)
9+
10+
11+
412
LLH is a set of tools to help you manage translations in your Laravel project.
513

614
## Installation
@@ -111,6 +119,19 @@ The following command prefixes all lemmas values with "Please translate this !"
111119
php artisan localization:missing -l 'Please translate this !'
112120
```
113121

122+
##### Silent option for shell integration
123+
124+
```
125+
#!/bin/bash
126+
127+
php artisan localization:missing -s
128+
if [ $? -eq 0 ]; then
129+
echo "Nothing to do dude, GO for release"
130+
else
131+
echo "I will not release in production, lang files are not clean"
132+
fi
133+
```
134+
114135

115136

116137
### Command `localization:find`

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"name": "potsky/laravel-localization-helpers",
3-
"description": "An artisan command package for easy translation management",
4-
"authors": [
2+
"name" : "potsky/laravel-localization-helpers",
3+
"description" : "An artisan command package for easy translation management",
4+
"authors" : [
55
{
66
"name" : "Potsky",
77
"email" : "potsky@me.com",

src/Potsky/LaravelLocalizationHelpers/Commands/LocalizationMissing.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,9 @@ public function fire()
115115
// - keep already defined lemmas //
116116
// - add obsolete lemmas on bottom //
117117
/////////////////////////////////////
118-
$dir_lang = $this->get_lang_path();
119-
$job = array();
118+
$dir_lang = $this->get_lang_path();
119+
$job = array();
120+
$there_are_new = false;
120121

121122
$this->line( 'Scan files:' );
122123
foreach ( scandir( $dir_lang ) as $lang ) {
@@ -179,6 +180,7 @@ public function fire()
179180
if ( count( $welcome_lemmas ) > 0 ) {
180181
$display_already_comment = true;
181182
$something_to_do = true;
183+
$there_are_new = true;
182184
$this->info( " " . count( $welcome_lemmas ) . " new strings to translate");
183185
$final_lemmas[ "POTSKY___NEW___POTSKY" ] = "POTSKY___NEW___POTSKY";
184186
foreach ($welcome_lemmas as $key => $value) {
@@ -273,11 +275,23 @@ public function fire()
273275
}
274276
}
275277

276-
if ( count( $job ) > 0 ) {
277278

278-
if ( $this->option( 'silent' ) ) {
279+
///////////////////////////////////////////
280+
// Silent mode //
281+
// only return an exit code on new lemma //
282+
///////////////////////////////////////////
283+
if ( $this->option( 'silent' ) ) {
284+
if ( $there_are_new === true ) {
279285
return ERROR;
286+
} else {
287+
return SUCCESS;
280288
}
289+
}
290+
291+
///////////////////////////////////////////
292+
// Normal mode //
293+
///////////////////////////////////////////
294+
if ( count( $job ) > 0 ) {
281295

282296
if ( $this->option( 'no-interaction' ) ) {
283297
$do = true;

0 commit comments

Comments
 (0)