From 6c388575022cc10f28ed99e8e414fbc76a67bb00 Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Wed, 23 Aug 2017 03:33:03 +0000 Subject: Repaired and extended support for help page translations including table of contents files at the top level. Moved help module javascript to mod_help.js. --- Zotlabs/Widget/Helpindex.php | 12 +++++-- doc/toc.html | 62 ------------------------------------- include/help.php | 39 +++++++++++++++++------ view/js/mod_help.js | 74 ++++++++++++++++++++++++++++++++++++++++++++ view/tpl/help.tpl | 18 ----------- 5 files changed, 113 insertions(+), 92 deletions(-) create mode 100644 view/js/mod_help.js diff --git a/Zotlabs/Widget/Helpindex.php b/Zotlabs/Widget/Helpindex.php index f23e73e75..8299cf16a 100644 --- a/Zotlabs/Widget/Helpindex.php +++ b/Zotlabs/Widget/Helpindex.php @@ -9,14 +9,22 @@ class Helpindex { $o .= '
'; $level_0 = get_help_content('sitetoc'); - if(! $level_0) - $level_0 = get_help_content('toc'); + if(! $level_0) { + $path = 'toc'; + $x = determine_help_language(); + $lang = $x['language']; + if($lang !== 'en') { + $path = $lang . '/toc'; + } + $level_0 = get_help_content($path); + } $level_0 = preg_replace('/\/','
- diff --git a/include/help.php b/include/help.php index 4f9251b1b..cbadd02d9 100644 --- a/include/help.php +++ b/include/help.php @@ -107,20 +107,39 @@ function preg_callback_help_include($matches) { } - +function determine_help_language() { + require_once('Text/LanguageDetect.php'); + $lang_detect = new Text_LanguageDetect(); + $lang_detect->setNameMode(2); + if($lang_detect->languageExists(argv(1))) { + $lang = argv(1); + $from_url = true; + } else { + $lang = \App::$language; + if(! isset($lang)) + $lang = 'en'; + $from_url = false; + } + return array('language' => $lang, 'from_url' => $from_url); +} function load_doc_file($s) { - $lang = \App::$language; - if(! isset($lang)) - $lang = 'en'; + $path = 'doc'; + $x = determine_help_language(); + $lang = $x['language']; + $url_idx = ($x['from_url'] ? 1 : 0); + if($x['from_url'] && $lang !== 'en') { + $path .= '/' . $lang; + } + $b = basename($s); - $d = dirname($s); - - if($dirname !== '-') { - $c = find_doc_file("$d/$lang/$b"); - if($c) - return $c; + + for($i=1+$url_idx; $i').find('ul'); + tocUl.removeClass(); // Classes are automatically added to