Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor OC\Server::getL10NFactory #40141

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
use OCP\Defaults;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\L10N\IFactory;
use OCP\Share\IManager;
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
Expand Down Expand Up @@ -102,7 +103,7 @@ protected function defaultShareProvider() {
$this->serverContainer->getLazyRootFolder(),
$this->serverContainer->getMailer(),
$this->serverContainer->query(Defaults::class),
$this->serverContainer->getL10NFactory(),
$this->serverContainer->get(IFactory::class),
$this->serverContainer->getURLGenerator(),
$this->serverContainer->getConfig()
);
Expand Down
7 changes: 4 additions & 3 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
use OCP\IInitialStateService;
use OCP\INavigationManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\Support\Subscription\IRegistry;
use OCP\Util;

Expand Down Expand Up @@ -126,7 +127,7 @@ public function __construct($renderAs, $appId = '') {
// Set default app name
$defaultApp = \OC::$server->getAppManager()->getDefaultAppForUser();
$defaultAppInfo = \OC::$server->getAppManager()->getAppInfo($defaultApp);
$l10n = \OC::$server->getL10NFactory()->get($defaultApp);
$l10n = \OC::$server->get(IFactory::class)->get($defaultApp);
$this->assign('defaultAppName', $l10n->t($defaultAppInfo['name']));

// Add navigation entry
Expand Down Expand Up @@ -200,8 +201,8 @@ public function __construct($renderAs, $appId = '') {
parent::__construct('core', 'layout.base');
}
// Send the language and the locale to our layouts
$lang = \OC::$server->getL10NFactory()->findLanguage();
$locale = \OC::$server->getL10NFactory()->findLocale($lang);
$lang = \OC::$server->get(IFactory::class)->findLanguage();
$locale = \OC::$server->get(IFactory::class)->findLocale($lang);

$lang = str_replace('_', '-', $lang);
$this->assign('language', $lang);
Expand Down
5 changes: 3 additions & 2 deletions lib/private/legacy/OC_Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
use OCP\IGroupManager;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\L10N\IFactory;
use OCP\Share\IManager;
use Psr\Log\LoggerInterface;

Expand Down Expand Up @@ -184,7 +185,7 @@ public static function copySkeleton($userId, \OCP\Files\Folder $userDirectory) {
$logger = \OC::$server->get(LoggerInterface::class);

$plainSkeletonDirectory = \OC::$server->getConfig()->getSystemValueString('skeletondirectory', \OC::$SERVERROOT . '/core/skeleton');
$userLang = \OC::$server->getL10NFactory()->findLanguage();
$userLang = \OC::$server->get(IFactory::class)->findLanguage();
$skeletonDirectory = str_replace('{lang}', $userLang, $plainSkeletonDirectory);

if (!file_exists($skeletonDirectory)) {
Expand Down Expand Up @@ -403,7 +404,7 @@ public static function addVendorScript($application, $file = null, $prepend = fa
*/
public static function addTranslations($application, $languageCode = null, $prepend = false) {
if (is_null($languageCode)) {
$languageCode = \OC::$server->getL10NFactory()->findLanguage($application);
$languageCode = \OC::$server->get(IFactory::class)->findLanguage($application);
}
if (!empty($application)) {
$path = "$application/l10n/$languageCode";
Expand Down
3 changes: 2 additions & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

use OC\AppScriptDependency;
use OC\AppScriptSort;
use OCP\L10N\IFactory;
use bantu\IniGetWrapper\IniGetWrapper;
use Psr\Container\ContainerExceptionInterface;

Expand Down Expand Up @@ -235,7 +236,7 @@ public static function getScripts(): array {
*/
public static function addTranslations($application, $languageCode = null) {
if (is_null($languageCode)) {
$languageCode = \OC::$server->getL10NFactory()->findLanguage($application);
$languageCode = \OC::$server->get(IFactory::class)->findLanguage($application);
}
if (!empty($application)) {
$path = "$application/l10n/$languageCode";
Expand Down
3 changes: 2 additions & 1 deletion tests/lib/L10N/L10nTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use Test\TestCase;

/**
Expand Down Expand Up @@ -218,7 +219,7 @@ public function testWeekdayName() {
public function testFindLanguageFromLocale($locale, $language) {
$this->assertEquals(
$language,
\OC::$server->getL10NFactory()->findLanguageFromLocale('lib', $locale)
\OC::$server->get(IFactory::class)->findLanguageFromLocale('lib', $locale)
);
}

Expand Down