aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/L10N
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/L10N')
-rw-r--r--lib/private/L10N/Factory.php209
-rw-r--r--lib/private/L10N/L10N.php61
-rw-r--r--lib/private/L10N/L10NString.php32
-rw-r--r--lib/private/L10N/LanguageIterator.php40
-rw-r--r--lib/private/L10N/LanguageNotFoundException.php22
-rw-r--r--lib/private/L10N/LazyL10N.php22
6 files changed, 155 insertions, 231 deletions
diff --git a/lib/private/L10N/Factory.php b/lib/private/L10N/Factory.php
index 7fcfab37fa6..6a747744829 100644
--- a/lib/private/L10N/Factory.php
+++ b/lib/private/L10N/Factory.php
@@ -1,45 +1,17 @@
<?php
declare(strict_types=1);
-
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @copyright 2016 Roeland Jago Douma <roeland@famdouma.nl>
- * @copyright 2016 Lukas Reschke <lukas@statuscode.ch>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Bjoern Schiessle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author GretaD <gretadoci@gmail.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author John Molakvoæ <skjnldsv@protonmail.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Robin McCorkell <robin@mccorkell.me.uk>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
-
namespace OC\L10N;
+use OCP\App\AppPathNotFoundException;
+use OCP\App\IAppManager;
+use OCP\ICache;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
@@ -52,7 +24,6 @@ use function is_null;
* A factory that generates language instances
*/
class Factory implements IFactory {
-
/** @var string */
protected $requestLanguage = '';
@@ -87,34 +58,29 @@ class Factory implements IFactory {
'pt_BR', 'pt_PT', 'da', 'fi_FI', 'nb_NO', 'sv', 'tr', 'zh_CN', 'ko'
];
- /** @var IConfig */
- protected $config;
-
- /** @var IRequest */
- protected $request;
-
- /** @var IUserSession */
- protected $userSession;
-
- /** @var string */
- protected $serverRoot;
-
/**
- * @param IConfig $config
- * @param IRequest $request
- * @param IUserSession $userSession
- * @param string $serverRoot
+ * Keep in sync with `build/translation-checker.php`
*/
+ public const RTL_LANGUAGES = [
+ 'ar', // Arabic
+ 'fa', // Persian
+ 'he', // Hebrew
+ 'ps', // Pashto,
+ 'ug', // 'Uyghurche / Uyghur
+ 'ur_PK', // Urdu
+ ];
+
+ private ICache $cache;
+
public function __construct(
- IConfig $config,
- IRequest $request,
- IUserSession $userSession,
- $serverRoot
+ protected IConfig $config,
+ protected IRequest $request,
+ protected IUserSession $userSession,
+ ICacheFactory $cacheFactory,
+ protected string $serverRoot,
+ protected IAppManager $appManager,
) {
- $this->config = $config;
- $this->request = $request;
- $this->userSession = $userSession;
- $this->serverRoot = $serverRoot;
+ $this->cache = $cacheFactory->createLocal('L10NFactory');
}
/**
@@ -127,12 +93,12 @@ class Factory implements IFactory {
*/
public function get($app, $lang = null, $locale = null) {
return new LazyL10N(function () use ($app, $lang, $locale) {
- $app = \OC_App::cleanAppId($app);
+ $app = $this->appManager->cleanAppId($app);
if ($lang !== null) {
$lang = str_replace(['\0', '/', '\\', '..'], '', $lang);
}
- $forceLang = $this->config->getSystemValue('force_language', false);
+ $forceLang = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
if (is_string($forceLang)) {
$lang = $forceLang;
}
@@ -142,9 +108,7 @@ class Factory implements IFactory {
$locale = $forceLocale;
}
- if ($lang === null || !$this->languageExists($app, $lang)) {
- $lang = $this->findLanguage($app);
- }
+ $lang = $this->validateLanguage($app, $lang);
if ($locale === null || !$this->localeExists($locale)) {
$locale = $this->findLocale($lang);
@@ -165,6 +129,29 @@ class Factory implements IFactory {
}
/**
+ * Check that $lang is an existing language and not null, otherwise return the language to use instead
+ *
+ * @psalm-taint-escape callable
+ * @psalm-taint-escape cookie
+ * @psalm-taint-escape file
+ * @psalm-taint-escape has_quotes
+ * @psalm-taint-escape header
+ * @psalm-taint-escape html
+ * @psalm-taint-escape include
+ * @psalm-taint-escape ldap
+ * @psalm-taint-escape shell
+ * @psalm-taint-escape sql
+ * @psalm-taint-escape unserialize
+ */
+ private function validateLanguage(string $app, ?string $lang): string {
+ if ($lang === null || !$this->languageExists($app, $lang)) {
+ return $this->findLanguage($app);
+ } else {
+ return $lang;
+ }
+ }
+
+ /**
* Find the best language
*
* @param string|null $appId App id or null for core
@@ -173,7 +160,7 @@ class Factory implements IFactory {
*/
public function findLanguage(?string $appId = null): string {
// Step 1: Forced language always has precedence over anything else
- $forceLang = $this->config->getSystemValue('force_language', false);
+ $forceLang = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
if (is_string($forceLang)) {
$this->requestLanguage = $forceLang;
}
@@ -190,7 +177,7 @@ class Factory implements IFactory {
*
* @link https://github.com/owncloud/core/issues/21955
*/
- if ($this->config->getSystemValue('installed', false)) {
+ if ($this->config->getSystemValueBool('installed', false)) {
$userId = !is_null($this->userSession->getUser()) ? $this->userSession->getUser()->getUID() : null;
if (!is_null($userId)) {
$userLang = $this->config->getUserValue($userId, 'core', 'lang', null);
@@ -228,9 +215,9 @@ class Factory implements IFactory {
return 'en';
}
- public function findGenericLanguage(string $appId = null): string {
+ public function findGenericLanguage(?string $appId = null): string {
// Step 1: Forced language always has precedence over anything else
- $forcedLanguage = $this->config->getSystemValue('force_language', false);
+ $forcedLanguage = $this->request->getParam('forceLanguage') ?? $this->config->getSystemValue('force_language', false);
if ($forcedLanguage !== false) {
return $forcedLanguage;
}
@@ -242,7 +229,7 @@ class Factory implements IFactory {
}
// Step 3.1: Check if Nextcloud is already installed before we try to access user info
- if (!$this->config->getSystemValue('installed', false)) {
+ if (!$this->config->getSystemValueBool('installed', false)) {
return 'en';
}
// Step 3.2: Check the current user (if any) for their preferred language
@@ -277,10 +264,10 @@ class Factory implements IFactory {
return $forceLocale;
}
- if ($this->config->getSystemValue('installed', false)) {
- $userId = null !== $this->userSession->getUser() ? $this->userSession->getUser()->getUID() : null;
+ if ($this->config->getSystemValueBool('installed', false)) {
+ $userId = $this->userSession->getUser() !== null ? $this->userSession->getUser()->getUID() : null;
$userLocale = null;
- if (null !== $userId) {
+ if ($userId !== null) {
$userLocale = $this->config->getUserValue($userId, 'core', 'locale', null);
}
} else {
@@ -299,7 +286,7 @@ class Factory implements IFactory {
}
// If no user locale set, use lang as locale
- if (null !== $lang && $this->localeExists($lang)) {
+ if ($lang !== null && $this->localeExists($lang)) {
return $lang;
}
@@ -314,7 +301,7 @@ class Factory implements IFactory {
* @param string $locale
* @return null|string
*/
- public function findLanguageFromLocale(string $app = 'core', string $locale = null) {
+ public function findLanguageFromLocale(string $app = 'core', ?string $locale = null) {
if ($this->languageExists($app, $locale)) {
return $locale;
}
@@ -338,6 +325,10 @@ class Factory implements IFactory {
$key = 'null';
}
+ if ($availableLanguages = $this->cache->get($key)) {
+ $this->availableLanguages[$key] = $availableLanguages;
+ }
+
// also works with null as key
if (!empty($this->availableLanguages[$key])) {
return $this->availableLanguages[$key];
@@ -349,7 +340,7 @@ class Factory implements IFactory {
$files = scandir($dir);
if ($files !== false) {
foreach ($files as $file) {
- if (substr($file, -5) === '.json' && substr($file, 0, 4) !== 'l10n') {
+ if (str_ends_with($file, '.json') && !str_starts_with($file, 'l10n')) {
$available[] = substr($file, 0, -5);
}
}
@@ -357,7 +348,7 @@ class Factory implements IFactory {
}
// merge with translations from theme
- $theme = $this->config->getSystemValue('theme');
+ $theme = $this->config->getSystemValueString('theme');
if (!empty($theme)) {
$themeDir = $this->serverRoot . '/themes/' . $theme . substr($dir, strlen($this->serverRoot));
@@ -365,7 +356,7 @@ class Factory implements IFactory {
$files = scandir($themeDir);
if ($files !== false) {
foreach ($files as $file) {
- if (substr($file, -5) === '.json' && substr($file, 0, 4) !== 'l10n') {
+ if (str_ends_with($file, '.json') && !str_starts_with($file, 'l10n')) {
$available[] = substr($file, 0, -5);
}
}
@@ -374,6 +365,7 @@ class Factory implements IFactory {
}
$this->availableLanguages[$key] = $available;
+ $this->cache->set($key, $available, 60);
return $available;
}
@@ -405,7 +397,15 @@ class Factory implements IFactory {
return in_array($lang, $languages);
}
- public function getLanguageIterator(IUser $user = null): ILanguageIterator {
+ public function getLanguageDirection(string $language): string {
+ if (in_array($language, self::RTL_LANGUAGES, true)) {
+ return 'rtl';
+ }
+
+ return 'ltr';
+ }
+
+ public function getLanguageIterator(?IUser $user = null): ILanguageIterator {
$user = $user ?? $this->userSession->getUser();
if ($user === null) {
throw new \RuntimeException('Failed to get an IUser instance');
@@ -420,7 +420,7 @@ class Factory implements IFactory {
* @return string
* @since 20.0.0
*/
- public function getUserLanguage(IUser $user = null): string {
+ public function getUserLanguage(?IUser $user = null): string {
$language = $this->config->getSystemValue('force_language', false);
if ($language !== false) {
return $language;
@@ -432,9 +432,13 @@ class Factory implements IFactory {
return $language;
}
+ if (($forcedLanguage = $this->request->getParam('forceLanguage')) !== null) {
+ return $forcedLanguage;
+ }
+
// Use language from request
- if ($this->userSession->getUser() instanceof IUser &&
- $user->getUID() === $this->userSession->getUser()->getUID()) {
+ if ($this->userSession->getUser() instanceof IUser
+ && $user->getUID() === $this->userSession->getUser()->getUID()) {
try {
return $this->getLanguageFromRequest();
} catch (LanguageNotFoundException $e) {
@@ -442,7 +446,7 @@ class Factory implements IFactory {
}
}
- return $this->config->getSystemValue('default_language', 'en');
+ return $this->request->getParam('forceLanguage') ?? $this->config->getSystemValueString('default_language', 'en');
}
/**
@@ -480,10 +484,14 @@ class Factory implements IFactory {
[$preferred_language] = explode(';', $preference);
$preferred_language = str_replace('-', '_', $preferred_language);
+ $preferred_language_parts = explode('_', $preferred_language);
foreach ($available as $available_language) {
if ($preferred_language === strtolower($available_language)) {
return $this->respectDefaultLanguage($app, $available_language);
}
+ if (strtolower($available_language) === $preferred_language_parts[0] . '_' . end($preferred_language_parts)) {
+ return $available_language;
+ }
}
// Fallback from de_De to de
@@ -509,10 +517,10 @@ class Factory implements IFactory {
// use formal version of german ("Sie" instead of "Du") if the default
// language is set to 'de_DE' if possible
if (
- is_string($defaultLanguage) &&
- strtolower($lang) === 'de' &&
- strtolower($defaultLanguage) === 'de_de' &&
- $this->languageExists($app, 'de_DE')
+ is_string($defaultLanguage)
+ && strtolower($lang) === 'de'
+ && strtolower($defaultLanguage) === 'de_de'
+ && $this->languageExists($app, 'de_DE')
) {
$result = 'de_DE';
}
@@ -529,12 +537,12 @@ class Factory implements IFactory {
*/
private function isSubDirectory($sub, $parent) {
// Check whether $sub contains no ".."
- if (strpos($sub, '..') !== false) {
+ if (str_contains($sub, '..')) {
return false;
}
// Check whether $sub is a subdirectory of $parent
- if (strpos($sub, $parent) === 0) {
+ if (str_starts_with($sub, $parent)) {
return true;
}
@@ -544,13 +552,9 @@ class Factory implements IFactory {
/**
* Get a list of language files that should be loaded
*
- * @param string $app
- * @param string $lang
* @return string[]
*/
- // FIXME This method is only public, until OC_L10N does not need it anymore,
- // FIXME This is also the reason, why it is not in the public interface
- public function getL10nFilesForApp($app, $lang) {
+ private function getL10nFilesForApp(string $app, string $lang): array {
$languageFiles = [];
$i18nDir = $this->findL10nDir($app);
@@ -558,7 +562,7 @@ class Factory implements IFactory {
if (($this->isSubDirectory($transFile, $this->serverRoot . '/core/l10n/')
|| $this->isSubDirectory($transFile, $this->serverRoot . '/lib/l10n/')
- || $this->isSubDirectory($transFile, \OC_App::getAppPath($app) . '/l10n/'))
+ || $this->isSubDirectory($transFile, $this->appManager->getAppPath($app) . '/l10n/'))
&& file_exists($transFile)
) {
// load the translations file
@@ -566,7 +570,7 @@ class Factory implements IFactory {
}
// merge with translations from theme
- $theme = $this->config->getSystemValue('theme');
+ $theme = $this->config->getSystemValueString('theme');
if (!empty($theme)) {
$transFile = $this->serverRoot . '/themes/' . $theme . substr($transFile, strlen($this->serverRoot));
if (file_exists($transFile)) {
@@ -588,9 +592,12 @@ class Factory implements IFactory {
if (file_exists($this->serverRoot . '/' . $app . '/l10n/')) {
return $this->serverRoot . '/' . $app . '/l10n/';
}
- } elseif ($app && \OC_App::getAppPath($app) !== false) {
- // Check if the app is in the app folder
- return \OC_App::getAppPath($app) . '/l10n/';
+ } elseif ($app) {
+ try {
+ return $this->appManager->getAppPath($app) . '/l10n/';
+ } catch (AppPathNotFoundException) {
+ /* App not found, continue */
+ }
}
return $this->serverRoot . '/core/l10n/';
}
@@ -614,6 +621,10 @@ class Factory implements IFactory {
}
$languageCodes = $this->findAvailableLanguages();
+ $reduceToLanguages = $this->config->getSystemValue('reduce_to_languages', []);
+ if (!empty($reduceToLanguages)) {
+ $languageCodes = array_intersect($languageCodes, $reduceToLanguages);
+ }
$commonLanguages = [];
$otherLanguages = [];
diff --git a/lib/private/L10N/L10N.php b/lib/private/L10N/L10N.php
index 09c0f1cdb35..50db373a65d 100644
--- a/lib/private/L10N/L10N.php
+++ b/lib/private/L10N/L10N.php
@@ -1,40 +1,20 @@
<?php
declare(strict_types=1);
-
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\L10N;
use OCP\IL10N;
use OCP\L10N\IFactory;
+use Psr\Log\LoggerInterface;
use Punic\Calendar;
use Symfony\Component\Translation\IdentityTranslator;
class L10N implements IL10N {
-
/** @var IFactory */
protected $factory;
@@ -103,7 +83,7 @@ class L10N implements IL10N {
$parameters = [$parameters];
}
- return (string) new L10NString($this, $text, $parameters);
+ return (string)new L10NString($this, $text, $parameters);
}
/**
@@ -122,16 +102,16 @@ class L10N implements IL10N {
*
*/
public function n(string $text_singular, string $text_plural, int $count, array $parameters = []): string {
- $identifier = "_${text_singular}_::_${text_plural}_";
+ $identifier = "_{$text_singular}_::_{$text_plural}_";
if (isset($this->translations[$identifier])) {
- return (string) new L10NString($this, $identifier, $parameters, $count);
+ return (string)new L10NString($this, $identifier, $parameters, $count);
}
if ($count === 1) {
- return (string) new L10NString($this, $text_singular, $parameters, $count);
+ return (string)new L10NString($this, $text_singular, $parameters, $count);
}
- return (string) new L10NString($this, $text_plural, $parameters, $count);
+ return (string)new L10NString($this, $text_plural, $parameters, $count);
}
/**
@@ -157,7 +137,7 @@ class L10N implements IL10N {
* - jsdate: Returns the short JS date format
*/
public function l(string $type, $data = null, array $options = []) {
- if (null === $this->locale) {
+ if ($this->locale === null) {
// Use the language of the instance
$this->locale = $this->getLanguageCode();
}
@@ -166,10 +146,10 @@ class L10N implements IL10N {
}
if ($type === 'firstday') {
- return (int) Calendar::getFirstWeekday($this->locale);
+ return (int)Calendar::getFirstWeekday($this->locale);
}
if ($type === 'jsdate') {
- return (string) Calendar::getDateFormat('short', $this->locale);
+ return (string)Calendar::getDateFormat('short', $this->locale);
}
$value = new \DateTime();
@@ -187,13 +167,13 @@ class L10N implements IL10N {
$width = $options['width'];
switch ($type) {
case 'date':
- return (string) Calendar::formatDate($value, $width, $this->locale);
+ return (string)Calendar::formatDate($value, $width, $this->locale);
case 'datetime':
- return (string) Calendar::formatDatetime($value, $width, $this->locale);
+ return (string)Calendar::formatDatetime($value, $width, $this->locale);
case 'time':
- return (string) Calendar::formatTime($value, $width, $this->locale);
+ return (string)Calendar::formatTime($value, $width, $this->locale);
case 'weekdayName':
- return (string) Calendar::getWeekdayName($value, $width, $this->locale);
+ return (string)Calendar::getWeekdayName($value, $width, $this->locale);
default:
return false;
}
@@ -216,7 +196,12 @@ class L10N implements IL10N {
public function getIdentityTranslator(): IdentityTranslator {
if (\is_null($this->identityTranslator)) {
$this->identityTranslator = new IdentityTranslator();
- $this->identityTranslator->setLocale($this->getLocaleCode());
+ // We need to use the language code here instead of the locale,
+ // because Symfony does not distinguish between the two and would
+ // otherwise e.g. with locale "Czech" and language "German" try to
+ // pick a non-existing plural rule, because Czech has 4 plural forms
+ // and German only 2.
+ $this->identityTranslator->setLocale($this->getLanguageCode());
}
return $this->identityTranslator;
@@ -230,7 +215,7 @@ class L10N implements IL10N {
$json = json_decode(file_get_contents($translationFile), true);
if (!\is_array($json)) {
$jsonError = json_last_error();
- \OC::$server->getLogger()->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']);
+ \OCP\Server::get(LoggerInterface::class)->warning("Failed to load $translationFile - json error code: $jsonError", ['app' => 'l10n']);
return false;
}
diff --git a/lib/private/L10N/L10NString.php b/lib/private/L10N/L10NString.php
index 472a80a5b75..a6515e78f24 100644
--- a/lib/private/L10N/L10NString.php
+++ b/lib/private/L10N/L10NString.php
@@ -1,29 +1,9 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Bart Visscher <bartv@thisnet.nl>
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @author Jakob Sack <mail@jakobsack.de>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Jörn Friedrich Dreyer <jfd@butonic.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OC\L10N;
@@ -65,12 +45,12 @@ class L10NString implements \JsonSerializable {
if (is_array($identity)) {
$pipeCheck = implode('', $identity);
- if (strpos($pipeCheck, '|') !== false) {
+ if (str_contains($pipeCheck, '|')) {
return 'Can not use pipe character in translations';
}
$identity = implode('|', $identity);
- } elseif (strpos($identity, '|') !== false) {
+ } elseif (str_contains($identity, '|')) {
return 'Can not use pipe character in translations';
}
diff --git a/lib/private/L10N/LanguageIterator.php b/lib/private/L10N/LanguageIterator.php
index 4a76667caf2..531eea5866b 100644
--- a/lib/private/L10N/LanguageIterator.php
+++ b/lib/private/L10N/LanguageIterator.php
@@ -3,26 +3,8 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2018 Arthur Schiwon <blizzz@arthur-schiwon.de>
- *
- * @author Arthur Schiwon <blizzz@arthur-schiwon.de>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\L10N;
@@ -63,8 +45,8 @@ class LanguageIterator implements ILanguageIterator {
return $forcedLang;
}
$this->next();
- /** @noinspection PhpMissingBreakStatementInspection */
- // no break
+ /** @noinspection PhpMissingBreakStatementInspection */
+ // no break
case 1:
$forcedLang = $this->config->getSystemValue('force_language', false);
if (is_string($forcedLang)
@@ -73,16 +55,16 @@ class LanguageIterator implements ILanguageIterator {
return $truncated;
}
$this->next();
- /** @noinspection PhpMissingBreakStatementInspection */
- // no break
+ /** @noinspection PhpMissingBreakStatementInspection */
+ // no break
case 2:
$userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null);
if (is_string($userLang)) {
return $userLang;
}
$this->next();
- /** @noinspection PhpMissingBreakStatementInspection */
- // no break
+ /** @noinspection PhpMissingBreakStatementInspection */
+ // no break
case 3:
$userLang = $this->config->getUserValue($this->user->getUID(), 'core', 'lang', null);
if (is_string($userLang)
@@ -93,10 +75,10 @@ class LanguageIterator implements ILanguageIterator {
$this->next();
// no break
case 4:
- return $this->config->getSystemValue('default_language', 'en');
- /** @noinspection PhpMissingBreakStatementInspection */
+ return $this->config->getSystemValueString('default_language', 'en');
+ /** @noinspection PhpMissingBreakStatementInspection */
case 5:
- $defaultLang = $this->config->getSystemValue('default_language', 'en');
+ $defaultLang = $this->config->getSystemValueString('default_language', 'en');
if (($truncated = $this->getTruncatedLanguage($defaultLang)) !== $defaultLang) {
return $truncated;
}
diff --git a/lib/private/L10N/LanguageNotFoundException.php b/lib/private/L10N/LanguageNotFoundException.php
index d483fd799dd..087a384e00e 100644
--- a/lib/private/L10N/LanguageNotFoundException.php
+++ b/lib/private/L10N/LanguageNotFoundException.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright Copyright (c) 2016 Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\L10N;
diff --git a/lib/private/L10N/LazyL10N.php b/lib/private/L10N/LazyL10N.php
index f56761799b3..0d72f638632 100644
--- a/lib/private/L10N/LazyL10N.php
+++ b/lib/private/L10N/LazyL10N.php
@@ -3,32 +3,14 @@
declare(strict_types=1);
/**
- * @copyright Copyright (c) 2019, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OC\L10N;
use OCP\IL10N;
class LazyL10N implements IL10N {
-
/** @var IL10N */
private $l;