From 4ff1b6171ccb6a1c546cba6bd0c9d5e63ccd0da6 Mon Sep 17 00:00:00 2001 From: overtrue Date: Fri, 25 Nov 2016 10:07:02 +0800 Subject: [PATCH 01/67] Update README. --- README.md | 2 +- README_CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d77b0a3..871b07c 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ You need only add the partials item what you want. ### publish the language files to your project `resources/lang/` directory: ```shell -$ php artisan lang:publish LOCALES {--force} +$ php artisan lang:publish [LOCALES] {--force} ``` examples: diff --git a/README_CN.md b/README_CN.md index 1993dc3..0818901 100644 --- a/README_CN.md +++ b/README_CN.md @@ -104,7 +104,7 @@ return [ ### 将翻译文件拷贝到你的项目 `resources/lang/` 目录下: ```shell -$ php artisan lang:publish LOCALES {--force} +$ php artisan lang:publish [LOCALES] {--force} ``` examples: From 4e370df31a556d778d74aa2ec6da11ab3fb8f291 Mon Sep 17 00:00:00 2001 From: Alexander Menk Date: Tue, 14 Feb 2017 11:00:48 +0100 Subject: [PATCH 02/67] Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available (#14) --- src/FileLoader.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/FileLoader.php b/src/FileLoader.php index 240c719..d8959ad 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -53,4 +53,26 @@ public function load($locale, $group, $namespace = null) return array_replace_recursive($defaults, parent::load($locale, $group, $namespace)); } + + /** + * Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available + * + * @param string $path + * @param string $locale + * @param string $group + * @return array|mixed + */ + protected function loadPath($path, $locale, $group) + { + $result = parent::loadPath($path, $locale, $group); + + if ($result == [] && strpos($locale, '-') !== false) { + list($baseLocale) = explode('-', $locale); + if ($this->files->exists($full = "{$path}/{$baseLocale}/{$group}.php")) { + return $this->files->getRequire($full); + } + } + + return $result; + } } From e8ec3e6ca054295bc781791596d104b00b22e505 Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 14 Feb 2017 18:03:00 +0800 Subject: [PATCH 03/67] Simplify. #14 --- src/FileLoader.php | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/FileLoader.php b/src/FileLoader.php index d8959ad..94ad0c6 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -53,24 +53,22 @@ public function load($locale, $group, $namespace = null) return array_replace_recursive($defaults, parent::load($locale, $group, $namespace)); } - - /** + + /** * Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available * * @param string $path * @param string $locale * @param string $group - * @return array|mixed + * + * @return array */ protected function loadPath($path, $locale, $group) { $result = parent::loadPath($path, $locale, $group); - if ($result == [] && strpos($locale, '-') !== false) { - list($baseLocale) = explode('-', $locale); - if ($this->files->exists($full = "{$path}/{$baseLocale}/{$group}.php")) { - return $this->files->getRequire($full); - } + if (empty($result) && str_contains($locale, '-')) { + return parent::loadPath($path, strstr($locale, '-', true), $group); } return $result; From c980eba644dd78f470f186afc1a6327167b02e1f Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 10 May 2017 20:48:58 +0800 Subject: [PATCH 04/67] Update trans function. #16 --- src/helpers.php | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/src/helpers.php b/src/helpers.php index 41a6cb2..9a5986c 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -9,41 +9,37 @@ * with this source code in the file LICENSE. */ -if (!function_exists('trans')) { +if (! function_exists('trans')) { /** * Translate the given message. * - * @param string $id - * @param array $parameters - * @param string $domain - * @param string $locale - * - * @return \Symfony\Component\Translation\TranslatorInterface|string + * @param string $id + * @param array $replace + * @param string $locale + * @return \Illuminate\Contracts\Translation\Translator|string */ - function trans($id = null, $parameters = [], $domain = 'messages', $locale = null) + function trans($id = null, $replace = [], $locale = null) { if (is_null($id)) { return app('translator'); } - return app('translator')->trans($id, $parameters, $domain, $locale); + return app('translator')->trans($id, $replace, $locale); } } -if (!function_exists('trans_choice')) { +if (! function_exists('trans_choice')) { /** * Translates the given message based on a count. * - * @param string $id - * @param int|array|\Countable $number - * @param array $parameters - * @param string $domain - * @param string $locale - * + * @param string $id + * @param int|array|\Countable $number + * @param array $replace + * @param string $locale * @return string */ - function trans_choice($id, $number, array $parameters = [], $domain = 'messages', $locale = null) + function trans_choice($id, $number, array $replace = [], $locale = null) { - return app('translator')->transChoice($id, $number, $parameters, $domain, $locale); + return app('translator')->transChoice($id, $number, $replace, $locale); } -} +} \ No newline at end of file From 82e6eaf1c4cc2dbce5f84c66b6d3001466b9d1ea Mon Sep 17 00:00:00 2001 From: Paul King Date: Sun, 25 Jun 2017 15:08:04 +0800 Subject: [PATCH 05/67] Update README.md (#18) --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 871b07c..286fcb3 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,15 @@ [![Total Downloads][badge_downloads]][link-packagist] [![License][badge_license]][link-packagist] +

+
+  创造不息,交付不止 +
+ + + +

+ # Features - Laravel 5 & Lumen support. @@ -129,4 +138,4 @@ MIT [badge_license]: https://img.shields.io/packagist/l/overtrue/laravel-lang.svg?maxAge=2592000 [link-github-repo]: https://github.com/overtrue/laravel-lang -[link-packagist]: https://packagist.org/packages/overtrue/laravel-lang \ No newline at end of file +[link-packagist]: https://packagist.org/packages/overtrue/laravel-lang From 9641e3115d72db09de23e4fbbddd36333ba86540 Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 3 Jul 2017 06:12:05 +0800 Subject: [PATCH 06/67] Auto discovery. --- composer.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index d4513b1..13e305e 100644 --- a/composer.json +++ b/composer.json @@ -21,5 +21,12 @@ "name": "overtrue", "email": "anzhengchao@gmail.com" } - ] + ], + "extra": { + "laravel": { + "providers": [ + "Overtrue\\LaravelLang\\TranslationServiceProvider" + ] + } + } } From 4428e377a770c7f02773ea8dde84c76eab44493b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 4 Jul 2017 21:11:38 +0800 Subject: [PATCH 07/67] Apply fixes from StyleCI (#20) --- src/FileLoader.php | 2 +- src/helpers.php | 22 ++++++++++++---------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/FileLoader.php b/src/FileLoader.php index 94ad0c6..4eabcc8 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -55,7 +55,7 @@ public function load($locale, $group, $namespace = null) } /** - * Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available + * Fall back to base locale (i.e. de) if a countries specific locale (i.e. de-CH) is not available. * * @param string $path * @param string $locale diff --git a/src/helpers.php b/src/helpers.php index 9a5986c..60ade97 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -9,13 +9,14 @@ * with this source code in the file LICENSE. */ -if (! function_exists('trans')) { +if (!function_exists('trans')) { /** * Translate the given message. * - * @param string $id - * @param array $replace - * @param string $locale + * @param string $id + * @param array $replace + * @param string $locale + * * @return \Illuminate\Contracts\Translation\Translator|string */ function trans($id = null, $replace = [], $locale = null) @@ -28,18 +29,19 @@ function trans($id = null, $replace = [], $locale = null) } } -if (! function_exists('trans_choice')) { +if (!function_exists('trans_choice')) { /** * Translates the given message based on a count. * - * @param string $id - * @param int|array|\Countable $number - * @param array $replace - * @param string $locale + * @param string $id + * @param int|array|\Countable $number + * @param array $replace + * @param string $locale + * * @return string */ function trans_choice($id, $number, array $replace = [], $locale = null) { return app('translator')->transChoice($id, $number, $replace, $locale); } -} \ No newline at end of file +} From 914fc271b5040621daabac49ac422909bae1936f Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 31 Jul 2017 10:22:26 +0800 Subject: [PATCH 08/67] Update README. --- README.md | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 286fcb3..1be374c 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,11 @@ -# Laravel-lang - -52 languages support for Laravel 5 application based on [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). - -[中文说明](README_CN.md) - -[![For Laravel 5][badge_laravel]][link-github-repo] -[![For Lumen 5][badge_lumen]][link-github-repo] -[![Latest Stable Version][badge_stable]][link-packagist] -[![Latest Unstable Version][badge_unstable]][link-packagist] -[![Total Downloads][badge_downloads]][link-packagist] -[![License][badge_license]][link-packagist] +

Laravel-lang

+

52 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

+

For Laravel 5 +For Lumen 5 +Latest Stable Version +Latest Unstable Version +Total Downloads +License


