Skip to content

Commit 6cf8993

Browse files
authored
Merge pull request #1 from movemoveapp/develop
1.7.0 release
2 parents 3aade75 + ddd3266 commit 6cf8993

File tree

14 files changed

+614
-341
lines changed

14 files changed

+614
-341
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# These are supported funding model platforms
22

3-
github: [mcamara, iwasherefirst2]
3+
github: [mcamara, iwasherefirst2, pipisco]

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/.project
33
/.settings
44
/vendor
5+
*.cache
56
composer.lock
67
composer.phar
78
Thumbs.db

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dist: trusty
66

77
php:
88
- 7.1
9-
- 7.2
109
- 7.3
1110
- 7.4
1211

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
### 1.7.0
2+
- Support for localization switch by domain names
3+
4+
### 1.6.1
5+
- Support Laravel < 6 for Illuminate\Support\Env usage (#750): Use `Env::get` instead of `.env`
6+
- It conflicts with other `env()` global functions (such as CakePHP), and most of them don't handle closures.
7+
- Support Laravel < 6 for Illuminate\Support\Env usage
8+
- Fixed `env()` and `Illuminate\Support\Env` usage to support Laravel < 6
9+
10+
### 1.6.0
11+
- Compatibility with Laravel 8
12+
13+
### 1.5.0
14+
- Compatibility with Laravel 7.x
15+
116
### 1.4.0
217
- Added compatibility with Laravel 6
318

README.md

Lines changed: 101 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,26 @@
11
# Laravel Localization
2+
[![Build Status](https://app.travis-ci.com/movemoveapp/laravel-localization.svg?branch=master)](https://app.travis-ci.com/movemoveapp/laravel-localization)
3+
[![Latest Stable Version](https://poser.pugx.org/movemoveapp/laravel-localization/v)](//packagist.org/packages/movemoveapp/laravel-localization)
4+
[![Total Downloads](https://poser.pugx.org/movemoveapp/laravel-localization/downloads)](//packagist.org/packages/movemoveapp/laravel-localization)
5+
[![License](https://poser.pugx.org/movemoveapp/laravel-localization/license)](//packagist.org/packages/movemoveapp/laravel-localization)
26

3-
[![Join the chat at https://gitter.im/mcamara/laravel-localization](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/mcamara/laravel-localization?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
47

5-
[![Latest Stable Version](https://poser.pugx.org/mcamara/laravel-localization/version.png)](https://packagist.org/packages/mcamara/laravel-localization) [![Total Downloads](https://poser.pugx.org/mcamara/laravel-localization/d/total.png)](https://packagist.org/packages/mcamara/laravel-localization) [![Build Status](https://travis-ci.org/mcamara/laravel-localization.png)](https://travis-ci.org/mcamara/laravel-localization)
6-
[![Open Source Helpers](https://www.codetriage.com/mcamara/laravel-localization/badges/users.svg)](https://www.codetriage.com/mcamara/laravel-localization)
7-
[![Reviewed by Hound](https://img.shields.io/badge/Reviewed_by-Hound-8E64B0.svg)](https://houndci.com)
8+
## About Fork
9+
This package is a fork of [mcamara/laravel-localization](https://github.com/mcamara/laravel-localization) with a support for localization switch by domain names like to
10+
11+
- exmaple.com - english version
12+
- example.es - versión en español
13+
- example.ru - русская версия
14+
15+
or
16+
17+
- en.exmaple.com - english version
18+
- es.example.com - versión en español
19+
- ru.example.com - русская версия
20+
21+
Read a more information about new feature [Localization Switch By Domain Names](#localization-switch-by-domain-names)
22+
23+
## Introduction
824

925
Easy i18n localization for Laravel, an useful tool to combine with Laravel localization classes.
1026

@@ -17,11 +33,14 @@ The package offers the following:
1733
- Supports caching & testing
1834
- Option to hide default locale in url
1935
- Many snippets and helpers (like language selector)
36+
- **Smart redirects between domain names**
2037

2138
## Table of Contents
2239

2340
- <a href="#installation">Installation</a>
24-
- <a href="#usage">Usage</a>
41+
- <a href="#one-domain-usage">One Domain Usage</a>
42+
- <a href="#localization-switch-by-domain-names">Localization Switch By Domain Names</a>
43+
- <a href="#domains-env-properties">Domains .env properties</a>
2544
- <a href="#redirect-middleware">Redirect Middleware</a>
2645
- <a href="#helpers">Helpers</a>
2746
- <a href="#translated-routes">Translated Routes</a>
@@ -50,7 +69,7 @@ The package offers the following:
5069

5170
## Installation
5271

53-
Install the package via composer: `composer require mcamara/laravel-localization`
72+
Install the package via composer: `composer require movemoveapp/laravel-localization`
5473

5574
For Laravel 5.4 and below it necessary to [register the service provider](/ADDITIONS.md#for-laravel-5.4-and-below).
5675

@@ -66,7 +85,7 @@ After that, `config/laravellocalization.php` will be created.
6685

6786
The configuration options are:
6887

69-
- **supportedLocales** Languages of your app (Default: English & Spanish).
88+
- **supportedLocales** Languages of your app (Default: English & Spanish) and localization domain name.
7089
- **useAcceptLanguageHeader** If true, then automatically detect language from browser.
7190
- **hideDefaultLocaleInURL** If true, then do not show default locale in url.
7291
- **localesOrder** Sort languages in custom order.
@@ -91,16 +110,18 @@ class Kernel extends HttpKernel {
91110
*/
92111
protected $routeMiddleware = [
93112
/**** OTHER MIDDLEWARE ****/
94-
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
95-
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
96-
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
97-
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
98-
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class
113+
'localize' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRoutes::class,
114+
'localizationRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationRedirectFilter::class,
115+
'localeSessionRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleSessionRedirect::class,
116+
'localeCookieRedirect' => \Mcamara\LaravelLocalization\Middleware\LocaleCookieRedirect::class,
117+
'localeViewPath' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationViewPath::class,
118+
/*** A new featrue with domain names ***/
119+
'localizationDomainRedirect' => \Mcamara\LaravelLocalization\Middleware\LaravelLocalizationDomainRedirectFilter::class,
99120
];
100121
}
101122
```
102123

103-
## Usage
124+
## One Domain Usage
104125

105126
Add the following to your routes file:
106127

@@ -124,7 +145,7 @@ Route::group(['prefix' => LaravelLocalization::setLocale()], function()
124145

125146
```
126147

127-
Once this route group is added to the routes file, a user can access all locales added into `supportedLocales` (`en` and `es` by default).
148+
Once this route group is added to the routes file, a user can access all locales added into `supportedLocales` (`en`, `es` and `ru` by default).
128149
For example, the above route file creates the following addresses:
129150

130151
```
@@ -154,6 +175,72 @@ Route::group(
154175
});
155176
```
156177

178+
### Localization Switch By Domain Names
179+
A first step, you should set up domains. For example, your project suppored tree locales:
180+
181+
- `en` is [example.com](https://example.com/)
182+
- `es` is [example.es](https://example.es/)
183+
- `ru` is [example.ru](https://example.ru/)
184+
185+
In your `.env` configuration files you should call about domains as:
186+
187+
```php
188+
LOCALIZATION_DOMAIN_NAME_EN=example.com
189+
LOCALIZATION_DOMAIN_NAME_ES=example.es
190+
LOCALIZATION_DOMAIN_NAME_RU=example.ru
191+
```
192+
193+
Don't forget uncommented your locales in the `config/laravellocalization.php` config file in `supportedLocales`.
194+
195+
Add the following to your routes file:
196+
197+
```php
198+
// routes/web.php
199+
200+
Route::group([
201+
'middleware' => [ 'localizationDomainRedirect' ]
202+
], function()
203+
{
204+
/** ADD ALL LOCALIZED ROUTES INSIDE THIS GROUP **/
205+
Route::get('/', function()
206+
{
207+
return View::make('hello');
208+
});
209+
210+
Route::get('test',function(){
211+
return View::make('test');
212+
});
213+
});
214+
215+
/** OTHER PAGES THAT SHOULD NOT BE LOCALIZED **/
216+
217+
```
218+
219+
For example, the above route file creates the following addresses:
220+
221+
```
222+
// Set application language to English
223+
https://example.com/
224+
https://example.com/test
225+
226+
// Set application language to Spanish
227+
https://example.es/
228+
https://example.es/test
229+
230+
// Set application language to Russian
231+
https://example.ru/
232+
https://example.ru/test
233+
234+
```
235+
236+
#### Domains .env properties
237+
To declare a domain name for a special location, you must declare the variable as `LOCALIZATION_DOMAIN_NAME_` and the location in uppercase. If the location uses a dash, it must be replaced with an underscore.
238+
239+
- Locale `en` is declared as `LOCALIZATION_DOMAIN_NAME_EN`
240+
- Locale `uz-Arab` is declared as `LOCALIZATION_DOMAIN_NAME_UZ_ARAB`
241+
- Locale `ca-valencia` is declared as `LOCALIZATION_DOMAIN_NAME_CA_VALENCIA`
242+
- etc...
243+
157244
### Recommendations
158245

159246
***1.***: It is **strongly** recommended to use a [redirecting middleware](#redirect-middleware).

composer.json

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
{
2-
"name": "mcamara/laravel-localization",
3-
"description": "Easy localization for Laravel",
4-
"keywords": ["localization", "laravel", "php"],
5-
"homepage": "https://github.com/mcamara/laravel-localization",
2+
"name": "movemoveapp/laravel-localization",
3+
"description": "Easy localization for Laravel with a support for localization switch by domain names.",
4+
"keywords": [
5+
"php",
6+
"laravel",
7+
"laravel-package",
8+
"laravel-localization",
9+
"language-selector",
10+
"laravel-domains",
11+
"laravel-domain-localization"
12+
],
13+
"homepage": "https://github.com/movemoveapp/laravel-localization",
614
"license": "MIT",
15+
"version": "1.7.0",
716
"authors": [
817
{
918
"name": "Marc Cámara",
1019
"email": "[email protected]",
1120
"role": "Developer"
21+
},
22+
{
23+
"name": "Dmitry Kovalev",
24+
"email": "[email protected]",
25+
"role": "Developer"
1226
}
1327
],
1428
"require": {

0 commit comments

Comments
 (0)