Skip to content

Commit

Permalink
Add regional language support (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
bajb authored Jun 29, 2020
1 parent 6578dab commit 3d20fa3
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/Language/AbstractLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
namespace Packaged\Rwd\Language;

abstract class AbstractLanguage implements LanguageInterface
{
}
13 changes: 13 additions & 0 deletions src/Language/AbstractRegionalLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
namespace Packaged\Rwd\Language;

abstract class AbstractRegionalLanguage extends AbstractLanguage implements RegionalLanguageInterface
{
/**
* @return string
*/
public function getFullCode()
{
return $this->getCode() . '-' . $this->getRegionCode();
}
}
39 changes: 39 additions & 0 deletions src/Language/RegionalLanguage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
namespace Packaged\Rwd\Language;

class RegionalLanguage extends AbstractRegionalLanguage implements RegionalLanguageInterface
{
protected $_language;
protected $_regionCode;

public function __construct(LanguageInterface $baseLanguage, string $regionCode)
{
$this->_language = $baseLanguage;
$this->_regionCode = $regionCode;
}

public function getEnglishName()
{
return $this->_language->getEnglishName();
}

public function getNativeName()
{
return $this->_language->getNativeName();
}

public function getCode()
{
return $this->_language->getCode();
}

public function getDirection()
{
return $this->_language->getDirection();
}

public function getRegionCode()
{
return $this->_regionCode;
}
}
15 changes: 15 additions & 0 deletions src/Language/RegionalLanguageInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
namespace Packaged\Rwd\Language;

interface RegionalLanguageInterface extends LanguageInterface
{
/**
* @return string
*/
public function getRegionCode();

/**
* @return string
*/
public function getFullCode();
}

0 comments on commit 3d20fa3

Please sign in to comment.