-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
45 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the ICanBoogie package. | ||
* | ||
* (c) Olivier Laviale <olivier.laviale@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace ICanBoogie\CLDR; | ||
|
||
/** | ||
* @property-read Repository $repository | ||
*/ | ||
trait LocalizeTrait | ||
{ | ||
/** | ||
* Localize the instance. | ||
* | ||
* @param string $locale_code | ||
* | ||
* @return mixed | ||
* | ||
* @throw \LogicException when the instance was created without a repository. | ||
*/ | ||
public function localize($locale_code) | ||
{ | ||
$repository = $this->repository; | ||
|
||
if (!$repository) | ||
{ | ||
throw new \LogicException("The instance was created without a repository."); | ||
} | ||
|
||
return $repository->locales[$locale_code]->localize($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters