MenaraSolutions\Geographer\Services\Poliglottas\English::translate PHP Method

translate() public method

public translate ( MenaraSolutions\Geographer\Contracts\IdentifiableInterface $subject, string $form = 'default', boolean $preposition = true ) : string
$subject MenaraSolutions\Geographer\Contracts\IdentifiableInterface
$form string
$preposition boolean
return string
    public function translate(IdentifiableInterface $subject, $form = 'default', $preposition = true)
    {
        if ($form != 'default' and !isset($this->defaultPrepositions[$form])) {
            throw new MisconfigurationException('Language ' . $this->code . ' doesn\'t inflict to ' . $form);
        }
        $result = $subject->expectsLongNames() ? $this->getLongName($subject->getMeta()) : $this->getShortName($subject->getMeta());
        if ($preposition && $form != 'default') {
            $result = $this->defaultPrepositions[$form] . ' ' . $result;
        }
        return $result;
    }