Skip to content

Commit

Permalink
Merge pull request #31 from ARCANEDEV/update-package
Browse files Browse the repository at this point in the history
Updating the package
  • Loading branch information
arcanedev-maroc committed Oct 3, 2019
2 parents dd0acb1 + 5b33b60 commit 66994d5
Show file tree
Hide file tree
Showing 15 changed files with 148 additions and 178 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

*By [ARCANEDEV©](http://www.arcanedev.net/)*

Translations manager and checker for Laravel v5 based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations.
Translations manager and checker for Laravel based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations.

Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelLang/releases), [license](LICENSE.md), and [contribution guidelines](CONTRIBUTING.md).

Expand All @@ -21,7 +21,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/LaravelLang/r
* Easy setup & configuration.
* Missing translations Checker.
* Translations Publisher.
* Laravel `5.0` to `6.0` are supported.
* Laravel `5.x | 6.x` are supported.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Made with :heart: & :coffee:.
Expand Down Expand Up @@ -50,7 +50,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.
- [All Contributors][link-contributors]

[badge_license]: https://img.shields.io/packagist/l/arcanedev/laravel-lang.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-From%205.0%20to%206.0-orange.svg?style=flat-square
[badge_laravel]: https://img.shields.io/badge/Laravel-From%205.x%20|%206.x-orange.svg?style=flat-square
[badge_build]: https://img.shields.io/travis/ARCANEDEV/LaravelLang.svg?style=flat-square
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/LaravelLang.svg?style=flat-square
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/LaravelLang.svg?style=flat-square
Expand Down
4 changes: 2 additions & 2 deletions _docs/0-Home.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# LaravelLang

Translations manager and checker for Laravel 5 based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations.
Translations manager and checker for Laravel based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang) translations.

### Features

* Easy setup & configuration.
* Missing translations Checker.
* Translations Publisher.
* Laravel `5.0` to `6.0` are supported.
* Laravel `5.0 | 6.x` are supported.
* Well documented & IDE Friendly.
* Well tested with maximum code quality.
* Made with :heart: & :coffee:.
Expand Down
20 changes: 10 additions & 10 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
| ![LaravelLang v4.x][laravel_lang_4_x] | ![Laravel v5.6][laravel_5_6] |
| ![LaravelLang v5.x][laravel_lang_5_x] | ![Laravel v5.7][laravel_5_7] |
| ![LaravelLang v6.x][laravel_lang_6_x] | ![Laravel v5.8][laravel_5_8] |
| ![LaravelLang v7.x][laravel_lang_7_x] | ![Laravel v6.0][laravel_6_0] |
| ![LaravelLang v7.x][laravel_lang_7_x] | ![Laravel v6.x][laravel_6_x] |