From c1194b30d5b9a91b80ebf7b0fbe78bcede1d6331 Mon Sep 17 00:00:00 2001 From: Amatist_Kurisu Date: Mon, 25 Sep 2017 10:04:22 +0800 Subject: [PATCH 09/67] Update README.md (#21) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1be374c..a13ef86 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

Laravel-lang

-

52 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

+

52 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

For Laravel 5 For Lumen 5 Latest Stable Version From ee334983bbafc1fef56a4c513f329563c60992e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sun, 24 Sep 2017 21:04:35 -0500 Subject: [PATCH 10/67] Apply fixes from StyleCI (#22) --- src/Commands/Publish.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 647ecbb..2e362ed 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -56,6 +56,7 @@ public function handle() if (!file_exists($file)) { $this->error("lang '$filename' not found."); + continue; } From 41e05ea496ccb1fdbd1c948a1751b725b4ac0b42 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 28 Oct 2017 11:58:10 +0800 Subject: [PATCH 11/67] Fixed #24 --- .php_cs | 28 +++++++++++++++------------- src/Commands/Publish.php | 29 +++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 15 deletions(-) diff --git a/.php_cs b/.php_cs index 18254c1..85b2134 100755 --- a/.php_cs +++ b/.php_cs @@ -9,19 +9,21 @@ This source file is subject to the MIT license that is bundled with this source code in the file LICENSE. EOF; -Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header); - -return Symfony\CS\Config\Config::create() - // use default SYMFONY_LEVEL and extra fixers: - ->fixers(array( - 'header_comment', - 'short_array_syntax', - 'ordered_use', - 'php_unit_construct', - 'strict_param', +return PhpCsFixer\Config::create() + ->setRiskyAllowed(true) + ->setRules(array( + '@Symfony' => true, + 'header_comment' => array('header' => $header), + 'array_syntax' => array('syntax' => 'short'), + 'ordered_imports' => true, + 'no_useless_else' => true, + 'no_useless_return' => true, + 'php_unit_construct' => true, + 'php_unit_strict' => true, )) - ->finder( - Symfony\CS\Finder\DefaultFinder::create() - ->in(__DIR__.'/src') + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->in(__DIR__) ) ; \ No newline at end of file diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 647ecbb..8d4966c 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -16,15 +16,30 @@ class Publish extends Command { + /** + * @var string + */ protected $signature = 'lang:publish {locales=all : Comma-separated list of, eg: zh_CN,tk,th} {--force : override existing files.}'; + /** + * @var string + */ protected $description = 'publish language files to resources directory.'; + /** + * @var bool + */ + protected $inLumen = false; + + /** + * Publish constructor. + */ public function __construct() { parent::__construct(); + $this->inLumen = $this->laravel instanceof \Laravel\Lumen\Application; } /** @@ -46,14 +61,20 @@ public function handle() $files = []; $published = []; + $copyEnFiles = false; if ($locale == 'all') { - $files = $sourcePath.'/*'; + $files = [$sourcePath.'/*']; $message = 'all'; + $copyEnFiles = true; } else { foreach (explode(',', $locale) as $filename) { $file = $sourcePath.'/'.trim($filename); + if ($locale === 'en') { + $copyEnFiles = true; + } + if (!file_exists($file)) { $this->error("lang '$filename' not found."); continue; @@ -67,10 +88,14 @@ public function handle() return; } - $files = implode(' ', $files); $message = json_encode($published); } + if ($this->inLumen && $copyEnFiles) { + $files[] = base_path('vendor/laravel/lumen-framework/resources/lang/en'); + } + + $files = implode(' ', $files); $process = new Process("cp -r{$force} $files $targetPath"); $process->run(function ($type, $buffer) { From a9db3df884dde825a9eb724873c5112c468b252d Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 28 Oct 2017 11:58:58 +0800 Subject: [PATCH 12/67] Add .gitignore. --- .gitignore | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d5b2f67 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +*.DS_Store +/vendor +sftp-config.json +/*.php +/.idea +/coverage +/.split +/composer.lock +.php_cs.cache \ No newline at end of file From 25496f97bfa6843f00546914e12ff80a872f3ff7 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 28 Oct 2017 12:00:17 +0800 Subject: [PATCH 13/67] Fixed #24 --- src/Commands/Publish.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 1fa292e..8b4de78 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -69,11 +69,11 @@ public function handle() $copyEnFiles = true; } else { foreach (explode(',', $locale) as $filename) { - $file = $sourcePath.'/'.trim($filename); - if ($locale === 'en') { $copyEnFiles = true; + continue; } + $file = $sourcePath.'/'.trim($filename); if (!file_exists($file)) { $this->error("lang '$filename' not found."); From 04b5caf9422985a74c2876f4e64b45a0837ad0d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sat, 28 Oct 2017 12:00:34 +0800 Subject: [PATCH 14/67] Apply fixes from StyleCI (#25) --- src/Commands/Publish.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 8b4de78..e97c630 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -71,6 +71,7 @@ public function handle() foreach (explode(',', $locale) as $filename) { if ($locale === 'en') { $copyEnFiles = true; + continue; } $file = $sourcePath.'/'.trim($filename); From c49d5f86c2ab2302c06e10d7ebd66a1ac73e0bab Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 28 Oct 2017 19:31:26 +0800 Subject: [PATCH 15/67] Fixed #24 --- src/Commands/Publish.php | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index e97c630..c90e252 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -28,18 +28,12 @@ class Publish extends Command */ protected $description = 'publish language files to resources directory.'; - /** - * @var bool - */ - protected $inLumen = false; - /** * Publish constructor. */ public function __construct() { parent::__construct(); - $this->inLumen = $this->laravel instanceof \Laravel\Lumen\Application; } /** @@ -55,13 +49,14 @@ public function handle() $sourcePath = base_path('vendor/caouecs/laravel-lang/src'); $targetPath = base_path('resources/lang/'); - if (!is_dir($targetPath) || !is_writable($targetPath)) { + if (!is_dir($targetPath) && !mkdir($targetPath)) { return $this->error('The lang path "resources/lang/" does not exist or not writable.'); } $files = []; $published = []; $copyEnFiles = false; + $inLumen = $this->laravel instanceof \Laravel\Lumen\Application; if ($locale == 'all') { $files = [$sourcePath.'/*']; @@ -93,7 +88,7 @@ public function handle() $message = json_encode($published); } - if ($this->inLumen && $copyEnFiles) { + if ($inLumen && $copyEnFiles) { $files[] = base_path('vendor/laravel/lumen-framework/resources/lang/en'); } From c58224944a3fc5586fa62b57bd648d516d310d58 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 1 May 2018 09:13:43 +0800 Subject: [PATCH 16/67] Update README.md --- README.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/README.md b/README.md index a13ef86..64cddc4 100644 --- a/README.md +++ b/README.md @@ -7,14 +7,6 @@ Total Downloads License

-

-
-  创造不息,交付不止 -
- - - -

# Features From 81f852fecf6ef69d7ad4213eb383861f060ddb1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 1 May 2018 09:13:58 +0800 Subject: [PATCH 17/67] Apply fixes from StyleCI (#29) --- src/Commands/Publish.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index c90e252..42ddc34 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -58,13 +58,13 @@ public function handle() $copyEnFiles = false; $inLumen = $this->laravel instanceof \Laravel\Lumen\Application; - if ($locale == 'all') { + if ('all' == $locale) { $files = [$sourcePath.'/*']; $message = 'all'; $copyEnFiles = true; } else { foreach (explode(',', $locale) as $filename) { - if ($locale === 'en') { + if ('en' === $locale) { $copyEnFiles = true; continue; @@ -101,7 +101,7 @@ public function handle() } }); - $type = ($force == 'f') ? 'overwrite' : 'no overwrite'; + $type = ('f' == $force) ? 'overwrite' : 'no overwrite'; $this->info("published languages ({$type}): {$message}."); } From e73aa561e6e9c62d46548a434b3c466dd02bfb2a Mon Sep 17 00:00:00 2001 From: Panda <1017109588@qq.com> Date: Sat, 1 Sep 2018 05:32:43 +0800 Subject: [PATCH 18/67] fix words (#31) fix words --- README_CN.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README_CN.md b/README_CN.md index 0818901..e376c30 100644 --- a/README_CN.md +++ b/README_CN.md @@ -88,7 +88,7 @@ echo trans('demo.email_has_registed', ['email' => 'anzhengchao@gmail.com']); ### 替换掉默认的语言项 -我们假设想替换掉密码重围成功的提示文字为例,创建 `resources/lang/zh-CN/passwords.php`: +我们假设想替换掉密码重置成功的提示文字为例,创建 `resources/lang/zh-CN/passwords.php`: ```php Date: Sat, 1 Sep 2018 03:19:35 +0200 Subject: [PATCH 19/67] also load and publish json translations (#32) * also load and publish json translations * apply StyleCI recommendations --- src/Commands/Publish.php | 14 +++++++++++++- src/TranslationServiceProvider.php | 5 ++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 42ddc34..1f38c5d 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -47,6 +47,7 @@ public function handle() $force = $this->option('force') ? 'f' : 'n'; $sourcePath = base_path('vendor/caouecs/laravel-lang/src'); + $sourceJsonPath = base_path('vendor/caouecs/laravel-lang/json'); $targetPath = base_path('resources/lang/'); if (!is_dir($targetPath) && !mkdir($targetPath)) { @@ -59,7 +60,10 @@ public function handle() $inLumen = $this->laravel instanceof \Laravel\Lumen\Application; if ('all' == $locale) { - $files = [$sourcePath.'/*']; + $files = [ + $sourcePath.'/*', + $jsonSourcePath, + ]; $message = 'all'; $copyEnFiles = true; } else { @@ -70,6 +74,7 @@ public function handle() continue; } $file = $sourcePath.'/'.trim($filename); + $jsonFile = $jsonSourcePath.'/'.trim($filename).'.json'; if (!file_exists($file)) { $this->error("lang '$filename' not found."); @@ -79,6 +84,13 @@ public function handle() $published[] = $filename; $files[] = $file; + + if (!file_exists($jsonFile)) { + $this->error("lang '$filename' not found."); + + continue; + } + $files[] = $jsonFile; } if (empty($files)) { diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index 6a34db9..4170250 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -49,12 +49,15 @@ protected function registerLoader() base_path('vendor/caouecs/laravel-lang/src/'), ]; + $jsonPath = base_path('vendor/caouecs/laravel-lang/json/'); + if ($this->inLumen) { $this->app['path.lang'] = base_path('vendor/laravel/lumen-framework/resources/lang'); array_push($paths, base_path('resources/lang/')); } - return new FileLoader($app['files'], $app['path.lang'], $paths); + return (new FileLoader($app['files'], $app['path.lang'], $paths)) + ->addJsonPath($jsonPath); }); } From f1d9f43ef1737f7e950732d17b8d9ab1fc3e3e29 Mon Sep 17 00:00:00 2001 From: overtrue Date: Sat, 1 Sep 2018 17:02:57 +0800 Subject: [PATCH 20/67] Bugfix #33 --- src/TranslationServiceProvider.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index 4170250..c56d11b 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -56,8 +56,12 @@ protected function registerLoader() array_push($paths, base_path('resources/lang/')); } - return (new FileLoader($app['files'], $app['path.lang'], $paths)) - ->addJsonPath($jsonPath); + + $loader = new FileLoader($app['files'], $app['path.lang'], $paths); + + $loader->addJsonPath($jsonPath); + + return $loader; }); } From dd92b8dfcd3e43bded3d96720076429962283aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Sat, 1 Sep 2018 17:03:24 +0800 Subject: [PATCH 21/67] Apply fixes from StyleCI (#34) --- src/TranslationServiceProvider.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index c56d11b..751b0ad 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -56,7 +56,6 @@ protected function registerLoader() array_push($paths, base_path('resources/lang/')); } - $loader = new FileLoader($app['files'], $app['path.lang'], $paths); $loader->addJsonPath($jsonPath); From ad382bfe500a9dfc8cb75f9130c4114997f25cca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E5=B0=8F=E4=B8=8B?= Date: Mon, 3 Sep 2018 14:29:10 +0800 Subject: [PATCH 22/67] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8F=98=E9=87=8F?= =?UTF-8?q?=E5=90=8D=E4=BD=BF=E7=94=A8=E9=94=99=E8=AF=AF=20(#37)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Publish.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 1f38c5d..d8dd3eb 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -62,7 +62,7 @@ public function handle() if ('all' == $locale) { $files = [ $sourcePath.'/*', - $jsonSourcePath, + $sourceJsonPath, ]; $message = 'all'; $copyEnFiles = true; @@ -74,7 +74,7 @@ public function handle() continue; } $file = $sourcePath.'/'.trim($filename); - $jsonFile = $jsonSourcePath.'/'.trim($filename).'.json'; + $jsonFile = $sourceJsonPath.'/'.trim($filename).'.json'; if (!file_exists($file)) { $this->error("lang '$filename' not found."); From 11d8386a5dee3cfedf4ee7e2da6af0d3b3fe268a Mon Sep 17 00:00:00 2001 From: overtrue Date: Mon, 3 Sep 2018 17:31:08 +0800 Subject: [PATCH 23/67] Fix #38 --- src/TranslationServiceProvider.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index 751b0ad..41e4ad6 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -49,8 +49,6 @@ protected function registerLoader() base_path('vendor/caouecs/laravel-lang/src/'), ]; - $jsonPath = base_path('vendor/caouecs/laravel-lang/json/'); - if ($this->inLumen) { $this->app['path.lang'] = base_path('vendor/laravel/lumen-framework/resources/lang'); array_push($paths, base_path('resources/lang/')); @@ -58,7 +56,9 @@ protected function registerLoader() $loader = new FileLoader($app['files'], $app['path.lang'], $paths); - $loader->addJsonPath($jsonPath); + if (\is_callable([$loader, 'addJsonPath'])) { + $loader->addJsonPath(base_path('vendor/caouecs/laravel-lang/json/')); + } return $loader; }); From 95888a0a9a5b048ba52de57fc01a098f23292b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E6=81=BA=E5=9E=A3?= Date: Sun, 13 Jan 2019 22:37:42 +0800 Subject: [PATCH 24/67] =?UTF-8?q?=E5=B0=86=E6=96=87=E4=BB=B6=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E4=B8=AD=E7=9A=84=E7=A9=BA=E6=A0=BC=E8=BD=AC=E4=B9=89?= =?UTF-8?q?=20(#40)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 将文件路径中的空格转义 将文件路径中的空格转义,避免在文件路径有空格的情况下执行 php artisan lang:publish 命令出现 cp 命令报错 * 纠正 pull request 中的错误 * escape commands. --- src/Commands/Publish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index d8dd3eb..2cb1de3 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -105,7 +105,7 @@ public function handle() } $files = implode(' ', $files); - $process = new Process("cp -r{$force} $files $targetPath"); + $process = new Process(['cp', "-r{$force}", $files, $targetPath]); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { From 9855b89cf9e6ce24587701d2e12052c3bb8093b3 Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 22 Jan 2019 14:22:12 +0800 Subject: [PATCH 25/67] Fixed #41 --- composer.json | 3 ++- src/Commands/Publish.php | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 13e305e..7b32c99 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,8 @@ "overtrue" ], "require": { - "caouecs/laravel-lang": "~3.0" + "caouecs/laravel-lang": "~3.0", + "symfony/process": "^3.0|^4.0" }, "autoload": { "psr-4": { diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 2cb1de3..4e1adae 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -104,8 +104,10 @@ public function handle() $files[] = base_path('vendor/laravel/lumen-framework/resources/lang/en'); } - $files = implode(' ', $files); - $process = new Process(['cp', "-r{$force}", $files, $targetPath]); + $files = implode(' ', \array_map('escapeshellarg', $files)); + $targetPath = escapeshellarg($targetPath); + $command = "cp -r{$force} {$files} {$targetPath}"; + $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { From 555007487344fca450342b0dd19a6ae3bac237e2 Mon Sep 17 00:00:00 2001 From: overtrue Date: Tue, 22 Jan 2019 15:10:12 +0800 Subject: [PATCH 26/67] Fixed #41 --- src/Commands/Publish.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 4e1adae..098dc96 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -61,8 +61,8 @@ public function handle() if ('all' == $locale) { $files = [ - $sourcePath.'/*', - $sourceJsonPath, + \addslashes($sourcePath).'/*', + escapeshellarg($sourceJsonPath), ]; $message = 'all'; $copyEnFiles = true; @@ -83,14 +83,14 @@ public function handle() } $published[] = $filename; - $files[] = $file; + $files[] = escapeshellarg($file); if (!file_exists($jsonFile)) { $this->error("lang '$filename' not found."); continue; } - $files[] = $jsonFile; + $files[] = escapeshellarg($jsonFile); } if (empty($files)) { @@ -101,10 +101,10 @@ public function handle() } if ($inLumen && $copyEnFiles) { - $files[] = base_path('vendor/laravel/lumen-framework/resources/lang/en'); + $files[] = escapeshellarg(base_path('vendor/laravel/lumen-framework/resources/lang/en')); } - $files = implode(' ', \array_map('escapeshellarg', $files)); + $files = implode(' ', $files); $targetPath = escapeshellarg($targetPath); $command = "cp -r{$force} {$files} {$targetPath}"; $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command); From 44917b643ca49d1bbac54f205cd6a51f2e71908f Mon Sep 17 00:00:00 2001 From: Ankur Kumar Date: Sat, 2 Mar 2019 11:11:26 +0530 Subject: [PATCH 27/67] Remove auto discovery (#42) --- composer.json | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/composer.json b/composer.json index 7b32c99..27798ea 100644 --- a/composer.json +++ b/composer.json @@ -22,12 +22,5 @@ "name": "overtrue", "email": "anzhengchao@gmail.com" } - ], - "extra": { - "laravel": { - "providers": [ - "Overtrue\\LaravelLang\\TranslationServiceProvider" - ] - } - } + ] } From 55681ae35a0c9253564a194cab4a862686225430 Mon Sep 17 00:00:00 2001 From: Andeson Ismael <23392311+aicouto@users.noreply.github.com> Date: Thu, 21 Mar 2019 10:26:54 -0300 Subject: [PATCH 28/67] correction of "larval" to "laravel" (#45) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 64cddc4..a6d3bac 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ $ composer require "overtrue/laravel-lang:~3.0" ``` -#### Laraval 5.* +#### Laravel 5.* After completion of the above, Replace the `config/app.php` content From af0d2bd264a33cf6a4e3fef99f3985ead4640732 Mon Sep 17 00:00:00 2001 From: Summer Date: Sat, 6 Apr 2019 07:23:15 +0800 Subject: [PATCH 29/67] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index a6d3bac..2f8603b 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,12 @@ examples: $ php artisan lang:publish zh-CN,zh-HK,th,tk ``` +## PHP 扩展包开发 + +> 想知道如何从零开始构建 PHP 扩展包? +> +> 请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— [《PHP 扩展包实战教程 - 从入门到发布》](https://learnku.com/courses/creating-package) + # License MIT From 16d0438de3e454e01b577a3c24bc10117b74684f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Tue, 16 Apr 2019 21:28:44 +0000 Subject: [PATCH 30/67] Update caouecs/laravel-lang requirement from ~3.0 to ~4.0 Updates the requirements on [caouecs/laravel-lang](https://github.com/caouecs/Laravel-lang) to permit the latest version. - [Release notes](https://github.com/caouecs/Laravel-lang/releases) - [Changelog](https://github.com/caouecs/Laravel-lang/blob/master/changelog.php) - [Commits](https://github.com/caouecs/Laravel-lang/compare/3.0.0...4.0.0) Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 27798ea..c51918d 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ "overtrue" ], "require": { - "caouecs/laravel-lang": "~3.0", + "caouecs/laravel-lang": "~4.0", "symfony/process": "^3.0|^4.0" }, "autoload": { From d4953528c17f40fcb27e4db01bcc1ffdbc288862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Mon, 3 Jun 2019 12:04:10 +0800 Subject: [PATCH 31/67] Create FUNDING.yml --- .github/FUNDING.yml | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..a3be7fa --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,9 @@ +# These are supported funding model platforms + +github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +patreon: overtrue +open_collective: # Replace with a single Open Collective username +ko_fi: # Replace with a single Ko-fi username +tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +custom: # Replace with a single custom sponsorship URL From 008665d85d15db529ff4a7256335274a8613110f Mon Sep 17 00:00:00 2001 From: Bill Li <21023027+lilianjin@users.noreply.github.com> Date: Wed, 4 Sep 2019 18:13:22 +0800 Subject: [PATCH 32/67] Update FileLoader.php --- src/FileLoader.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/FileLoader.php b/src/FileLoader.php index 4eabcc8..6aa67b0 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -11,6 +11,7 @@ namespace Overtrue\LaravelLang; +use Illuminate\Support\Str; use Illuminate\Filesystem\Filesystem; use Illuminate\Translation\FileLoader as LaravelTranslationFileLoader; @@ -67,7 +68,7 @@ protected function loadPath($path, $locale, $group) { $result = parent::loadPath($path, $locale, $group); - if (empty($result) && str_contains($locale, '-')) { + if (empty($result) && Str::contains($locale, '-')) { return parent::loadPath($path, strstr($locale, '-', true), $group); } From 176d3dba3516093a230e21d59f9f1c8ff2202c9d Mon Sep 17 00:00:00 2001 From: Lasse Rafn Date: Sun, 27 Oct 2019 16:50:00 +0000 Subject: [PATCH 33/67] Update README_CN.md Change amount of languages supported --- README_CN.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_CN.md b/README_CN.md index e376c30..7b77dae 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,6 +1,6 @@ # Laravel-lang -Laravel 5 语言包,包含 52 种语言, 基于 [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). +Laravel 5 语言包,包含 68 种语言, 基于 [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). [![For Laravel 5][badge_laravel]][link-github-repo] [![For Lumen 5][badge_lumen]][link-github-repo] From aecdd60b725b973f7f321b968bb1a8150d4b37e9 Mon Sep 17 00:00:00 2001 From: Lasse Rafn Date: Sun, 27 Oct 2019 16:50:05 +0000 Subject: [PATCH 34/67] Update README.md Change amount of languages supported --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2f8603b..05e6770 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

Laravel-lang

-

52 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

+

68 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

For Laravel 5 For Lumen 5 Latest Stable Version From 02b0985e388d369c11d7e64403d5ac9049e94bcb Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 21 Nov 2019 21:24:41 +0000 Subject: [PATCH 35/67] Update symfony/process requirement from ^3.0|^4.0 to ^5.0.0 Updates the requirements on [symfony/process](https://github.com/symfony/process) to permit the latest version. - [Release notes](https://github.com/symfony/process/releases) - [Changelog](https://github.com/symfony/process/blob/master/CHANGELOG.md) - [Commits](https://github.com/symfony/process/commits/v5.0.0) Signed-off-by: dependabot-preview[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c51918d..5cf905b 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ ], "require": { "caouecs/laravel-lang": "~4.0", - "symfony/process": "^3.0|^4.0" + "symfony/process": "^5.0.0" }, "autoload": { "psr-4": { From c066bd5940c3502099fe5a1b27df87a9c1bc58da Mon Sep 17 00:00:00 2001 From: overtrue Date: Fri, 6 Mar 2020 10:37:51 +0800 Subject: [PATCH 36/67] Fixed str_contains. --- composer.json | 3 +++ src/FileLoader.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 13e305e..5f82f97 100644 --- a/composer.json +++ b/composer.json @@ -28,5 +28,8 @@ "Overtrue\\LaravelLang\\TranslationServiceProvider" ] } + }, + "require-dev": { + "laravel/framework": "~7.0" } } diff --git a/src/FileLoader.php b/src/FileLoader.php index 4eabcc8..d7f6a03 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -12,6 +12,7 @@ namespace Overtrue\LaravelLang; use Illuminate\Filesystem\Filesystem; +use Illuminate\Support\Str; use Illuminate\Translation\FileLoader as LaravelTranslationFileLoader; class FileLoader extends LaravelTranslationFileLoader @@ -67,7 +68,7 @@ protected function loadPath($path, $locale, $group) { $result = parent::loadPath($path, $locale, $group); - if (empty($result) && str_contains($locale, '-')) { + if (empty($result) && Str::contains($locale, '-')) { return parent::loadPath($path, strstr($locale, '-', true), $group); } From 5642c8b758415f1d47370c0f091c5a35fe366e62 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 17 Mar 2020 21:13:15 +0000 Subject: [PATCH 37/67] Update caouecs/laravel-lang requirement from ~4.0 to ~6.0 Updates the requirements on [caouecs/laravel-lang](https://github.com/caouecs/Laravel-lang) to permit the latest version. - [Release notes](https://github.com/caouecs/Laravel-lang/releases) - [Commits](https://github.com/caouecs/Laravel-lang/compare/4.0.0...6.0.1) Signed-off-by: dependabot-preview[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c4a7fbb..9f013ad 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "caouecs/laravel-lang": "~4.0", + "caouecs/laravel-lang": "~6.0", "symfony/process": "^5.0.0" }, "autoload": { From 3ee38cf1221100054d55e47d72debfbb7d9a44ff Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Tue, 14 Jul 2020 00:50:55 +0000 Subject: [PATCH 38/67] Update caouecs/laravel-lang requirement from ~6.0 to ~7.0 Updates the requirements on [caouecs/laravel-lang](https://github.com/caouecs/Laravel-lang) to permit the latest version. - [Release notes](https://github.com/caouecs/Laravel-lang/releases) - [Commits](https://github.com/caouecs/Laravel-lang/compare/6.0.0...7.0.0) Signed-off-by: dependabot-preview[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 9f013ad..493e840 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "caouecs/laravel-lang": "~6.0", + "caouecs/laravel-lang": "~7.0", "symfony/process": "^5.0.0" }, "autoload": { From 7db618f2c722bddc99141d35f1a614362be16fce Mon Sep 17 00:00:00 2001 From: Fred Delrieu Date: Tue, 21 Jul 2020 08:16:25 +0200 Subject: [PATCH 39/67] fix: new directories for zh_* languages --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 05e6770..4d2522b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

Laravel-lang

-

68 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

+

75 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

For Laravel 5 For Lumen 5 Latest Stable Version @@ -47,7 +47,7 @@ $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class); you can change the locale at `config/app.php`: ```php -'locale' => 'zh-CN', +'locale' => 'zh_CN', ``` ### Lumen @@ -55,7 +55,7 @@ you can change the locale at `config/app.php`: set locale in `.env` file: ``` -APP_LOCALE=zh-CN +APP_LOCALE=zh_CN ``` # Usage @@ -68,7 +68,7 @@ If you need to add additional language content, Please create a file in the `res Here, for example in Chinese: -`resources/lang/zh-CN/demo.php`: +`resources/lang/zh_CN/demo.php`: ```php 'anzhengchao@gmail.com']); We assume that want to replace the `password.reset` message: -`resources/lang/zh-CN/passwords.php`: +`resources/lang/zh_CN/passwords.php`: ```php Date: Tue, 21 Jul 2020 08:18:37 +0200 Subject: [PATCH 40/67] Update README_CN.md --- README_CN.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README_CN.md b/README_CN.md index 7b77dae..d52b213 100644 --- a/README_CN.md +++ b/README_CN.md @@ -1,6 +1,6 @@ # Laravel-lang -Laravel 5 语言包,包含 68 种语言, 基于 [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). +Laravel 5 语言包,包含 75 种语言, 基于 [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). [![For Laravel 5][badge_laravel]][link-github-repo] [![For Lumen 5][badge_lumen]][link-github-repo] @@ -50,25 +50,25 @@ $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class); 修改项目语言 `config/app.php`: ```php -'locale' => 'zh-CN', +'locale' => 'zh_CN', ``` ### Lumen 在 `.env` 文件中修改语言: ``` -APP_LOCALE=zh-CN +APP_LOCALE=zh_CN ``` # 使用 -和正常使用一样,你如果需要额外添加语言项,请在 `resources/lang/zh-CN/` 下建立你自己的文件即可,也可以建立同样的文件来替换掉默认的语言部分。 +和正常使用一样,你如果需要额外添加语言项,请在 `resources/lang/zh_CN/` 下建立你自己的文件即可,也可以建立同样的文件来替换掉默认的语言部分。 ### 添加自定义语言项 -例如创建文件 `resources/lang/zh-CN/demo.php`: +例如创建文件 `resources/lang/zh_CN/demo.php`: ```php 'anzhengchao@gmail.com']); ### 替换掉默认的语言项 -我们假设想替换掉密码重置成功的提示文字为例,创建 `resources/lang/zh-CN/passwords.php`: +我们假设想替换掉密码重置成功的提示文字为例,创建 `resources/lang/zh_CN/passwords.php`: ```php Date: Tue, 21 Jul 2020 14:36:31 +0800 Subject: [PATCH 41/67] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4d2522b..d1d5acd 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ # Features -- Laravel 5 & Lumen support. +- Laravel 5+ && Lumen support. - Translations Publisher. - Made with 💖. From 21f48d5854ac7c98eb9ee964df2fd67b4638441b Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 2 Sep 2020 12:03:29 +0800 Subject: [PATCH 42/67] Update caouecs/laravel-lang -> Laravel-lang/lang --- .php_cs | 64 +++++++++----- README.md | 12 +-- README_CN.md | 129 ----------------------------- composer.json | 11 ++- src/Commands/Publish.php | 9 -- src/FileLoader.php | 10 +-- src/TranslationServiceProvider.php | 4 +- src/helpers.php | 9 -- 8 files changed, 54 insertions(+), 194 deletions(-) delete mode 100644 README_CN.md diff --git a/.php_cs b/.php_cs index 85b2134..56c5149 100755 --- a/.php_cs +++ b/.php_cs @@ -1,29 +1,49 @@ - -This source file is subject to the MIT license that is bundled -with this source code in the file LICENSE. -EOF; - return PhpCsFixer\Config::create() - ->setRiskyAllowed(true) - ->setRules(array( - '@Symfony' => true, - 'header_comment' => array('header' => $header), - 'array_syntax' => array('syntax' => 'short'), - 'ordered_imports' => true, - 'no_useless_else' => true, - 'no_useless_return' => true, - 'php_unit_construct' => true, - 'php_unit_strict' => true, - )) + ->setRules([ + '@PSR2' => true, + 'binary_operator_spaces' => true, + 'blank_line_after_opening_tag' => true, + 'compact_nullable_typehint' => true, + 'declare_equal_normalize' => true, + 'lowercase_cast' => true, + 'lowercase_static_reference' => true, + 'new_with_braces' => true, + 'no_blank_lines_after_class_opening' => true, + 'no_leading_import_slash' => true, + 'no_whitespace_in_blank_line' => true, + 'no_unused_imports' => true, + 'ordered_class_elements' => [ + 'order' => [ + 'use_trait', + ], + ], + 'ordered_imports' => [ + 'imports_order' => [ + 'class', + 'function', + 'const', + ], + 'sort_algorithm' => 'none', + ], + 'return_type_declaration' => true, + 'short_scalar_cast' => true, + 'single_blank_line_before_namespace' => true, + 'single_trait_insert_per_statement' => true, + 'ternary_operator_spaces' => true, + 'unary_operator_spaces' => true, + 'visibility_required' => [ + 'elements' => [ + 'const', + 'method', + 'property', + ], + ], + ]) ->setFinder( PhpCsFixer\Finder::create() ->exclude('vendor') - ->in(__DIR__) + ->in([__DIR__.'/src/']) ) -; \ No newline at end of file +; diff --git a/README.md b/README.md index d1d5acd..75aa664 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@

Laravel-lang

-

75 languages support for Laravel 5 application based on caouecs/Laravel-lang. 中文说明

+

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

For Laravel 5 For Lumen 5 Latest Stable Version @@ -123,13 +123,3 @@ $ php artisan lang:publish zh_CN,zh_HK,th,tk # License MIT - -[badge_laravel]: https://img.shields.io/badge/laravel-5.*-green.svg -[badge_lumen]: https://img.shields.io/badge/lumen-5.*-green.svg -[badge_stable]: https://img.shields.io/packagist/v/overtrue/laravel-lang.svg -[badge_unstable]: https://img.shields.io/packagist/vpre/overtrue/laravel-lang.svg -[badge_downloads]: https://img.shields.io/packagist/dt/overtrue/laravel-lang.svg?maxAge=2592000 -[badge_license]: https://img.shields.io/packagist/l/overtrue/laravel-lang.svg?maxAge=2592000 - -[link-github-repo]: https://github.com/overtrue/laravel-lang -[link-packagist]: https://packagist.org/packages/overtrue/laravel-lang diff --git a/README_CN.md b/README_CN.md deleted file mode 100644 index d52b213..0000000 --- a/README_CN.md +++ /dev/null @@ -1,129 +0,0 @@ -# Laravel-lang - -Laravel 5 语言包,包含 75 种语言, 基于 [caouecs/Laravel-lang](https://github.com/caouecs/Laravel-lang). - -[![For Laravel 5][badge_laravel]][link-github-repo] -[![For Lumen 5][badge_lumen]][link-github-repo] -[![Latest Stable Version][badge_stable]][link-packagist] -[![Latest Unstable Version][badge_unstable]][link-packagist] -[![Total Downloads][badge_downloads]][link-packagist] -[![License][badge_license]][link-packagist] - -# Features - -- Laravel 5 & Lumen support. -- Translations Publisher. -- Made with 💖. - -# 安装 - -```shell -composer require "overtrue/laravel-lang:~3.0" -``` - -#### Laraval 5.* - -完成上面的操作后,将项目文件 `config/app.php` 中的下一行 - -```php -Illuminate\Translation\TranslationServiceProvider::class, -``` - -替换为: - -```php -Overtrue\LaravelLang\TranslationServiceProvider::class, -``` - -#### Lumen - -在 `bootstrap/app.php` 中添加下面这行: - -```php -$app->register(Overtrue\LaravelLang\TranslationServiceProvider::class); -``` - -# 配置 - -### Laravel - -修改项目语言 `config/app.php`: - -```php -'locale' => 'zh_CN', -``` - -### Lumen - -在 `.env` 文件中修改语言: -``` -APP_LOCALE=zh_CN -``` - - - -# 使用 - -和正常使用一样,你如果需要额外添加语言项,请在 `resources/lang/zh_CN/` 下建立你自己的文件即可,也可以建立同样的文件来替换掉默认的语言部分。 - -### 添加自定义语言项 - -例如创建文件 `resources/lang/zh_CN/demo.php`: - -```php - '用户不存在', - 'email_has_registed' => '邮箱 :email 已经注册过!', -]; -``` -然后在任何地方: - -```php -echo trans('demo.user_not_exists'); // 用户不存在 -echo trans('demo.email_has_registed', ['email' => 'anzhengchao@gmail.com']); -// 邮箱 anzhengchao@gmail.com 已经注册过! -``` - -### 替换掉默认的语言项 - -我们假设想替换掉密码重置成功的提示文字为例,创建 `resources/lang/zh_CN/passwords.php`: - -```php - '您的密码已经重置成功了,你可以使用新的密码登录了!', -]; -``` - -只放置你需要替换的部分即可。 - - -### 将翻译文件拷贝到你的项目 `resources/lang/` 目录下: - -```shell -$ php artisan lang:publish [LOCALES] {--force} -``` - -examples: - -```shell -$ php artisan lang:publish zh_CN,zh_HK,th,tk -``` - -# License - -MIT - - -[badge_laravel]: https://img.shields.io/badge/laravel-5.*-green.svg -[badge_lumen]: https://img.shields.io/badge/lumen-5.*-green.svg -[badge_stable]: https://img.shields.io/packagist/v/overtrue/laravel-lang.svg -[badge_unstable]: https://img.shields.io/packagist/vpre/overtrue/laravel-lang.svg -[badge_downloads]: https://img.shields.io/packagist/dt/overtrue/laravel-lang.svg?maxAge=2592000 -[badge_license]: https://img.shields.io/packagist/l/overtrue/laravel-lang.svg?maxAge=2592000 - -[link-github-repo]: https://github.com/overtrue/laravel-lang -[link-packagist]: https://packagist.org/packages/overtrue/laravel-lang diff --git a/composer.json b/composer.json index 493e840..8f63bbc 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "overtrue/laravel-lang", - "description": "List of 52 languages for Laravel 5", + "description": "List of 75 languages for Laravel 4, 5, 6 and 7", "keywords": [ "laravel", "languages", @@ -9,8 +9,9 @@ "overtrue" ], "require": { - "caouecs/laravel-lang": "~7.0", - "symfony/process": "^5.0.0" + "laravel-lang/lang": "~7.0", + "symfony/process": "^5.0.0", + "ext-json": "*" }, "autoload": { "psr-4": { @@ -34,5 +35,9 @@ }, "require-dev": { "laravel/framework": "~7.0" + }, + "scripts": { + "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" } } diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 098dc96..464bf7e 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace Overtrue\LaravelLang\Commands; use Illuminate\Console\Command; diff --git a/src/FileLoader.php b/src/FileLoader.php index 6aa67b0..c444e8a 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - namespace Overtrue\LaravelLang; use Illuminate\Support\Str; @@ -27,6 +18,7 @@ class FileLoader extends LaravelTranslationFileLoader * * @param \Illuminate\Filesystem\Filesystem $files * @param array $path + * @param array $paths */ public function __construct(Filesystem $files, $path, $paths = []) { diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index 41e4ad6..4073c44 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -46,7 +46,7 @@ protected function registerLoader() { $this->app->singleton('translation.loader', function ($app) { $paths = [ - base_path('vendor/caouecs/laravel-lang/src/'), + base_path('vendor/laravel-lang/lang/src/'), ]; if ($this->inLumen) { @@ -57,7 +57,7 @@ protected function registerLoader() $loader = new FileLoader($app['files'], $app['path.lang'], $paths); if (\is_callable([$loader, 'addJsonPath'])) { - $loader->addJsonPath(base_path('vendor/caouecs/laravel-lang/json/')); + $loader->addJsonPath(base_path('vendor/laravel-lang/lang/json/')); } return $loader; diff --git a/src/helpers.php b/src/helpers.php index 60ade97..4a74183 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -1,14 +1,5 @@ - * - * This source file is subject to the MIT license that is bundled - * with this source code in the file LICENSE. - */ - if (!function_exists('trans')) { /** * Translate the given message. From d93b9e0b7e184701d0ab9ea7f7bed34c804c0ded Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Fri, 11 Sep 2020 18:18:16 +0000 Subject: [PATCH 43/67] Update laravel/framework requirement from ~7.0 to ~8.1 Updates the requirements on [laravel/framework](https://github.com/laravel/framework) to permit the latest version. - [Release notes](https://github.com/laravel/framework/releases) - [Changelog](https://github.com/laravel/framework/blob/8.x/CHANGELOG-7.x.md) - [Commits](https://github.com/laravel/framework/compare/v7.0.0...v8.1.0) Signed-off-by: dependabot-preview[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8f63bbc..1a1324b 100644 --- a/composer.json +++ b/composer.json @@ -34,7 +34,7 @@ } }, "require-dev": { - "laravel/framework": "~7.0" + "laravel/framework": "~8.1" }, "scripts": { "check-style": "php-cs-fixer fix --using-cache=no --diff --config=.php_cs --dry-run --ansi", From 8db02bb782ff3f27198740a7a5f47b8934f949ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 16 Sep 2020 11:00:55 +0800 Subject: [PATCH 44/67] Fixed #62 --- src/Commands/Publish.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 464bf7e..5137a43 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -37,8 +37,8 @@ public function handle() $locale = $this->argument('locales'); $force = $this->option('force') ? 'f' : 'n'; - $sourcePath = base_path('vendor/caouecs/laravel-lang/src'); - $sourceJsonPath = base_path('vendor/caouecs/laravel-lang/json'); + $sourcePath = base_path('vendor/laravel-lang/lang/src'); + $sourceJsonPath = base_path('vendor/laravel-lang/lang/json'); $targetPath = base_path('resources/lang/'); if (!is_dir($targetPath) && !mkdir($targetPath)) { From a2f9e02cba10d145337772d7d31715de0d919aeb Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 12 Nov 2020 09:31:15 +0800 Subject: [PATCH 45/67] Remove helpers. Closed #65 --- composer.json | 5 ++--- src/helpers.php | 38 -------------------------------------- 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 src/helpers.php diff --git a/composer.json b/composer.json index 1a1324b..c2c81aa 100644 --- a/composer.json +++ b/composer.json @@ -9,15 +9,14 @@ "overtrue" ], "require": { - "laravel-lang/lang": "~7.0", + "laravel-lang/lang": "^7.0", "symfony/process": "^5.0.0", "ext-json": "*" }, "autoload": { "psr-4": { "Overtrue\\LaravelLang\\": "src/" - }, - "files": ["src/helpers.php"] + } }, "license": "MIT", "authors": [ diff --git a/src/helpers.php b/src/helpers.php deleted file mode 100644 index 4a74183..0000000 --- a/src/helpers.php +++ /dev/null @@ -1,38 +0,0 @@ -trans($id, $replace, $locale); - } -} - -if (!function_exists('trans_choice')) { - /** - * Translates the given message based on a count. - * - * @param string $id - * @param int|array|\Countable $number - * @param array $replace - * @param string $locale - * - * @return string - */ - function trans_choice($id, $number, array $replace = [], $locale = null) - { - return app('translator')->transChoice($id, $number, $replace, $locale); - } -} From 653189caa6eac682fa5d15482f271489721231c7 Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 12 Nov 2020 09:44:31 +0800 Subject: [PATCH 46/67] ISO 15897 format --- src/Commands/Publish.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 5137a43..85c58f9 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -34,7 +34,7 @@ public function __construct() */ public function handle() { - $locale = $this->argument('locales'); + $locale = \str_replace('-', '_', $this->argument('locales')); $force = $this->option('force') ? 'f' : 'n'; $sourcePath = base_path('vendor/laravel-lang/lang/src'); @@ -68,7 +68,7 @@ public function handle() $jsonFile = $sourceJsonPath.'/'.trim($filename).'.json'; if (!file_exists($file)) { - $this->error("lang '$filename' not found."); + $this->error("'$filename' not found."); continue; } @@ -77,7 +77,7 @@ public function handle() $files[] = escapeshellarg($file); if (!file_exists($jsonFile)) { - $this->error("lang '$filename' not found."); + $this->error("'$filename' not found."); continue; } From ffeaba6fbbd0dcd2afe58304ff287339744a774d Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 28 Apr 2021 11:54:03 +0800 Subject: [PATCH 47/67] 5.x --- src/FileLoader.php | 2 ++ 1 file changed, 2 insertions(+) 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)); } From 30133b4b97a43368949ca48985cd04968d50ba40 Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 28 Apr 2021 11:56:56 +0800 Subject: [PATCH 48/67] require 8.x --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c2c81aa..3270d77 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "laravel-lang/lang": "^7.0", + "laravel-lang/lang": "^8.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 From b0bbd887a7bfb69d4f4d60887ad2b2bd03c77522 Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 28 Apr 2021 12:05:31 +0800 Subject: [PATCH 49/67] 9.x --- README.md | 31 ++++++++++++++----------------- composer.json | 6 +++--- src/Commands/Publish.php | 6 ++---- src/FileLoader.php | 2 ++ 4 files changed, 21 insertions(+), 24 deletions(-) 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)); } From ac84d724691d3ec70d8114ba8a6f52c1cad05910 Mon Sep 17 00:00:00 2001 From: overtrue Date: Wed, 28 Apr 2021 12:06:35 +0800 Subject: [PATCH 50/67] add docs. --- README.md | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 75aa664..5bd4dd5 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Total Downloads License

- # Features - Laravel 5+ && Lumen support. @@ -16,21 +15,16 @@ # 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 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:~5.0" ``` #### Lumen @@ -44,6 +38,7 @@ $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class); # Configuration ### Laravel + you can change the locale at `config/app.php`: ```php @@ -62,7 +57,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 +73,7 @@ return [ 'email_has_registed' => '邮箱 :email 已经注册过!', ]; ``` + Used in the template: ```php From 471d59af70d7e9515986267fb864233afd65c524 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Thu, 29 Apr 2021 19:31:26 +0000 Subject: [PATCH 51/67] Upgrade to GitHub-native Dependabot --- .github/dependabot.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..c67cb49 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +version: 2 +updates: +- package-ecosystem: composer + directory: "/" + schedule: + interval: daily + time: "21:00" + open-pull-requests-limit: 10 + ignore: + - dependency-name: laravel-lang/lang + versions: + - 8.0.0 + - 8.1.0 + - 9.0.0 + - 9.1.0 From 998e60218d547f88dfb92b39eedae31224ea2967 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 2 Jun 2021 21:12:06 +0000 Subject: [PATCH 52/67] Update laravel-lang/lang requirement from ^8.0 to ^10.1 Updates the requirements on [laravel-lang/lang](https://github.com/Laravel-Lang/lang) to permit the latest version. - [Release notes](https://github.com/Laravel-Lang/lang/releases) - [Changelog](https://github.com/Laravel-Lang/lang/blob/master/docs/changelog.md) - [Commits](https://github.com/Laravel-Lang/lang/compare/8.0.0...10.1.0) --- updated-dependencies: - dependency-name: laravel-lang/lang dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3270d77..58a712d 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "laravel-lang/lang": "^8.0", + "laravel-lang/lang": "^10.1", "symfony/process": "^5.0.0", "ext-json": "*" }, From 8aaca30aabfad979c31ed5333c76cde3e26bd4d1 Mon Sep 17 00:00:00 2001 From: suyaqi Date: Fri, 20 Aug 2021 17:39:53 +0800 Subject: [PATCH 53/67] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20laravel-lang/?= =?UTF-8?q?lang:10x=20=E7=89=88=E6=9C=AC=E7=9B=AE=E5=BD=95=E7=BB=93?= =?UTF-8?q?=E6=9E=84=E5=8F=98=E6=9B=B4=E5=AF=BC=E8=87=B4=E7=9A=84=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E7=BF=BB=E8=AF=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Publish.php | 12 ++++---- src/FileLoader.php | 48 ++++++++++++++++++++++++++++++ src/TranslationServiceProvider.php | 4 +-- 3 files changed, 57 insertions(+), 7 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 85c58f9..7b473cd 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -37,8 +37,8 @@ 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'); + $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales'); $targetPath = base_path('resources/lang/'); if (!is_dir($targetPath) && !mkdir($targetPath)) { @@ -53,7 +53,7 @@ public function handle() if ('all' == $locale) { $files = [ \addslashes($sourcePath).'/*', - escapeshellarg($sourceJsonPath), + \addslashes($sourceJsonPath).'/*/*.json', ]; $message = 'all'; $copyEnFiles = true; @@ -64,8 +64,10 @@ public function handle() continue; } - $file = $sourcePath.'/'.trim($filename); - $jsonFile = $sourceJsonPath.'/'.trim($filename).'.json'; + + $trimFilename = trim($filename); + $file = $sourcePath.'/'.$trimFilename; + $jsonFile = $sourceJsonPath."/{$trimFilename}/{$trimFilename}".'.json'; if (!file_exists($file)) { $this->error("'$filename' not found."); diff --git a/src/FileLoader.php b/src/FileLoader.php index 6f106bf..e793e00 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -5,6 +5,7 @@ use Illuminate\Support\Str; use Illuminate\Filesystem\Filesystem; use Illuminate\Translation\FileLoader as LaravelTranslationFileLoader; +use RuntimeException; class FileLoader extends LaravelTranslationFileLoader { @@ -13,6 +14,11 @@ class FileLoader extends LaravelTranslationFileLoader */ protected $paths; + /** + * @var string[] + */ + protected $customJsonPaths = []; + /** * Create a new file loader instance. * @@ -68,4 +74,46 @@ protected function loadPath($path, $locale, $group) return $result; } + + /** + * Add a new JSON path to the loader. + * + * @param string $path + * @return void + */ + public function addJsonPath($path) + { + $this->customJsonPaths[] = $path; + parent::addJsonPath($path); + } + + /** + * Load a locale from the given JSON file path. + * + * @param string $locale + * @return array + * + * @throws RuntimeException + */ + protected function loadJsonPaths($locale) + { + return collect(array_merge($this->jsonPaths, [$this->path])) + ->reduce(function ($output, $path) use ($locale) { + if (in_array($path, $this->customJsonPaths)) { + $locale = "{$locale}/{$locale}"; + } + + if ($this->files->exists($full = "{$path}/{$locale}.json")) { + $decoded = json_decode($this->files->get($full), true); + + if (is_null($decoded) || json_last_error() !== JSON_ERROR_NONE) { + throw new RuntimeException("Translation file [{$full}] contains an invalid JSON structure."); + } + + $output = array_merge($output, $decoded); + } + + return $output; + }, []); + } } diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index 4073c44..bd0f2ed 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -46,7 +46,7 @@ protected function registerLoader() { $this->app->singleton('translation.loader', function ($app) { $paths = [ - base_path('vendor/laravel-lang/lang/src/'), + base_path('vendor/laravel-lang/lang/locales/'), ]; if ($this->inLumen) { @@ -57,7 +57,7 @@ protected function registerLoader() $loader = new FileLoader($app['files'], $app['path.lang'], $paths); if (\is_callable([$loader, 'addJsonPath'])) { - $loader->addJsonPath(base_path('vendor/laravel-lang/lang/json/')); + $loader->addJsonPath(base_path('vendor/laravel-lang/lang/locales/')); } return $loader; From da3b2c34aa5241c9ca7d2efe7deaa48458ff3089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 2 Nov 2021 11:26:38 +0800 Subject: [PATCH 54/67] Update FUNDING.yml --- .github/FUNDING.yml | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index a3be7fa..5ea9ebf 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,9 +1 @@ -# These are supported funding model platforms - -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: overtrue -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -custom: # Replace with a single custom sponsorship URL +github: [overtrue] From bd4ed62569a968a25098daeb373ca981fbcf5847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 3 Nov 2021 19:53:37 +0800 Subject: [PATCH 55/67] Update README.md --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 5bd4dd5..1bd6df2 100644 --- a/README.md +++ b/README.md @@ -110,6 +110,12 @@ examples: $ php artisan lang:publish zh_CN,zh_HK,th,tk ``` +## :heart: Sponsor me + +If you like the work I do and want to support it, [you know what to do :heart:](https://github.com/sponsors/overtrue) + +如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) + ## PHP 扩展包开发 > 想知道如何从零开始构建 PHP 扩展包? From 58929511da635c06982235fee7d72056a1383be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Thu, 18 Nov 2021 12:52:47 +0800 Subject: [PATCH 56/67] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1bd6df2..49319db 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,8 @@ - Translations Publisher. - Made with 💖. +[![Sponsor me](https://raw.githubusercontent.com/overtrue/overtrue/master/sponsor-me-button-s.svg)](https://github.com/sponsors/overtrue) + # Install | Laravel version | Composer command | @@ -112,7 +114,7 @@ $ php artisan lang:publish zh_CN,zh_HK,th,tk ## :heart: Sponsor me -If you like the work I do and want to support it, [you know what to do :heart:](https://github.com/sponsors/overtrue) +[![Sponsor me](https://raw.githubusercontent.com/overtrue/overtrue/master/sponsor-me.svg)](https://github.com/sponsors/overtrue) 如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) From 7a2e728f147293befe273fe041e584d5cee47eaf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Tue, 23 Nov 2021 09:59:53 +0800 Subject: [PATCH 57/67] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 49319db..c4ca242 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,13 @@ $ php artisan lang:publish zh_CN,zh_HK,th,tk 如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) + +## Project supported by JetBrains + +Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects. + +[![](https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.svg)](https://www.jetbrains.com/?from=https://github.com/overtrue) + ## PHP 扩展包开发 > 想知道如何从零开始构建 PHP 扩展包? From 9afd6b3f99e34583927df95ff01782ab592d942c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 1 Dec 2021 00:05:56 +0800 Subject: [PATCH 58/67] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c4ca242..5ec3297 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ - Translations Publisher. - Made with 💖. -[![Sponsor me](https://raw.githubusercontent.com/overtrue/overtrue/master/sponsor-me-button-s.svg)](https://github.com/sponsors/overtrue) +[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me-button-s.svg?raw=true)](https://github.com/sponsors/overtrue) # Install @@ -114,7 +114,7 @@ $ php artisan lang:publish zh_CN,zh_HK,th,tk ## :heart: Sponsor me -[![Sponsor me](https://raw.githubusercontent.com/overtrue/overtrue/master/sponsor-me.svg)](https://github.com/sponsors/overtrue) +[![Sponsor me](https://github.com/overtrue/overtrue/blob/master/sponsor-me.svg?raw=true)](https://github.com/sponsors/overtrue) 如果你喜欢我的项目并想支持它,[点击这里 :heart:](https://github.com/sponsors/overtrue) From 1328ff64ab6dcde8d280be0f8344bf760f9515cb Mon Sep 17 00:00:00 2001 From: overtrue Date: Thu, 10 Feb 2022 15:16:41 +0800 Subject: [PATCH 59/67] Laravel 9 --- .php_cs | 49 --------------------------- README.md | 8 ++--- composer.json | 94 ++++++++++++++++++++++++++++++--------------------- 3 files changed, 59 insertions(+), 92 deletions(-) delete mode 100755 .php_cs diff --git a/.php_cs b/.php_cs deleted file mode 100755 index 56c5149..0000000 --- a/.php_cs +++ /dev/null @@ -1,49 +0,0 @@ -setRules([ - '@PSR2' => true, - 'binary_operator_spaces' => true, - 'blank_line_after_opening_tag' => true, - 'compact_nullable_typehint' => true, - 'declare_equal_normalize' => true, - 'lowercase_cast' => true, - 'lowercase_static_reference' => true, - 'new_with_braces' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_leading_import_slash' => true, - 'no_whitespace_in_blank_line' => true, - 'no_unused_imports' => true, - 'ordered_class_elements' => [ - 'order' => [ - 'use_trait', - ], - ], - 'ordered_imports' => [ - 'imports_order' => [ - 'class', - 'function', - 'const', - ], - 'sort_algorithm' => 'none', - ], - 'return_type_declaration' => true, - 'short_scalar_cast' => true, - 'single_blank_line_before_namespace' => true, - 'single_trait_insert_per_statement' => true, - 'ternary_operator_spaces' => true, - 'unary_operator_spaces' => true, - 'visibility_required' => [ - 'elements' => [ - 'const', - 'method', - 'property', - ], - ], - ]) - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('vendor') - ->in([__DIR__.'/src/']) - ) -; diff --git a/README.md b/README.md index f4279a5..bb59719 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ | Laravel 5 | `composer require overtrue/laravel-lang:~1.0` | ```shell -$ composer require "overtrue/laravel-lang:~6.0" +composer require "overtrue/laravel-lang:~6.0" ``` #### Lumen @@ -99,16 +99,16 @@ return [ You need only add the partials item what you want. -### publish the language files to your project `resources/lang/` directory: +### publish the language files to your project `resources/lang/` directory ```shell -$ php artisan lang:publish [LOCALES] {--force} +php artisan lang:publish [LOCALES] {--force} ``` examples: ```shell -$ php artisan lang:publish zh_CN,zh_HK,th,tk +php artisan lang:publish zh_CN,zh_HK,th,tk ``` ## PHP 扩展包开发 diff --git a/composer.json b/composer.json index 6c5f5c6..3a65861 100644 --- a/composer.json +++ b/composer.json @@ -1,42 +1,58 @@ { - "name": "overtrue/laravel-lang", - "description": "List of 75 languages for Laravel.", - "keywords": [ - "laravel", - "languages", - "i18n", - "locale", - "overtrue" + "name": "overtrue/laravel-lang", + "description": "List of 75 languages for Laravel.", + "keywords": [ + "laravel", + "languages", + "i18n", + "locale", + "overtrue" + ], + "require": { + "laravel-lang/lang": "^9.0", + "symfony/process": "^6.0", + "ext-json": "*" + }, + "autoload": { + "psr-4": { + "Overtrue\\LaravelLang\\": "src/" + } + }, + "license": "MIT", + "authors": [ + { + "name": "overtrue", + "email": "anzhengchao@gmail.com" + } + ], + "extra": { + "laravel": { + "providers": [ + "Overtrue\\LaravelLang\\TranslationServiceProvider" + ] + } + }, + "require-dev": { + "laravel/framework": "^9.0" + }, + "scripts": { + "post-update-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" ], - "require": { - "laravel-lang/lang": "^9.0", - "symfony/process": "^5.0.0", - "ext-json": "*" - }, - "autoload": { - "psr-4": { - "Overtrue\\LaravelLang\\": "src/" - } - }, - "license": "MIT", - "authors": [ - { - "name": "overtrue", - "email": "anzhengchao@gmail.com" - } + "post-merge": "composer install", + "post-install-cmd": [ + "cghooks remove", + "cghooks add --ignore-lock", + "cghooks update" ], - "extra": { - "laravel": { - "providers": [ - "Overtrue\\LaravelLang\\TranslationServiceProvider" - ] - } - }, - "require-dev": { - "laravel/framework": "~8.1" - }, - "scripts": { - "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 + "cghooks": "vendor/bin/cghooks", + "check-style": "php-cs-fixer fix --using-cache=no --diff --dry-run --ansi", + "fix-style": "php-cs-fixer fix --using-cache=no --ansi" + }, + "scripts-descriptions": { + "check-style": "Run style checks (only dry run - no fixing!).", + "fix-style": "Run style checks and fix violations." + } +} From 264dfec24bf7afad01a11e05dca3d713cd651f30 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 21 Feb 2022 08:56:53 +0000 Subject: [PATCH 60/67] Update laravel-lang/lang requirement from ^9.0 to ^10.4 Updates the requirements on [laravel-lang/lang](https://github.com/Laravel-Lang/lang) to permit the latest version. - [Release notes](https://github.com/Laravel-Lang/lang/releases) - [Commits](https://github.com/Laravel-Lang/lang/compare/9.0.0...10.4.6) --- updated-dependencies: - dependency-name: laravel-lang/lang dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 3a65861..c63efee 100644 --- a/composer.json +++ b/composer.json @@ -9,7 +9,7 @@ "overtrue" ], "require": { - "laravel-lang/lang": "^9.0", + "laravel-lang/lang": "^10.4", "symfony/process": "^6.0", "ext-json": "*" }, From 103fd38911096addd6e49bebb40ee72b3c291df8 Mon Sep 17 00:00:00 2001 From: karlfzwang Date: Wed, 2 Mar 2022 18:15:31 +0800 Subject: [PATCH 61/67] =?UTF-8?q?=E4=BF=AE=E6=94=B9targetPath=E4=B8=BALara?= =?UTF-8?q?vel=209=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84=20&&=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Publish.php | 11 ++++++----- src/FileLoader.php | 8 ++++---- src/TranslationServiceProvider.php | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 7b473cd..18c5ae5 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -30,7 +30,7 @@ public function __construct() /** * Execute the console command. * - * @return mixed + * @return void */ public function handle() { @@ -39,10 +39,11 @@ public function handle() $sourcePath = base_path('vendor/laravel-lang/lang/locales'); $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales'); - $targetPath = base_path('resources/lang/'); + $targetPath = base_path('lang'); if (!is_dir($targetPath) && !mkdir($targetPath)) { - return $this->error('The lang path "resources/lang/" does not exist or not writable.'); + $this->error('The lang path "lang" does not exist or not writable.'); + return; } $files = []; @@ -100,11 +101,11 @@ public function handle() $files = implode(' ', $files); $targetPath = escapeshellarg($targetPath); $command = "cp -r{$force} {$files} {$targetPath}"; - $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process($command); + $process = \method_exists(Process::class, 'fromShellCommandline') ? Process::fromShellCommandline($command) : new Process([$command]); $process->run(function ($type, $buffer) { if (Process::ERR === $type) { - return $this->error(trim($buffer)); + $this->error(trim($buffer)); } }); diff --git a/src/FileLoader.php b/src/FileLoader.php index 1da926c..9f8f415 100644 --- a/src/FileLoader.php +++ b/src/FileLoader.php @@ -23,10 +23,10 @@ class FileLoader extends LaravelTranslationFileLoader * Create a new file loader instance. * * @param \Illuminate\Filesystem\Filesystem $files - * @param array $path - * @param array $paths + * @param string $path + * @param array $paths */ - public function __construct(Filesystem $files, $path, $paths = []) + public function __construct(Filesystem $files, string $path, array $paths = []) { $this->paths = $paths; @@ -64,7 +64,7 @@ public function load($locale, $group, $namespace = null) * * @return array */ - protected function loadPath($path, $locale, $group) + protected function loadPath($path, $locale, $group): array { $result = parent::loadPath($path, $locale, $group); diff --git a/src/TranslationServiceProvider.php b/src/TranslationServiceProvider.php index bd0f2ed..fc0d5cb 100644 --- a/src/TranslationServiceProvider.php +++ b/src/TranslationServiceProvider.php @@ -51,7 +51,7 @@ protected function registerLoader() if ($this->inLumen) { $this->app['path.lang'] = base_path('vendor/laravel/lumen-framework/resources/lang'); - array_push($paths, base_path('resources/lang/')); + $paths[] = base_path('lang'); } $loader = new FileLoader($app['files'], $app['path.lang'], $paths); @@ -77,7 +77,7 @@ protected function registerCommands() * * @return array */ - public function provides() + public function provides(): array { return array_merge(parent::provides(), [PublishCommand::class]); } From 1053865d8663168910fbf86cb6da9b1e35a91408 Mon Sep 17 00:00:00 2001 From: Tall <75692074@qq.com> Date: Sat, 18 Jun 2022 13:38:15 +0800 Subject: [PATCH 62/67] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20Laravel9=20=E4=BB=A5?= =?UTF-8?q?=E4=B8=8B=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Publish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 18c5ae5..652ba83 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -39,7 +39,7 @@ public function handle() $sourcePath = base_path('vendor/laravel-lang/lang/locales'); $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales'); - $targetPath = base_path('lang'); + $targetPath = lang_path(); if (!is_dir($targetPath) && !mkdir($targetPath)) { $this->error('The lang path "lang" does not exist or not writable.'); From 4bfc71e2bedc87400c343dd8353c6aae3c0edb7d Mon Sep 17 00:00:00 2001 From: Max Sky Date: Fri, 1 Jul 2022 23:26:06 +0800 Subject: [PATCH 63/67] =?UTF-8?q?=E5=85=BC=E5=AE=B9=20Lumen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Commands/Publish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 652ba83..18c5ae5 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -39,7 +39,7 @@ public function handle() $sourcePath = base_path('vendor/laravel-lang/lang/locales'); $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales'); - $targetPath = lang_path(); + $targetPath = base_path('lang'); if (!is_dir($targetPath) && !mkdir($targetPath)) { $this->error('The lang path "lang" does not exist or not writable.'); From 5de693b3cdc3a1a4b914fc02b04563ad42fb7790 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Mon, 4 Jul 2022 22:03:11 +0800 Subject: [PATCH 64/67] Update Publish.php --- src/Commands/Publish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Commands/Publish.php b/src/Commands/Publish.php index 18c5ae5..e9be64c 100644 --- a/src/Commands/Publish.php +++ b/src/Commands/Publish.php @@ -39,7 +39,7 @@ public function handle() $sourcePath = base_path('vendor/laravel-lang/lang/locales'); $sourceJsonPath = base_path('vendor/laravel-lang/lang/locales'); - $targetPath = base_path('lang'); + $targetPath = function_exists('lang_path') ? lang_path() : base_path('lang'); if (!is_dir($targetPath) && !mkdir($targetPath)) { $this->error('The lang path "lang" does not exist or not writable.'); From 3f47052f315e93619da4ea8098e59f19729edf37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Mon, 4 Jul 2022 22:04:42 +0800 Subject: [PATCH 65/67] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 237a6ed..d7d0762 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@

Laravel-lang

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

For Laravel 5 -For Lumen 5 +

For Laravel 5 +For Lumen 5 Latest Stable Version Latest Unstable Version Total Downloads From 4672b969263d92c316a6941c470d1b948957b5f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 27 Jul 2022 07:10:36 +0800 Subject: [PATCH 66/67] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d7d0762..e4b696b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,10 @@ Total Downloads License

+> **Warning** +> +> In order not to duplicate the wheel, there is already a better solution to use [our official Laravel-Lang publisher](https://publisher.laravel-lang.com/). This library will be discontinued, thank you for your support. + # Features - Laravel 5+ && Lumen support. From ded49155630276dda3d6e459e767493a7467d3d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 27 Jul 2022 07:10:59 +0800 Subject: [PATCH 67/67] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4b696b..318dbac 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ > **Warning** > -> In order not to duplicate the wheel, there is already a better solution to use [our official Laravel-Lang publisher](https://publisher.laravel-lang.com/). This library will be discontinued, thank you for your support. +> There is already a better solution to use [our official Laravel-Lang publisher](https://publisher.laravel-lang.com/). This project will be discontinued, thank you for your support. # Features