aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/help.php28
-rw-r--r--include/language.php16
2 files changed, 24 insertions, 20 deletions
diff --git a/include/help.php b/include/help.php
index 02c3cb8e4..0dc37e517 100644
--- a/include/help.php
+++ b/include/help.php
@@ -28,7 +28,7 @@ function get_help_content($tocpath = false) {
}
if($path) {
-
+
$title = basename($path);
if(! $tocpath)
\App::$page['title'] = t('Help:') . ' ' . ucwords(str_replace('-',' ',notags($title)));
@@ -38,10 +38,10 @@ function get_help_content($tocpath = false) {
// available and so default back to the English TOC at /doc/toc.{html,bb,md}
// TODO: This is incompatible with the hierarchical TOC construction
// defined in /Zotlabs/Widget/Helpindex.php.
- if($tocpath !== false &&
- load_doc_file('doc/' . $path . '.md') === '' &&
- load_doc_file('doc/' . $path . '.bb') === '' &&
- load_doc_file('doc/' . $path . '.html') === ''
+ if($tocpath !== false &&
+ load_doc_file('doc/' . $path . '.md') === '' &&
+ load_doc_file('doc/' . $path . '.bb') === '' &&
+ load_doc_file('doc/' . $path . '.html') === ''
) {
$path = $title;
}
@@ -120,22 +120,28 @@ function preg_callback_help_include($matches) {
}
+/**
+ * @brief
+ *
+ * @return boolean|array
+ */
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
+ // 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;
} else {
$lang = \App::$language;
- if(! isset($lang))
+ if(! isset($lang))
$lang = 'en';
+
$from_url = false;
}
+
return array('language' => $lang, 'from_url' => $from_url);
}
@@ -145,14 +151,14 @@ function load_doc_file($s) {
$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
+ // 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;
+ $path .= '/' . $lang;
}
$b = basename($s);
-
+
for($i=1+$url_idx; $i<argc()-1; $i++) {
$path .= '/' . argv($i);
}
diff --git a/include/language.php b/include/language.php
index a59823757..eb286231a 100644
--- a/include/language.php
+++ b/include/language.php
@@ -17,7 +17,7 @@
*
* Get the language setting directly from system variables, bypassing get_config()
* as database may not yet be configured.
- *
+ *
* If possible, we use the value from the browser.
*
* @return array with ordered list of preferred languages from browser
@@ -28,7 +28,7 @@ function get_browser_language() {
if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) {
// break up string into pieces (languages and q factors)
- preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
+ preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\s*(;\s*q\s*=\s*(1|0\.[0-9]+))?/i',
$_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
if (count($lang_parse[1])) {
@@ -40,7 +40,7 @@ function get_browser_language() {
if ($val === '') $langs[$lang] = 1;
}
- // sort list based on value
+ // sort list based on value
arsort($langs, SORT_NUMERIC);
}
}
@@ -52,7 +52,7 @@ function get_browser_language() {
* @brief Returns the best language for which also a translation exists.
*
* This function takes the results from get_browser_language() and compares it
- * with the available translations and returns the best fitting language for
+ * with the available translations and returns the best fitting language for
* which there exists a translation.
*
* If there is no match fall back to config['system']['language']
@@ -243,11 +243,9 @@ function string_plural_select_default($n) {
*
* @see http://pear.php.net/package/Text_LanguageDetect
* @param string $s A string to examine
- * @return Language code in 2-letter ISO 639-1 (en, de, fr) format
+ * @return string Language code in 2-letter ISO 639-1 (en, de, fr) format
*/
function detect_language($s) {
- require_once('Text/LanguageDetect.php');
-
$min_length = get_config('system', 'language_detect_min_length');
if ($min_length === false)
$min_length = LANGUAGE_DETECT_MIN_LENGTH;
@@ -257,7 +255,7 @@ function detect_language($s) {
$min_confidence = LANGUAGE_DETECT_MIN_CONFIDENCE;
// embedded apps have long base64 strings which will trip up the detector.
- $naked_body = preg_replace('/\[app\](.*?)\[\/app\]/','',$s);
+ $naked_body = preg_replace('/\[app\](.*?)\[\/app\]/', '', $s);
// strip off bbcode
$naked_body = preg_replace('/\[(.+?)\]/', '', $naked_body);
if (mb_strlen($naked_body) < intval($min_length)) {
@@ -381,7 +379,7 @@ function lang_selector() {
$o = replace_macros($tpl, array(
'$title' => t('Select an alternate language'),
'$langs' => array($lang_options, $selected),
-
+
));
return $o;