[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
Expand All @@ -27,15 +27,15 @@
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"
[laravel_6_0]: https://img.shields.io/badge/v6.0-supported-brightgreen.svg?style=flat-square "Laravel v6.0"

[laravel_lang_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "LaravelLang v1.*"
[laravel_lang_2_x]: https://img.shields.io/badge/version-2.*-blue.svg?style=flat-square "LaravelLang v2.*"
[laravel_lang_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "LaravelLang v3.*"
[laravel_lang_4_x]: https://img.shields.io/badge/version-4.*-blue.svg?style=flat-square "LaravelLang v4.*"
[laravel_lang_5_x]: https://img.shields.io/badge/version-5.*-blue.svg?style=flat-square "LaravelLang v5.*"
[laravel_lang_6_x]: https://img.shields.io/badge/version-6.*-blue.svg?style=flat-square "LaravelLang v6.*"
[laravel_lang_7_x]: https://img.shields.io/badge/version-7.*-blue.svg?style=flat-square "LaravelLang v7.*"
[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.x"

[laravel_lang_1_x]: https://img.shields.io/badge/version-1.x-blue.svg?style=flat-square "LaravelLang v1.x"
[laravel_lang_2_x]: https://img.shields.io/badge/version-2.x-blue.svg?style=flat-square "LaravelLang v2.x"
[laravel_lang_3_x]: https://img.shields.io/badge/version-3.x-blue.svg?style=flat-square "LaravelLang v3.x"
[laravel_lang_4_x]: https://img.shields.io/badge/version-4.x-blue.svg?style=flat-square "LaravelLang v4.x"
[laravel_lang_5_x]: https://img.shields.io/badge/version-5.x-blue.svg?style=flat-square "LaravelLang v5.x"
[laravel_lang_6_x]: https://img.shields.io/badge/version-6.x-blue.svg?style=flat-square "LaravelLang v6.x"
[laravel_lang_7_x]: https://img.shields.io/badge/version-7.x-blue.svg?style=flat-square "LaravelLang v7.x"

## Composer

Expand Down
2 changes: 1 addition & 1 deletion _docs/2-Configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ return [
*/

/** @link https://github.com/caouecs/Laravel-lang */
'vendor' => base_path('vendor/caouecs/laravel4-lang'),
'vendor' => base_path('vendor/caouecs/laravel-lang/src'),

/* -----------------------------------------------------------------
| Supported locales
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
"license": "MIT",
"require": {
"php": ">=7.2.0",
"arcanedev/support": "~5.0.0",
"caouecs/laravel-lang": "~4.0"
"arcanedev/support": "^5.0",
"caouecs/laravel-lang": "^4.0"
},
"require-dev": {
"orchestra/testbench": "~4.0.0",
"phpunit/phpcov": "~6.0",
"phpunit/phpunit": "~8.0",
"mockery/mockery": "~1.2"
"orchestra/testbench": "^4.0",
"phpunit/phpcov": "^6.0",
"phpunit/phpunit": "^8.0",
"mockery/mockery": "^1.2"
},
"autoload": {
"psr-4": {
Expand Down
3 changes: 1 addition & 2 deletions src/Entities/Locale.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
<?php namespace Arcanedev\LaravelLang\Entities;

use Arcanedev\LaravelLang\Contracts\Entities\Locale as LocaleContract;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Support\{Arr, Str};

/**
* Class Locale
Expand Down
2 changes: 1 addition & 1 deletion src/LaravelLang.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ class LaravelLang
| -----------------------------------------------------------------
*/

const VERSION = '6.0.0';
const VERSION = '7.1.0';
}
94 changes: 9 additions & 85 deletions src/LaravelLangServiceProvider.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php namespace Arcanedev\LaravelLang;

use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
use Illuminate\Foundation\Application;
use Arcanedev\Support\Providers\PackageServiceProvider as ServiceProvider;

/**
* Class LaravelLangServiceProvider
Expand Down Expand Up @@ -31,101 +30,26 @@ class LaravelLangServiceProvider extends ServiceProvider
/**
* Register the service provider.
*/
public function register()
public function register(): void
{
parent::register();

$this->registerConfig();
$this->registerTransManager();
$this->registerTransChecker();
$this->registerLangPublisher();

$this->app->registerDeferredProvider(Providers\DeferredServiceProvider::class);
$this->registerProvider(Providers\TranslationServiceProvider::class);
$this->registerConsoleServiceProvider(Providers\CommandServiceProvider::class);

$this->registerCommands([
Commands\CheckCommand::class,
Commands\PublishCommand::class,
]);
}

/**
* Boot the service provider.
*/
public function boot()
public function boot(): void
{
parent::boot();

$this->publishConfig();
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [
Contracts\TransManager::class,
Contracts\TransChecker::class,
Contracts\TransPublisher::class,
];
}

/* -----------------------------------------------------------------
| Services
| -----------------------------------------------------------------
*/

/**
* Register the trans manager.
*/
private function registerTransManager()
{
$this->singleton(Contracts\TransManager::class, function (Application $app) {
/**
* @var \Illuminate\Filesystem\Filesystem $files
* @var \Illuminate\Contracts\Config\Repository $config
*/
$files = $app['files'];
$config = $app['config'];

return new TransManager($files, array_map('realpath', [
'app' => $app->langPath(),
'vendor' => $config->get('laravel-lang.vendor', ''),
]));
});
}

/**
* Register the trans checker.
*/
private function registerTransChecker()
{
$this->singleton(Contracts\TransChecker::class, function (Application $app) {
/**
* @var \Illuminate\Translation\Translator $translator
* @var \Arcanedev\LaravelLang\Contracts\TransManager $manager
* @var \Illuminate\Contracts\Config\Repository $config
*/
$translator = $app['translator'];
$manager = $app[Contracts\TransManager::class];
$config = $app['config'];

return new TransChecker($translator, $manager, $config->get('laravel-lang', []));
});
}

/**
* Register the lang publisher.
*/
private function registerLangPublisher()
{
$this->singleton(Contracts\TransPublisher::class, function (Application $app) {
/**
* @var \Illuminate\Filesystem\Filesystem $files
* @var \Arcanedev\LaravelLang\Contracts\TransManager $manager
*/
$files = $app['files'];
$manager = $app[Contracts\TransManager::class];

return new TransPublisher($files, $manager, $app->langPath());
});
}
}
28 changes: 0 additions & 28 deletions src/Providers/CommandServiceProvider.php

This file was deleted.

92 changes: 92 additions & 0 deletions src/Providers/DeferredServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
<?php namespace Arcanedev\LaravelLang\Providers;

use Arcanedev\LaravelLang\{Contracts, TransChecker, TransManager, TransPublisher};
use Arcanedev\Support\Providers\ServiceProvider;
use Illuminate\Contracts\Support\DeferrableProvider;
use Illuminate\Foundation\Application;

/**
* Class DeferredServiceProvider
*
* @package Arcanedev\LaravelLang\Providers
* @author ARCANEDEV <[email protected]>
*/
class DeferredServiceProvider extends ServiceProvider implements DeferrableProvider
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Register any application services.
*/
public function register(): void
{
$this->registerTransManager();
$this->registerTransChecker();
$this->registerLangPublisher();
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(): array
{
return [
Contracts\TransManager::class,
Contracts\TransChecker::class,
Contracts\TransPublisher::class,
];
}

/* -----------------------------------------------------------------
| Services
| -----------------------------------------------------------------
*/

/**
* Register the trans manager.
*/
private function registerTransManager()
{
$this->singleton(Contracts\TransManager::class, function (Application $app) {
$paths = array_map('realpath', [
'app' => $app->langPath(),
'vendor' => $app['config']->get('laravel-lang.vendor', ''),
]);

return new TransManager($app['files'], $paths);
});
}

/**
* Register the trans checker.
*/
private function registerTransChecker()
{
$this->singleton(Contracts\TransChecker::class, function (Application $app) {
return new TransChecker(
$app['translator'],
$app[Contracts\TransManager::class],
$app['config']->get('laravel-lang', [])
);
});
}

/**
* Register the lang publisher.
*/
private function registerLangPublisher()
{
$this->singleton(Contracts\TransPublisher::class, function (Application $app) {
return new TransPublisher(
$app['files'],
$app[Contracts\TransManager::class],
$app->langPath()
);
});
}
}
14 changes: 5 additions & 9 deletions src/Providers/TranslationServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,13 @@ class TranslationServiceProvider extends ServiceProvider
protected function registerLoader()
{
$this->app->singleton('translation.loader', function(Application $app) {
/**
* @var \Illuminate\Config\Repository $config
* @var \Illuminate\Filesystem\Filesystem $files
*/
$config = $app['config'];
$files = $app['files'];
$vendor = $config->get('laravel-lang.vendor', '');
$locales = $config->get('laravel-lang.locales', []);
$config = $app['config'];

return new FileLoader(
$files, $app->langPath(), $vendor, $locales
$app['files'],
$app->langPath(),
$config->get('laravel-lang.vendor', ''),
$config->get('laravel-lang.locales', [])
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/TransChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TransChecker implements TransCheckerInterface
*
* @var array
*/
private $missing = [];
private $missing = [];

/* -----------------------------------------------------------------
| Constructor
Expand Down
Loading

0 comments on commit 66994d5

Please sign in to comment.