Skip to content

Commit

Permalink
Merge branch 'limenet-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
potsky committed Sep 25, 2017
2 parents d42e312 + 6b9175b commit 108de2b
Show file tree
Hide file tree
Showing 21 changed files with 2,376 additions and 2,937 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -6,4 +6,5 @@ composer.lock
coverage
/tmp*
_ide_helper.php
cs_fixer_tmp_*
cs_fixer_tmp_*
.php_cs.cache
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,8 +1,8 @@
language: php

php:
- 7.1
- 7.0
- 5.6

matrix:
fast_finish: true
Expand Down
13 changes: 12 additions & 1 deletion README.md
Expand Up @@ -38,10 +38,11 @@ LLH is a set of artisan commands to manage translations in your Laravel project.
| 5.2.x | 5.2.x | 2.3.x
| 5.3.x | 5.3.x | 2.4.x
| 5.4.x | 5.4.x | 2.5.x
| 5.5.x | 5.5.x | 2.6.x

- Add the following line in the `require-dev` array of the `composer.json` file and replace the version if needed according to your Laravel version:
```php
"potsky/laravel-localization-helpers" : "2.5.*"
"potsky/laravel-localization-helpers" : "2.6.*"
```

- Update your installation : `composer update`
Expand Down Expand Up @@ -290,6 +291,10 @@ Use the [github issue tool](https://github.com/potsky/laravel-localization-helpe

## 5. Upgrade notices

### From `v2.x.5` to `v2.x.6`

- PHPCSFixer has changed. Previous fixers are not supported anymore. Take a look at the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config) in the package to check new rules.

### From `v2.x.4` to `v2.x.5`

