X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FL10n.php;h=0a91677b5d80080c205381b32732c08e2888b2ec;hb=88b3effc180c5477bc8002b9d9ea8f3f628588dd;hp=2c45fb95519f47473e7ce867b0881e4758c69423;hpb=e3aed8099c1605e1b15b70f74b94540f4512c829;p=friendica.git diff --git a/src/Core/L10n.php b/src/Core/L10n.php index 2c45fb9551..0a91677b5d 100644 --- a/src/Core/L10n.php +++ b/src/Core/L10n.php @@ -1,6 +1,6 @@ 'Eesti', 'fi-fi' => 'Suomi', 'fr' => 'Français', + 'gd' => 'Gàidhlig', 'hu' => 'Magyar', 'is' => 'Íslenska', 'it' => 'Italiano', @@ -187,10 +188,10 @@ class L10n { $lang_variable = $server['HTTP_ACCEPT_LANGUAGE'] ?? null; - $acceptedLanguages = preg_split('/,\s*/', $lang_variable); - - if (empty($acceptedLanguages)) { + if (empty($lang_variable)) { $acceptedLanguages = []; + } else { + $acceptedLanguages = preg_split('/,\s*/', $lang_variable); } // Add get as absolute quality accepted language (except this language isn't valid) @@ -303,11 +304,12 @@ class L10n * @param string $singular * @param string $plural * @param int $count + * @param array $vars Variables to interpolate in the translation string * * @return string * @throws \Exception */ - public function tt(string $singular, string $plural, int $count): string + public function tt(string $singular, string $plural, int $count, ...$vars): string { $s = null; @@ -340,7 +342,9 @@ class L10n $s = $singular; } - $s = @sprintf($s, $count); + // We mute errors here because the translation strings may not be referencing the count at all, + // but we still have to try the interpolation just in case it is indeed referenced. + $s = @sprintf($s, $count, ...$vars); return $s; } @@ -425,32 +429,6 @@ class L10n return $ret; } - /** - * Load poke verbs - * - * @return array index is present tense verb - * value is array containing past tense verb, translation of present, translation of past - * @throws \Friendica\Network\HTTPException\InternalServerErrorException - * @hook poke_verbs pokes array - */ - public function getPokeVerbs(): array - { - // index is present tense verb - // value is array containing past tense verb, translation of present, translation of past - $arr = [ - 'poke' => ['poked', $this->t('poke'), $this->t('poked')], - 'ping' => ['pinged', $this->t('ping'), $this->t('pinged')], - 'prod' => ['prodded', $this->t('prod'), $this->t('prodded')], - 'slap' => ['slapped', $this->t('slap'), $this->t('slapped')], - 'finger' => ['fingered', $this->t('finger'), $this->t('fingered')], - 'rebuff' => ['rebuffed', $this->t('rebuff'), $this->t('rebuffed')], - ]; - - Hook::callAll('poke_verbs', $arr); - - return $arr; - } - /** * Creates a new L10n instance based on the given langauge *