Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloud.com.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--functions.php16
-rw-r--r--l10n.php9
2 files changed, 20 insertions, 5 deletions
diff --git a/functions.php b/functions.php
index cd8d1eb4..683d25d1 100644
--- a/functions.php
+++ b/functions.php
@@ -15,4 +15,18 @@ require_once locate_template('/lib/gallery.php'); // Custom [gallery] mo
require_once locate_template('/lib/comments.php'); // Custom comments modifications
require_once locate_template('/lib/relative-urls.php'); // Root relative URLs
require_once locate_template('/lib/widgets.php'); // Sidebars and widgets
-require_once locate_template('/lib/custom.php'); // Custom functions \ No newline at end of file
+require_once locate_template('/lib/custom.php'); // Custom functions
+
+function translationUrlFilter($url, $path, $orig_scheme, $blog_id) {
+ $path = parse_url(site_url())['path'];
+ $language = explode('/', substr($_SERVER['REQUEST_URI'], strlen($path)));
+ if(isset($language[1]) && $language[1] === 'de') {
+ $url = explode('/', $url);
+ $languageEntry = ['de'];
+ array_splice($url, 4, 0, $languageEntry);
+ return implode('/', $url);
+ }
+ return $url;
+}
+
+add_filter('home_url', 'translationUrlFilter');
diff --git a/l10n.php b/l10n.php
index db6ecb9c..15be3b9d 100644
--- a/l10n.php
+++ b/l10n.php
@@ -41,10 +41,11 @@ class L10N {
* @return string
*/
private function getCurrentLanguage() {
- if(isset($_GET['hl'])) {
- $hl = strtolower((string)$_GET['hl']);
- if(ctype_alnum($hl) && strlen($hl) === 2) {
- return $hl;
+ $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];
}
}