Skip to content

Commit

Permalink
Merge pull request #1 from mark-gerarts/develop
Browse files Browse the repository at this point in the history
Workaround for invalid langcode error
  • Loading branch information
mark-gerarts authored May 29, 2018
2 parents b6dcd15 + c6eb541 commit e344ea1
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/PhpWord/Style/Language.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public function __construct($latin = null, $eastAsia = null, $bidirectional = nu
*/
public function setLatin($latin)
{
$latin = $this->correctLocale($latin);
$this->validateLocale($latin);
$this->latin = $latin;

Expand Down Expand Up @@ -223,4 +224,18 @@ private function validateLocale($locale)
throw new \InvalidArgumentException($locale . ' is not a valid language code');
}
}

/**
* @param string|null $locale
* @return string|null
*/
private function correctLocale($locale)
{
// This is a workaround for the error "en is not a valid language code".
if ($locale === 'en') {
return self::EN_GB;
}

return $locale;
}
}

0 comments on commit e344ea1

Please sign in to comment.