Skip to content

Commit

Permalink
Fix for topics when switching language
Browse files Browse the repository at this point in the history
Fix for #804
  • Loading branch information
eSilverStrike committed Aug 16, 2017
1 parent 6a1ec61 commit f5a032f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions public_html/switchlang.php
Expand Up @@ -73,11 +73,15 @@ function switch_language($url, $newLang, $oldLang)
for ($i = 0; $i < $parts; $i++) {
if (substr($p[$i], -4) === '.php') {
// found the script name - assume next parameter is the ID
if (isset($p[$i + 1])) {
if (substr($p[$i + 1], -($lang_len + 1)) === '_' . $oldLang) {
$p[$i + 1] = substr_replace($p[$i + 1], $newLang, -$lang_len);
$changed = true;
}
// There is a langID somewhere after the script name (it may no longer be next with url_rewrite enabled, etc..)
for ($j = $i; $j < $parts; $j++) {
if (isset($p[$j + 1])) {
if (substr($p[$j + 1], -($lang_len + 1)) === '_' . $oldLang) {
$p[$j + 1] = substr_replace($p[$j + 1], $newLang, -$lang_len);
$changed = true;
break;
}
}
}
break;
}
Expand Down

0 comments on commit f5a032f

Please sign in to comment.