aboutsummaryrefslogtreecommitdiffstats
path: root/include/language.php
diff options
context:
space:
mode:
Diffstat (limited to 'include/language.php')
-rw-r--r--include/language.php49
1 files changed, 6 insertions, 43 deletions
diff --git a/include/language.php b/include/language.php
index 538f67d90..9b68717f8 100644
--- a/include/language.php
+++ b/include/language.php
@@ -29,7 +29,7 @@ function get_browser_language() {
$langs = [];
$lang_parse = [];
- if (x($_SERVER, 'HTTP_ACCEPT_LANGUAGE')) {
+ if (!empty($_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',
$_SERVER['HTTP_ACCEPT_LANGUAGE'], $lang_parse);
@@ -204,7 +204,7 @@ function load_translation_table($lang, $install = false) {
function t($s, $ctx = ''): string {
$cs = $ctx ? '__ctx:' . $ctx . '__ ' . $s : $s;
- if (x(App::$strings, $cs)) {
+ if (!empty(App::$strings[$cs])) {
$t = App::$strings[$cs];
return ((is_array($t)) ? translate_projectname($t[0]) : translate_projectname($t));
@@ -219,7 +219,7 @@ function t($s, $ctx = ''): string {
*/
function translate_projectname($s) {
- if(strpos($s,'rojectname') !== false) {
+ if(str_contains($s,'rojectname')) {
return str_replace(array('$projectname','$Projectname'),array(Zotlabs\Lib\System::get_platform_name(),ucfirst(Zotlabs\Lib\System::get_platform_name())),$s);
}
return $s;
@@ -239,7 +239,7 @@ function translate_projectname($s) {
function tt($singular, $plural, $count, $ctx = ''){
$cs = $ctx ? "__ctx:" . $ctx . "__ " . $singular : $singular;
- if (x(App::$strings,$cs)) {
+ if (!empty(App::$strings[$cs])) {
$t = App::$strings[$cs];
$f = 'string_plural_select_' . str_replace('-', '_', App::$language);
if (! function_exists($f))
@@ -282,9 +282,8 @@ function ta($k){
*/
function tf() {
-
- $s = "plural_function_code";
- return (x(App::$strings, $s) ? App::$strings[$s] : "0");
+ $s = "plural_function_code";
+ return (!empty(App::$strings[$s]) ? App::$strings[$s] : "0");
}
/**
@@ -391,7 +390,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 +404,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',