Skip to content
This repository was archived by the owner on Oct 19, 2022. It is now read-only.

Commit 913dee1

Browse files
committed
Use /de/ for DE
1 parent 1b97ecc commit 913dee1

2 files changed

Lines changed: 20 additions & 5 deletions

File tree

‎functions.php‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,18 @@
1515
require_once locate_template('/lib/comments.php'); // Custom comments modifications
1616
require_once locate_template('/lib/relative-urls.php'); // Root relative URLs
1717
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets
18-
require_once locate_template('/lib/custom.php'); // Custom functions
18+
require_once locate_template('/lib/custom.php'); // Custom functions
19+
20+
function translationUrlFilter($url, $path, $orig_scheme, $blog_id) {
21+
$path = parse_url(site_url())['path'];
22+
$language = explode('/', substr($_SERVER['REQUEST_URI'], strlen($path)));
23+
if(isset($language[1]) && $language[1] === 'de') {
24+
$url = explode('/', $url);
25+
$languageEntry = ['de'];
26+
array_splice($url, 4, 0, $languageEntry);
27+
return implode('/', $url);
28+
}
29+
return $url;
30+
}
31+
32+
add_filter('home_url', 'translationUrlFilter');

‎l10n.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ private function getBaseTranslationFilePath() {
4141
* @return string
4242
*/
4343
private function getCurrentLanguage() {
44-
if(isset($_GET['hl'])) {
45-
$hl = strtolower((string)$_GET['hl']);
46-
if(ctype_alnum($hl) && strlen($hl) === 2) {
47-
return $hl;
44+
$path = parse_url(site_url())['path'];
45+
$language = explode('/', substr($_SERVER['REQUEST_URI'], strlen($path)));
46+
if(isset($language[1]) && strlen($language[1]) === 2) {
47+
if(ctype_alnum($language[1])) {
48+
return $language[1];
4849
}
4950
}
5051

0 commit comments

Comments
 (0)