aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2025-04-19 05:43:26 +0000
committerMario <mario@mariovavti.com>2025-04-19 05:43:26 +0000
commit295266cb10efcc55bb4dd179706439f42ef41828 (patch)
treef14e4cc191b21ddcaaa829782aa7169533828c2d
parentcace4c6c65438cc90efb51ec3098df715c194f31 (diff)
parente800d176fb70c8f6fbe69c19e6762206a4c7318b (diff)
downloadvolse-hubzilla-295266cb10efcc55bb4dd179706439f42ef41828.tar.gz
volse-hubzilla-295266cb10efcc55bb4dd179706439f42ef41828.tar.bz2
volse-hubzilla-295266cb10efcc55bb4dd179706439f42ef41828.zip
Merge branch 'refactor-language-selector' into 'dev'
Move lang_selector function to Lang module and refactor See merge request hubzilla/core!2195
-rw-r--r--Zotlabs/Module/Lang.php16
-rw-r--r--include/language.php36
2 files changed, 15 insertions, 37 deletions
diff --git a/Zotlabs/Module/Lang.php b/Zotlabs/Module/Lang.php
index fe185ebea..1eeb29363 100644
--- a/Zotlabs/Module/Lang.php
+++ b/Zotlabs/Module/Lang.php
@@ -65,8 +65,22 @@ class Lang extends Controller {
}
nav_set_selected('Language');
- return lang_selector();
+ return $this->lang_selector();
}
+ private function lang_selector(): string
+ {
+ $lang_options = language_list();
+ array_unshift($lang_options, t('default'));
+
+ $tpl = get_markup_template('lang_selector.tpl');
+
+ return replace_macros($tpl, [
+ '$title' => t('Select an alternate language'),
+ '$langs' => array($lang_options, App::$language),
+
+ ]);
+ }
+
}
diff --git a/include/language.php b/include/language.php
index 538f67d90..44b3419d5 100644
--- a/include/language.php
+++ b/include/language.php
@@ -391,7 +391,6 @@ function language_list() {
$langs = glob('view/*/hstrings.php');
$lang_options = array();
- $selected = "";
if(is_array($langs) && count($langs)) {
if(! in_array('view/en/hstrings.php',$langs))
@@ -406,41 +405,6 @@ function language_list() {
return $lang_options;
}
-function lang_selector() {
-
- $langs = glob('view/*/hstrings.php');
-
- $lang_options = array();
- $selected = "";
-
- if(is_array($langs) && count($langs)) {
- $langs[] = '';
- if(! in_array('view/en/hstrings.php',$langs))
- $langs[] = 'view/en/';
- asort($langs);
- foreach($langs as $l) {
- if($l == '') {
- $lang_options[""] = t('default');
- continue;
- }
- $ll = substr($l,5);
- $ll = substr($ll,0,strrpos($ll,'/'));
- $selected = (($ll === App::$language && (x($_SESSION, 'language'))) ? $ll : $selected);
- $lang_options[$ll] = get_language_name($ll, $ll) . " ($ll)";
- }
- }
-
- $tpl = get_markup_template('lang_selector.tpl');
-
- $o = replace_macros($tpl, array(
- '$title' => t('Select an alternate language'),
- '$langs' => array($lang_options, $selected),
-
- ));
-
- return $o;
-}
-
function rtl_languages() {
return [
'ar',