diff options
author | git-marijus <mario@mariovavti.com> | 2017-08-24 21:58:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-24 21:58:44 +0200 |
commit | 9cb856d5fd1505577fb50de299a63ef4ac7b5783 (patch) | |
tree | ad24adea25fbc6649a102f14889729661013c386 /include | |
parent | 2d5768b71c0fa588524849749cfb0b6ffe6300b7 (diff) | |
parent | 90ec3340e44a3d3c69779f0db33ee49e864f326d (diff) | |
download | volse-hubzilla-9cb856d5fd1505577fb50de299a63ef4ac7b5783.tar.gz volse-hubzilla-9cb856d5fd1505577fb50de299a63ef4ac7b5783.tar.bz2 volse-hubzilla-9cb856d5fd1505577fb50de299a63ef4ac7b5783.zip |
Merge pull request #849 from anaqreon/doco
Added language selector menu for Help pages
Diffstat (limited to 'include')
-rw-r--r-- | include/help.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/include/help.php b/include/help.php index f38f77854..ef6b77e12 100644 --- a/include/help.php +++ b/include/help.php @@ -32,6 +32,13 @@ function get_help_content($tocpath = false) { if(! $tocpath) \App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title))); + if($tocpath !== false && + load_doc_file('doc/' . $path . '.md') === '' && + load_doc_file('doc/' . $path . '.bb') === '' && + load_doc_file('doc/' . $path . '.html') === '' + ) { + $path = 'toc'; + } $text = load_doc_file('doc/' . $path . '.md'); if(! $text) { @@ -110,7 +117,10 @@ function preg_callback_help_include($matches) { function determine_help_language() { require_once('Text/LanguageDetect.php'); $lang_detect = new Text_LanguageDetect(); + // Set this mode to recognize language by the short code like "en", "ru", etc. $lang_detect->setNameMode(2); + // If the language was specified in the URL, override the language preference + // of the browser. Default to English if both of these are absent. if($lang_detect->languageExists(argv(1))) { $lang = argv(1); $from_url = true; @@ -125,13 +135,16 @@ function determine_help_language() { function load_doc_file($s) { $path = 'doc'; + // Determine the language and modify the path accordingly $x = determine_help_language(); $lang = $x['language']; $url_idx = ($x['from_url'] ? 1 : 0); + // The English translation is at the root of /doc/. Other languages are in + // subfolders named by the language code such as "de", "es", etc. if($lang !== 'en') { $path .= '/' . $lang; } - + $b = basename($s); for($i=1+$url_idx; $i<argc()-1; $i++) { @@ -140,6 +153,16 @@ function load_doc_file($s) { $c = find_doc_file($path . '/' . $b); if($c) return $c; + // Possibly a translation was requested that has not been translated, so fall + // back to the English version + $path = 'doc'; + for($i=1+$url_idx; $i<argc()-1; $i++) { + $path .= '/' . argv($i); + } + $c = find_doc_file($path . '/' . $b); + if($c) + return $c; + // Try one last time to find the file at the explicit path input to the function $c = find_doc_file($s); if($c) return $c; |