From a0e57459dcbe8645184f636f648739d84da6bcdf Mon Sep 17 00:00:00 2001 From: Ernestas Staugaitis Date: Sun, 16 Feb 2020 22:12:34 +0200 Subject: [PATCH 1/2] Some document have non-standard locale code --- src/PhpWord/Style/Language.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index 18ef88975f..2ccc44c7c2 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -228,6 +228,8 @@ public function getBidirectional() */ private function validateLocale($locale) { + $locale = str_replace('_', '-', $locale); + if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale); } From 37c15e66cda2820162e07ff12db2782c64382b28 Mon Sep 17 00:00:00 2001 From: Ernestas Staugaitis Date: Mon, 17 Feb 2020 11:44:27 +0200 Subject: [PATCH 2/2] Some document have non-standard locale code --- src/PhpWord/Style/Language.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/PhpWord/Style/Language.php b/src/PhpWord/Style/Language.php index 2ccc44c7c2..7b2de51e07 100644 --- a/src/PhpWord/Style/Language.php +++ b/src/PhpWord/Style/Language.php @@ -228,7 +228,9 @@ public function getBidirectional() */ private function validateLocale($locale) { - $locale = str_replace('_', '-', $locale); + if ($locale !== null) { + $locale = str_replace('_', '-', $locale); + } if (strlen($locale) === 2) { return strtolower($locale) . '-' . strtoupper($locale);