diff --git a/README.md b/README.md index 75aa664..f4279a5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

Laravel-lang

-

75 languages support for Laravel 5 application based on Laravel-Lang/lang. +

75 languages support for Laravel application based on Laravel-Lang/lang.

For Laravel 5 For Lumen 5 Latest Stable Version @@ -7,7 +7,6 @@ Total Downloads License

- # Features - Laravel 5+ && Lumen support. @@ -16,21 +15,17 @@ # Install -```shell -$ composer require "overtrue/laravel-lang:~3.0" -``` - -#### Laravel 5.* - -After completion of the above, Replace the `config/app.php` content - -```php -Illuminate\Translation\TranslationServiceProvider::class, -``` -with: +| Laravel version | Composer command | +| --------------- | --------------------------------------------- | +| Laravel 9.x | `composer require overtrue/laravel-lang:~6.0` | +| Laravel 7.x-8.x | `composer require overtrue/laravel-lang:~5.0` | +| Laravel 6.x | `composer require overtrue/laravel-lang:~4.0` | +| Laravel 5.8 | `composer require overtrue/laravel-lang:~3.0` | +| Laravel 5.1-5.7 | `composer require overtrue/laravel-lang:~2.0` | +| Laravel 5 | `composer require overtrue/laravel-lang:~1.0` | -```php -Overtrue\LaravelLang\TranslationServiceProvider::class, +```shell +$ composer require "overtrue/laravel-lang:~6.0" ``` #### Lumen @@ -44,6 +39,7 @@ $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class); # Configuration ### Laravel + you can change the locale at `config/app.php`: ```php @@ -62,7 +58,7 @@ APP_LOCALE=zh_CN There is no difference with the usual usage. -If you need to add additional language content, Please create a file in the `resources/lang/{LANGUAGE}` directory. +If you need to add additional language content, Please create a file in the `resources/lang/{LANGUAGE}` directory. ### Add custom language items @@ -78,6 +74,7 @@ return [ 'email_has_registed' => '邮箱 :email 已经注册过!', ]; ``` + Used in the template: ```php diff --git a/composer.json b/composer.json index c2c81aa..6c5f5c6 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "overtrue/laravel-lang", - "description": "List of 75 languages for Laravel 4, 5, 6 and 7", + "description": "List of 75 languages for Laravel.", "keywords": [ "laravel", "languages", @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "laravel-lang/lang": "^7.0", + "laravel-lang/lang": "^9.0", "symfony/process": "^5.0.0", "ext-json": "*" }, @@ -39,4 +39,4 @@ "check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php_cs --dry-run --ansi", "fix-style": "php-cs-fixer fix --using-cache=no --config=.php_cs --ansi" } -} +} \ No newline at end of file diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 85c58f9..5bfc99c 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -37,8 +37,7 @@ public function handle() $locale = \str_replace('-', '_', $this->argument('locales')); $force = $this->option('force') ? 'f' : 'n'; - $sourcePath = base_path('vendor/laravel-lang/lang/src'); - $sourceJsonPath = base_path('vendor/laravel-lang/lang/json'); + $sourcePath = base_path('vendor/laravel-lang/lang/locales'); $targetPath = base_path('resources/lang/'); if (!is_dir($targetPath) && !mkdir($targetPath)) { @@ -53,7 +52,6 @@ public function handle() if ('all' == $locale) { $files = [ \addslashes($sourcePath).'/*', - escapeshellarg($sourceJsonPath), ]; $message = 'all'; $copyEnFiles = true; @@ -65,7 +63,7 @@ public function handle() continue; } $file = $sourcePath.'/'.trim($filename); - $jsonFile = $sourceJsonPath.'/'.trim($filename).'.json'; + $jsonFile = $sourcePath.'/'.trim($filename).'.json'; if (!file_exists($file)) { $this->error("'$filename' not found."); diff --git a/src/FileLoader.php b/src/FileLoader.php index c444e8a..6f106bf 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -40,6 +40,8 @@ public function load($locale, $group, $namespace = null) { $defaults = []; + $locale = str_replace('-', '_', $locale); + foreach ($this->paths as $path) { $defaults = array_replace_recursive($defaults, $this->loadPath($path, $locale, $group)); }