Skip to content

Commit 8d3b1ed

Browse files
Merge pull request #152 from ARCANEDEV/update-laravel_7.x_support
Updating the package to support Laravel 7
2 parents d2c7dfe + 0cac4af commit 8d3b1ed

14 files changed

Lines changed: 91 additions & 91 deletions

.editorconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# This file is for unifying the coding style for different editors and IDEs
2-
# editorconfig.org
3-
41
root = true
52

63
[*]
7-
end_of_line = lf
84
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
97
indent_style = space
108
indent_size = 4
119
trim_trailing_whitespace = true
12-
insert_final_newline = true
1310

1411
[*.md]
12+
trim_trailing_whitespace = false
13+
14+
[*.{yml,yaml}]
1515
indent_size = 2

.github/workflows/run-tests.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: run-tests
22

3-
on: [push]
3+
on: [push, pull_request]
44

55
jobs:
66
tests:
@@ -10,7 +10,6 @@ jobs:
1010
fail-fast: true
1111
matrix:
1212
php: [7.2, 7.3, 7.4]
13-
laravel: [6.*]
1413
dependency-version: [prefer-lowest, prefer-stable]
1514

1615
name: PHP ${{ matrix.php }} - ${{ matrix.dependency-version }}
@@ -23,10 +22,10 @@ jobs:
2322
uses: actions/cache@v1
2423
with:
2524
path: ~/.composer/cache/files
26-
key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
25+
key: dependencies-laravel-7.x-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }}
2726

