diff options
author | Jos Poortvliet <jospoortvliet@gmail.com> | 2018-07-30 20:25:39 +0300 |
---|---|---|
committer | Jos Poortvliet <jospoortvliet@gmail.com> | 2018-07-30 20:25:39 +0300 |
commit | 3eb051a918947732c3d819274d4ecc7c487f4b01 (patch) | |
tree | 357e2f72d0ccf01acfca4037ff15e56156d1f78f /l10n.php | |
parent | cd1f412b3506bc6c5df38820d2c06fdc7ee81d26 (diff) |
update translation code to deal with xx_XX
Signed-off-by: Jos Poortvliet <jospoortvliet@gmail.com>
Diffstat (limited to 'l10n.php')
-rw-r--r-- | l10n.php | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -37,15 +37,18 @@ class L10N { /** * Gets the currently used language either from the hl parameter or the current domain + * Checks if the length is either 2 or 5 and if it is either alphanumeric or matches the xx_XX format * * @return string */ private function getCurrentLanguage() { $path = parse_url(site_url())['path']; $language = explode('/', substr($_SERVER['REQUEST_URI'], strlen($path))); - if(isset($language[1]) && strlen($language[1]) === 2) { - if(ctype_alnum($language[1])) { - return $language[1]; + if(isset($language[1])) { + if(strlen($language[1]) === 2 || strlen($language[1]) === 5) { + if(ctype_alnum($language[1]) || preg_match("/^[a-z]{2}_[A-Z]{2}/",$language[1])) { + return $language[1]; + } } } |