Skip to content

Commit

Permalink
Merge pull request #89 from ARCANEDEV/update-package
Browse files Browse the repository at this point in the history
Update package
  • Loading branch information
arcanedev-maroc authored Mar 22, 2017
2 parents fe9181f + 2b92ff2 commit bc0bfa9
Show file tree
Hide file tree
Showing 27 changed files with 402 additions and 577 deletions.
17 changes: 0 additions & 17 deletions _docs/1-Installation-and-Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,6 @@ Once the package is installed, you can register the service provider in `config/

> No need to register the Localization facade, it's done automagically.
##### Now you need to update your Http Kernel to use the Localization Router.

```php
// app/Http/Kernel.php
<?php namespace App\Http;

//...

class Kernel extends HttpKernel
{
// Localization Trait
use \Arcanedev\Localization\Traits\LocalizationKernelTrait;

// Your middleware(s) here
}
```

### Artisan commands

To publish the config &amp; view files, run this command:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"require": {
"php": ">=5.6.4",
"arcanedev/support": "~3.20"
"arcanedev/support": "~4.1"
},
"require-dev": {
"phpunit/phpcov": "~3.0",
Expand Down
16 changes: 10 additions & 6 deletions config/localization.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

return [
/* ------------------------------------------------------------------------------------------------

/* -----------------------------------------------------------------
| Settings
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'supported-locales' => ['en', 'es', 'fr'],

'accept-language-header' => true,
Expand All @@ -13,10 +15,11 @@

'facade' => 'Localization',

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Route
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'route' => [
'middleware' => [
'localization-session-redirect' => true,
Expand All @@ -27,10 +30,11 @@
],
],

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Locales
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/

'locales' => [
// A
//====================================================>
Expand Down
10 changes: 5 additions & 5 deletions src/Contracts/LocalesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
interface LocalesManager
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Set and return current locale.
Expand Down Expand Up @@ -90,9 +90,9 @@ public function getSupportedLocalesKeys();
*/
public function setSupportedLocales(array $supportedLocales);

/* ------------------------------------------------------------------------------------------------
| Check Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/
/**
* Check if default is supported.
Expand Down
45 changes: 24 additions & 21 deletions src/Contracts/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/
interface Localization
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Returns default locale.
Expand Down Expand Up @@ -93,6 +93,13 @@ public function getCurrentLocaleNative();
*/
public function getCurrentLocaleRegional();

/**
* Get all locales.
*
* @return \Arcanedev\Localization\Entities\LocaleCollection
*/
public function getAllLocales();

/**
* Set and return current locale.
*
Expand All @@ -116,9 +123,9 @@ public function setBaseUrl($url);
*/
public function setRouteNameFromRequest(Request $request);

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Translate routes and save them to the translated routes array (used in the localize route filter).
Expand Down Expand Up @@ -168,9 +175,9 @@ public function getLocalizedURL($locale = null, $url = null, $attributes = []);
*/
public function createUrlFromUri($uri);

/* ------------------------------------------------------------------------------------------------
| Translation Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Translation Methods
| -----------------------------------------------------------------
*/
/**
* Returns an URL adapted to the route name and the locale given.
Expand All @@ -183,27 +190,23 @@ public function createUrlFromUri($uri);
*/
public function getUrlFromRouteName($locale, $transKey, $attributes = []);

/* ------------------------------------------------------------------------------------------------
| Check Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/
/**
* Check if Locale exists on the supported locales collection.
*
* @param string|bool $locale
* Hide the default locale in URL ??
*
* @return bool
*/
public function isLocaleSupported($locale);
public function isDefaultLocaleHiddenInUrl();

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
*/
/**
* Hide the default locale in URL ??
* Check if Locale exists on the supported locales collection.
*
* @param string|bool $locale
*
* @return bool
*/
public function isDefaultLocaleHiddenInUrl();
public function isLocaleSupported($locale);
}
17 changes: 14 additions & 3 deletions src/Contracts/Negotiator.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php namespace Arcanedev\Localization\Contracts;

use Arcanedev\Localization\Entities\LocaleCollection;
use Illuminate\Http\Request;

/**
Expand All @@ -10,10 +11,20 @@
*/
interface Negotiator
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Make Negotiator instance.
*
* @param string $defaultLocale
* @param \Arcanedev\Localization\Entities\LocaleCollection $supportedLanguages
*
* @return self
*/
public static function make($defaultLocale, LocaleCollection $supportedLanguages);

/**
* Negotiate the request.
*
Expand Down
20 changes: 11 additions & 9 deletions src/Contracts/RouteTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
*/
interface RouteTranslator
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get current route.
Expand All @@ -37,9 +37,9 @@ public function setCurrentRoute($currentRoute);
*/
public function getTranslatedRoutes();

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Translate routes and save them to the translated routes array (used in the localize route filter).
Expand Down Expand Up @@ -96,11 +96,13 @@ public function findTranslatedRouteByPath($path, $locale);
*
* @return string
*/
public function getUrlFromRouteName($locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false);
public function getUrlFromRouteName(
$locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false
);

/* ------------------------------------------------------------------------------------------------
| Check Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/
/**
* Check if has current route.
Expand Down
6 changes: 3 additions & 3 deletions src/Contracts/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
*/
interface Url
{
/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Extract attributes for current url.
Expand Down
26 changes: 13 additions & 13 deletions src/Entities/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
class Locale implements Arrayable, Jsonable, JsonSerializable
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Locale key.
Expand Down Expand Up @@ -65,9 +65,9 @@ class Locale implements Arrayable, Jsonable, JsonSerializable
*/
private $default = false;

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Constructor
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Create Locale instance.
Expand All @@ -85,9 +85,9 @@ public function __construct($key, array $data)
$this->setRegional(isset($data['regional']) ? $data['regional'] : '');
}

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Get local key.
Expand Down Expand Up @@ -181,7 +181,7 @@ public function direction()
/**
* Set Direction.
*
* @param string $direction
* @param string $direction
*
* @return self
*/
Expand Down Expand Up @@ -264,9 +264,9 @@ private function setDefault()
return $this;
}

/* ------------------------------------------------------------------------------------------------
| Main Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Create Locale instance.
Expand All @@ -281,9 +281,9 @@ public static function make($key, array $data)
return new self($key, $data);
}

/* ------------------------------------------------------------------------------------------------
| Other Functions
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Other Methods
| -----------------------------------------------------------------
*/
/**
* Get the locale entity as an array.
Expand Down
21 changes: 7 additions & 14 deletions src/Entities/LocaleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,20 @@
*/
class LocaleCollection extends Collection
{
/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Properties
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Locale collection.
*
* @var array
*/
protected $items = [];

/**
* Supported locales.
*
* @var array
*/
protected $supported = [];

/* ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Getters & Setters
| ------------------------------------------------------------------------------------------------
| -----------------------------------------------------------------
*/
/**
* Set supported locales keys.
Expand All @@ -46,9 +39,9 @@ public function setSupportedKeys(array $supported)
return $this;
}

/* ------------------------------------------------------------------------------------------------
| Main Function
| ------------------------------------------------------------------------------------------------
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/
/**
* Get the first locale from the collection.
Expand Down
Loading

0 comments on commit bc0bfa9

Please sign in to comment.