2827
- name: Setup PHP
29-
uses: shivammathur/setup-php@v1
28+
uses: shivammathur/setup-php@v2
3029
with:
3130
php-version: ${{ matrix.php }}
3231
extensions: curl, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, iconv, intl

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2015-2019 | ARCANEDEV <arcanedev.maroc@gmail.com> - Localization
3+
Copyright (c) 2015-2020 | ARCANEDEV <arcanedev.maroc@gmail.com> - Localization
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Feel free to check out the [releases](https://github.com/ARCANEDEV/Localization/
2121
### Features
2222

2323
* Easy setup & configuration.
24-
* Laravel `5.x | 6.x` are supported.
24+
* Laravel `5.x | 6.x | 7.x` are supported.
2525
* SEO-Friendly (Search engine optimization).
2626
* New extended Router to manage your localized routes.
2727
* Translated Eloquent Models.
@@ -52,7 +52,7 @@ If you discover any security related issues, please email arcanedev.maroc@gmail.
5252
- [All Contributors][link-contributors]
5353

5454
[badge_license]: http://img.shields.io/packagist/l/arcanedev/localization.svg?style=flat-square
55-
[badge_laravel]: https://img.shields.io/badge/Laravel-5.x%20|%206.x-orange.svg?style=flat-square
55+
[badge_laravel]: https://img.shields.io/badge/Laravel-5.x|6.x|7.x-orange.svg?style=flat-square
5656
[badge_build]: https://img.shields.io/github/workflow/status/ARCANEDEV/Localization/run-tests?style=flat-square
5757
[badge_coverage]: https://img.shields.io/scrutinizer/coverage/g/ARCANEDEV/Localization.svg?style=flat-square
5858
[badge_quality]: https://img.shields.io/scrutinizer/g/ARCANEDEV/Localization.svg?style=flat-square

_docs/1-Installation-and-Setup.md

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,49 +6,40 @@
66
2. [Configuration](2-Configuration.md)
77
3. [Usage](3-Usage.md)
88
4. [FAQ](4-FAQ.md)
9-
10-
## Server Requirements
11-
12-
The Localization package has a few system requirements:
13-
14-
- PHP >= 7.0
15-
16-
##### Optional
17-
18-
PHP extensions:
19-
20-
* **ext_intl :** Needed to use the `Locale` class. (http://php.net/manual/en/class.locale.php)
219

2210
## Version Compatibility
2311

2412
| Localization | Laravel |
2513
|:---------------------------------------|:--------------------------------------------------------------------------------------------------------------------|
26-
| ![Localization v0.x][localization_0_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] |
27-
| ![Localization v1.x][localization_1_x] | ![Laravel v5.4][laravel_5_4] |
28-
| ![Localization v2.x][localization_2_x] | ![Laravel v5.5][laravel_5_5] |
29-
| ![Localization v3.x][localization_3_x] | ![Laravel v5.6][laravel_5_6] |
30-
| ![Localization v4.x][localization_4_x] | ![Laravel v5.7][laravel_5_7] |
14+
| ![Localization v7.x][localization_7_x] | ![Laravel v7.*][laravel_7_x] |
15+
| ![Localization v6.x][localization_6_x] | ![Laravel v6.*][laravel_6_x] |
3116
| ![Localization v5.x][localization_5_x] | ![Laravel v5.8][laravel_5_8] |
32-
| ![Localization v6.x][localization_6_x] | ![Laravel v6.0][laravel_6_0] |
17+
| ![Localization v4.x][localization_4_x] | ![Laravel v5.7][laravel_5_7] |
18+
| ![Localization v3.x][localization_3_x] | ![Laravel v5.6][laravel_5_6] |
19+
| ![Localization v2.x][localization_2_x] | ![Laravel v5.5][laravel_5_5] |
20+
| ![Localization v1.x][localization_1_x] | ![Laravel v5.4][laravel_5_4] |
21+
| ![Localization v0.x][localization_0_x] | ![Laravel v5.0][laravel_5_0] ![Laravel v5.1][laravel_5_1] ![Laravel v5.2][laravel_5_2] ![Laravel v5.3][laravel_5_3] |
3322

34-
[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"
35-
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
36-
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
37-
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
38-
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
39-
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
40-
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
41-
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
23+
[laravel_7_x]: https://img.shields.io/badge/v7.x-supported-brightgreen.svg?style=flat-square "Laravel v7.*"
24+
[laravel_6_x]: https://img.shields.io/badge/v6.x-supported-brightgreen.svg?style=flat-square "Laravel v6.*"
4225
[laravel_5_8]: https://img.shields.io/badge/v5.8-supported-brightgreen.svg?style=flat-square "Laravel v5.8"
43-
[laravel_6_0]: https://img.shields.io/badge/v6.0-supported-brightgreen.svg?style=flat-square "Laravel v6.0"
26+
[laravel_5_7]: https://img.shields.io/badge/v5.7-supported-brightgreen.svg?style=flat-square "Laravel v5.7"
27+
[laravel_5_6]: https://img.shields.io/badge/v5.6-supported-brightgreen.svg?style=flat-square "Laravel v5.6"
28+
[laravel_5_5]: https://img.shields.io/badge/v5.5-supported-brightgreen.svg?style=flat-square "Laravel v5.5"
29+
[laravel_5_4]: https://img.shields.io/badge/v5.4-supported-brightgreen.svg?style=flat-square "Laravel v5.4"
30+
[laravel_5_3]: https://img.shields.io/badge/v5.3-supported-brightgreen.svg?style=flat-square "Laravel v5.3"
31+
[laravel_5_2]: https://img.shields.io/badge/v5.2-supported-brightgreen.svg?style=flat-square "Laravel v5.2"
32+
[laravel_5_1]: https://img.shields.io/badge/v5.1-supported-brightgreen.svg?style=flat-square "Laravel v5.1"
33+
[laravel_5_0]: https://img.shields.io/badge/v5.0-supported-brightgreen.svg?style=flat-square "Laravel v5.0"
4434

45-
[localization_0_x]: https://img.shields.io/badge/version-0.*-blue.svg?style=flat-square "Localization v0.*"
46-
[localization_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "Localization v1.*"
47-
[localization_2_x]: https://img.shields.io/badge/version-2.*-blue.svg?style=flat-square "Localization v2.*"
48-
[localization_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "Localization v3.*"
49-
[localization_4_x]: https://img.shields.io/badge/version-4.*-blue.svg?style=flat-square "Localization v4.*"
50-
[localization_5_x]: https://img.shields.io/badge/version-5.*-blue.svg?style=flat-square "Localization v5.*"
35+
[localization_7_x]: https://img.shields.io/badge/version-7.*-blue.svg?style=flat-square "Localization v7.*"
5136
[localization_6_x]: https://img.shields.io/badge/version-6.*-blue.svg?style=flat-square "Localization v6.*"
37+
[localization_5_x]: https://img.shields.io/badge/version-5.*-blue.svg?style=flat-square "Localization v5.*"
38+
[localization_4_x]: https://img.shields.io/badge/version-4.*-blue.svg?style=flat-square "Localization v4.*"
39+
[localization_3_x]: https://img.shields.io/badge/version-3.*-blue.svg?style=flat-square "Localization v3.*"
40+
[localization_2_x]: https://img.shields.io/badge/version-2.*-blue.svg?style=flat-square "Localization v2.*"
41+
[localization_1_x]: https://img.shields.io/badge/version-1.*-blue.svg?style=flat-square "Localization v1.*"
42+
[localization_0_x]: https://img.shields.io/badge/version-0.*-blue.svg?style=flat-square "Localization v0.*"
5243

5344
## Composer
5445

@@ -58,6 +49,10 @@ You can install this package via [Composer](http://getcomposer.org/) by running
5849
composer require arcanedev/localization
5950
```
6051

52+
PHP extensions:
53+
54+
* **ext_intl :** Needed to use the `Locale` class. (http://php.net/manual/en/class.locale.php)
55+
6156
## Laravel
6257

6358
### Setup

_docs/2-Configuration.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@ return [
6666
| localized-routes | Allows to register all translatable routes. |
6767
| translation-redirect | Allows to translate the route attributes by using the translation event. |
6868

69-
## Ignored URI / Route
69+
## Ignored URI/Route from localization
7070

7171
```php
72-
'ignored-uri' => [
73-
//
74-
],
75-
76-
'ignored-routes' => [
72+
'ignored-redirection' => [
7773
//
7874
],
7975
```

composer.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
"type": "library",
1515
"license": "MIT",
1616
"require": {
17-
"php": ">=7.2.0",
17+
"php": "^7.2.5",
1818
"ext-json": "*",
19-
"arcanedev/support": "^5.1"
19+
"arcanedev/support": "^7.0"
2020
},
2121
"require-dev": {
2222
"ext-intl": "*",
23-
"orchestra/testbench": "^4.0",
23+
"orchestra/testbench": "^5.0",
2424
"mockery/mockery": "^1.3.1",
25-
"phpunit/phpunit": "^8.0"
25+
"phpunit/phpunit": "^8.5|^9.0"
2626
},
2727
"autoload": {
2828
"psr-4": {
@@ -45,5 +45,7 @@
4545
},
4646
"suggest": {
4747
"ext-intl": "Use Intl extension for 'Locale' class (an identifier used to get language)."
48-
}
48+
},
49+
"minimum-stability": "dev",
50+
"prefer-stable": true
4951
}

config/localization.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,11 @@
3333
],
3434

3535
/* -----------------------------------------------------------------
36-
| Ignored URI/Routes from localization
36+
| Ignored URI/Route from localization
3737
| -----------------------------------------------------------------
3838
*/
3939

40-
'ignored-uri' => [
41-
//
42-
],
43-
44-
'ignored-routes' => [
40+
'ignored-redirection' => [
4541
//
4642
],
4743

src/LocalizationServiceProvider.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,11 @@ public function register(): void
4848
*/
4949
public function boot(): void
5050
{
51-
$this->publishConfig();
52-
$this->publishViews();
51+
$this->loadViews();
52+
53+
if ($this->app->runningInConsole()) {
54+
$this->publishConfig();
55+
$this->publishViews();
56+
}
5357
}
5458
}

src/Middleware/Middleware.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ protected function hideDefaultLocaleInURL()
9595
return $this->localization->isDefaultLocaleHiddenInUrl();
9696
}
9797

98+
/**
99+
* Get the ignored URI/Route.
100+
*
101+
* @return array
102+
*/
103+
protected function getIgnoredRedirection(): array
104+
{
105+
return config('localization.ignored-redirection', []);
106+
}
107+
98108
/* -----------------------------------------------------------------
99109
| Check Methods
100110
| -----------------------------------------------------------------
@@ -122,14 +132,17 @@ protected function isDefaultLocaleHidden($locale)
122132
protected function shouldIgnore(Request $request): bool
123133
{
124134
foreach ($this->except as $except) {
125-
if ($except !== '/')
135+
if ($except !== '/') {
126136
$except = trim($except, '/');
137+
}
127138

128-
if ($request->is($except))
139+
if ($request->is($except)) {
129140
return true;
141+
}
130142

131-
if ($request->routeIs($except))
143+
if ($request->routeIs($except)) {
132144
return true;
145+
}
133146
}
134147

135148
return false;
@@ -166,17 +179,4 @@ protected function makeRedirectResponse($url, $code = null)
166179
{
167180
return new RedirectResponse($url, $code ?? config('localization.redirection-code', 302), ['Vary' => 'Accept-Language']);
168181
}
169-
170-
/**
171-
* The URIs or route names that should not be redirected.
172-
*
173-
* @return array
174-
*/
175-
protected function getIgnoredRedirection(): array
176-
{
177-
return array_merge(
178-
config('localization.ignored-uri', []),
179-
config('localization.ignored-routes', [])
180-
);
181-
}
182182
}

0 commit comments

Comments
 (0)