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 /base.php | |
parent | cd1f412b3506bc6c5df38820d2c06fdc7ee81d26 (diff) |
update translation code to deal with xx_XX
Signed-off-by: Jos Poortvliet <jospoortvliet@gmail.com>
Diffstat (limited to 'base.php')
-rw-r--r-- | base.php | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -202,9 +202,14 @@ $echoed = false; $hl = ''; $path = parse_url(site_url())['path']; $language = explode('/', substr($_SERVER['REQUEST_URI'], strlen($path))); -if(isset($language[1]) && $language[1] === 'de') { - $hl = strtolower((string)$language[1]); - if (ctype_alnum($hl) && strlen($hl) === 2) { +if(isset($language[1])) { // check if language is set. + if (strlen($hl) == 2) { + $hl = strtolower((string)$language[1]); // lowercase two-character country codes + } else { + $hl = (string)$language[1]; + } + // check if $hl is either a 2-character alphanumeric code or a regexp matched, 5-character xx_YY style code + if ( (ctype_alnum($hl) && strlen($hl) === 2) || (preg_match("/^[a-z]{2}_[A-Z]{2}/",$language[1]) && strlen($hl) == 5) ) { $l10nFiles = [ get_post()->post_name, 'header-navbar', |