aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorAndrew Manning <andrewmanning@grid.reticu.li>2017-08-24 18:57:41 +0000
committerAndrew Manning <andrewmanning@grid.reticu.li>2017-08-24 18:57:41 +0000
commitcf2609530fcffdc7f5477336232b7cfde8b6403f (patch)
treef93c35c66cbc636a92ba53ca3bb60e6c8fbe38b7 /view/js
parent592cf893c006f24c652902fa4fae7d2d94496c3c (diff)
downloadvolse-hubzilla-cf2609530fcffdc7f5477336232b7cfde8b6403f.tar.gz
volse-hubzilla-cf2609530fcffdc7f5477336232b7cfde8b6403f.tar.bz2
volse-hubzilla-cf2609530fcffdc7f5477336232b7cfde8b6403f.zip
Added language selector menu for Help pages
Diffstat (limited to 'view/js')
-rw-r--r--view/js/mod_help.js50
1 files changed, 50 insertions, 0 deletions
diff --git a/view/js/mod_help.js b/view/js/mod_help.js
index 0f85af462..257be67e6 100644
--- a/view/js/mod_help.js
+++ b/view/js/mod_help.js
@@ -71,4 +71,54 @@ $(document).ready(function () {
var newref = p.protocol + '//' + p.hostname + portstr + p.pathname + p.hash.split('?').shift();
location.replace(newref)
}
+
+
+ // Determine language translations available from the language selector menu itself
+ var langChoices = [];
+ $('.lang-selector').find('.lang-choice').each(function (idx, a) {
+ langChoices.push($(a).html());
+ });
+ // Parse the URL and insert the language code for the loaded language, based
+ // on the variable "help_language" that is declared in the help.tpl page template
+ var path = window.location.pathname.split('/');
+ var pathParts = [];
+ var pick_me = true;
+ for (var i = 0; i < path.length; i++) {
+ if(i === 2 && pick_me ) {
+ if(path[i].length > 0) {
+ pathParts.push(help_language);
+ pick_me = false;
+ if($.inArray(path[i], langChoices) < 0) {
+ i--;
+ }
+ }
+ } else {
+ if(path[i].length > 0) {
+ pathParts.push(path[i]);
+ }
+ }
+
+ }
+ // Update the address bar to reflect the loaded language
+ window.history.pushState({}, '', '/' + pathParts.join('/'));
+
+ // Highlight the language in the language selector that is currently viewed
+ $('.lang-selector').find('.lang-choice:contains("' + help_language + '")').css('font-weight','bold').css('background-color','lightgray');
+
+ // Construct the links to the available translations based and populate the selector menu
+ $('.lang-selector').find('.lang-choice').each(function (idx, a) {
+ var langLink = [];
+
+ for (var i = 0; i < pathParts.length; i++) {
+
+ if(i === 1) {
+ langLink.push($(a).html());
+ } else {
+ langLink.push(pathParts[i]);
+ }
+
+ }
+ $(a).attr('href', '/' + langLink.join('/'));
+ });
+
});