Functions and Calls

finish the other functions before returning to t() and tt()
This commit is contained in:
Adam Magness 2018-01-21 12:06:27 -05:00
parent c8ecc31405
commit 45f8000ba5
4 changed files with 15 additions and 9 deletions

View file

@ -10,6 +10,7 @@ use Friendica\Content\Feature;
use Friendica\Content\Text\Markdown;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Core\Worker;
@ -1129,7 +1130,7 @@ function admin_page_site_post(App $a)
function admin_page_site(App $a)
{
/* Installed langs */
$lang_choices = get_available_languages();
$lang_choices = L10n::getAvailableLanguages();
if (strlen(Config::get('system', 'directory_submit_url')) &&
!strlen(Config::get('system', 'directory'))) {

View file

@ -3,6 +3,7 @@
* @file mod/install.php
*/
use Friendica\App;
use Friendica\Core\L10n;
use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Database\DBStructure;
@ -259,7 +260,7 @@ function install_content(App $a) {
$adminmail = notags(trim($_POST['adminmail']));
$timezone = ((x($_POST, 'timezone')) ? ($_POST['timezone']) : 'America/Los_Angeles');
/* Installed langs */
$lang_choices = get_available_languages();
$lang_choices = L10n::getAvailableLanguages();
$tpl = get_markup_template('install_settings.tpl');
$o .= replace_macros($tpl, [

View file

@ -8,6 +8,7 @@ use Friendica\Content\Feature;
use Friendica\Content\Nav;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
use Friendica\Core\PConfig;
use Friendica\Core\System;
use Friendica\Core\Worker;
@ -1186,7 +1187,7 @@ function settings_content(App $a)
}
/* Installed langs */
$lang_choices = get_available_languages();
$lang_choices = L10n::getAvailableLanguages();
/// @TODO Fix indending (or so)
$o .= replace_macros($stpl, [

View file

@ -7,6 +7,7 @@ namespace Friendica\Core;
use Friendica\Core\Config;
use dba;
require_once 'boot.php';
require_once 'include/dba.php';
/**
@ -183,14 +184,14 @@ class L10n
if (is_array($t)) {
$plural_function = 'string_plural_select_' . str_replace('-', '_', $lang);
if (function_exists($plural_function)) {
$plural_function = 'string_plural_select_default';
$plural_function = 'self::stringPluralSelectDefault';
}
$i = $plural_function($count);
$s = $t[$i];
} else {
$s = $t;
}
} elseif (string_plural_select_default($count)) {
} elseif (self::stringPluralSelectDefault($count)) {
$s = $plural;
} else {
$s = $singular;
@ -201,9 +202,10 @@ class L10n
return $s;
}
// provide a fallback which will not collide with
// a function defined in any language file
function string_plural_select_default($n)
/**
* Provide a fallback which will not collide with a function defined in any language file
*/
private static function stringPluralSelectDefault($n)
{
return $n != 1;
}
@ -221,7 +223,8 @@ class L10n
*
* @return array
*/
function get_available_languages() {
public static function getAvailableLanguages()
{
$langs = [];
$strings_file_paths = glob('view/lang/*/strings.php');