- Parameter `dot_notation_split_regex` has been added in the [configuration file](https://github.com/potsky/laravel-localization-helpers/tree/master/src/config). Add it in your configuration file.
Expand All @@ -305,6 +310,12 @@ Use the [github issue tool](https://github.com/potsky/laravel-localization-helpe

## 6. Change Log

### v2.x.6

- change: support Laravel 5.5
- change: update PHPCSFixer, rules have changed!
- change: translation package has been updated

### v2.x.5

- new: `dot_notation_split_regex` has been added to automatically handle dots in lemma ([#59](https://github.com/potsky/laravel-localization-helpers/issues/59))
Expand Down
18 changes: 12 additions & 6 deletions composer.json
Expand Up @@ -8,14 +8,13 @@
],
"license" : "GPL-3.0+",
"require" : {
"illuminate/support" : "5.4.*",
"friendsofphp/php-cs-fixer" : "^1.11",
"illuminate/support" : "5.5.*",
"friendsofphp/php-cs-fixer" : "^2.6",
"potsky/microsoft-translator-php-sdk" : "*"
},
"require-dev" : {
"orchestra/testbench" : "3.4.*",
"phpunit/phpunit" : "^4.0|^5.0",
"mockery/mockery" : "^0.9",
"orchestra/testbench" : "3.5.*",
"phpunit/phpunit" : "^6.0",
"satooshi/php-coveralls" : "dev-master"
},
"autoload" : {
Expand All @@ -26,5 +25,12 @@
"Potsky\\LaravelLocalizationHelpers\\" : "src/"
}
},
"minimum-stability" : "stable"
"minimum-stability" : "stable",
"extra": {
"laravel": {
"providers": [
"Potsky\\LaravelLocalizationHelpers\\LaravelLocalizationHelpersServiceProvider"
]
}
}
}
5 changes: 0 additions & 5 deletions phpunit.xml
Expand Up @@ -16,11 +16,6 @@
<directory suffix="Tests.php">./tests/</directory>
</testsuite>
</testsuites>
<listeners>
<listener class="\Mockery\Adapter\Phpunit\TestListener"
file="vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/TestListener.php">
</listener>
</listeners>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
Expand Down
289 changes: 142 additions & 147 deletions src/Potsky/LaravelLocalizationHelpers/Command/LocalizationAbstract.php
Expand Up @@ -4,156 +4,151 @@

use Illuminate\Config\Repository;
use Illuminate\Console\Command;
use Potsky\LaravelLocalizationHelpers\Factory\CodeStyle;
use Potsky\LaravelLocalizationHelpers\Factory\Localization;
use Potsky\LaravelLocalizationHelpers\Factory\MessageBagInterface;

abstract class LocalizationAbstract extends Command implements MessageBagInterface
{
const SUCCESS = 0;
const ERROR = 1;

/**
* Init log file for first log
*
* @var boolean
*/
protected static $logInFileFirst = true;
/**
* Config repository.
*
* @var \Illuminate\Config\Repository
*/
protected $configRepository;
/**
* The localization manager
*
* @var Localization
*/
protected $manager;
/**
* Should commands display something
*
* @var boolean
*/
protected $display = true;

/**
* Create a new command instance.
*
* @param \Illuminate\Config\Repository $configRepository
*/
public function __construct( Repository $configRepository )
{
// Inject this command just to have access to writeLine, writeError, etc... methods
$this->manager = new Localization( $this );

parent::__construct();
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeLine( $s )
{
if ( $this->display )
{
parent::line( $s );
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeInfo( $s )
{
if ( $this->display )
{
parent::info( $s );
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeComment( $s )
{
if ( $this->display )
{
parent::comment( $s );
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*
* @codeCoverageIgnore
*/
public function writeQuestion( $s )
{
if ( $this->display )
{
parent::question( $s );
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeError( $s )
{
if ( $this->display )
{
parent::error( $s );
}
}

/**
* Log in a file for debug purpose only
*
* @param mixed $txt
* @param string $logFile
*
* @codeCoverageIgnore
*/
protected function logInFile( $txt = '' , $logFile = '/tmp/llh.log' )
{
if ( ! is_string( $txt ) )
{
$txt = print_r( $txt , true );
}

$txt = '==> ' . date( 'Y/m/d H:i:s' ) . ' ==> ' . $txt . "\n";

if ( self::$logInFileFirst === true )
{
file_put_contents( $logFile , $txt );

self::$logInFileFirst = false;
}
else
{
file_put_contents( $logFile , $txt , FILE_APPEND );
}
}

const SUCCESS = 0;

const ERROR = 1;

/**
* Init log file for first log
*
* @var boolean
*/
protected static $logInFileFirst = true;

/**
* Config repository.
*
* @var \Illuminate\Config\Repository
*/
protected $configRepository;

/**
* The localization manager
*
* @var Localization
*/
protected $manager;

/**
* Should commands display something
*
* @var boolean
*/
protected $display = true;

/**
* Create a new command instance.
*
* @param \Illuminate\Config\Repository $configRepository
*/
public function __construct(Repository $configRepository)
{
// Inject this command just to have access to writeLine, writeError, etc... methods
$this->manager = new Localization($this);

parent::__construct();
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeLine($s)
{
if ($this->display) {
parent::line($s);
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeInfo($s)
{
if ($this->display) {
parent::info($s);
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeComment($s)
{
if ($this->display) {
parent::comment($s);
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*
* @codeCoverageIgnore
*/
public function writeQuestion($s)
{
if ($this->display) {
parent::question($s);
}
}

/**
* Display console message
*
* @param string $s the message to display
*
* @return void
*/
public function writeError($s)
{
if ($this->display) {
parent::error($s);
}
}

/**
* Log in a file for debug purpose only
*
* @param mixed $txt
* @param string $logFile
*
* @codeCoverageIgnore
*/
protected function logInFile($txt = '', $logFile = '/tmp/llh.log')
{
if (! is_string($txt)) {
$txt = print_r($txt, true);
}

$txt = '==> '.date('Y/m/d H:i:s').' ==> '.$txt."\n";

if (self::$logInFileFirst === true) {
file_put_contents($logFile, $txt);

self::$logInFileFirst = false;
} else {
file_put_contents($logFile, $txt, FILE_APPEND);
}
}
}

0 comments on commit 108de2b

Please sign in to comment.