Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

Commit

Permalink
9.x
Browse files Browse the repository at this point in the history
  • Loading branch information
overtrue committed Apr 28, 2021
1 parent 653189c commit b0bbd88
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 24 deletions.
31 changes: 14 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
<h1 align="center">Laravel-lang</h1>
<p align="center">75 languages support for Laravel 5 application based on <a href="https://github.com/Laravel-Lang/lang">Laravel-Lang/lang</a>.
<p align="center">75 languages support for Laravel application based on <a href="https://github.com/Laravel-Lang/lang">Laravel-Lang/lang</a>.
<p align="center"><a href="https://github.com/overtrue/laravel-lang"><img alt="For Laravel 5" src="https://img.shields.io/badge/laravel-5.*-green.svg" style="max-width:100%;"></a>
<a href="https://github.com/overtrue/laravel-lang"><img alt="For Lumen 5" src="https://img.shields.io/badge/lumen-5.*-green.svg" style="max-width:100%;"></a>
<a href="https://packagist.org/packages/overtrue/laravel-lang"><img alt="Latest Stable Version" src="https://img.shields.io/packagist/v/overtrue/laravel-lang.svg" style="max-width:100%;"></a>
<a href="https://packagist.org/packages/overtrue/laravel-lang"><img alt="Latest Unstable Version" src="https://img.shields.io/packagist/vpre/overtrue/laravel-lang.svg" style="max-width:100%;"></a>
<a href="https://packagist.org/packages/overtrue/laravel-lang"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/overtrue/laravel-lang.svg?maxAge=2592000" style="max-width:100%;"></a>
<a href="https://packagist.org/packages/overtrue/laravel-lang"><img alt="License" src="https://img.shields.io/packagist/l/overtrue/laravel-lang.svg?maxAge=2592000" style="max-width:100%;"></a></p>


# Features

- Laravel 5+ && Lumen support.
Expand All @@ -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
Expand All @@ -44,6 +39,7 @@ $app->register(Overtrue\LaravelLang\TranslationServiceProvider::class);
# Configuration

### Laravel

you can change the locale at `config/app.php`:

```php
Expand All @@ -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

Expand All @@ -78,6 +74,7 @@ return [
'email_has_registed' => '邮箱 :email 已经注册过!',
];
```

Used in the template:

```php
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -9,7 +9,7 @@
"overtrue"
],
"require": {
"laravel-lang/lang": "^7.0",
"laravel-lang/lang": "^9.0",
"symfony/process": "^5.0.0",
"ext-json": "*"
},
Expand Down Expand Up @@ -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"
}
}
}
6 changes: 2 additions & 4 deletions src/Commands/Publish.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -53,7 +52,6 @@ public function handle()
if ('all' == $locale) {
$files = [
\addslashes($sourcePath).'/*',
escapeshellarg($sourceJsonPath),
];
$message = 'all';
$copyEnFiles = true;
Expand All @@ -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.");
Expand Down
2 changes: 2 additions & 0 deletions src/FileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down

0 comments on commit b0bbd88

Please sign in to comment.