diff --git a/lib/private/Share20/ProviderFactory.php b/lib/private/Share20/ProviderFactory.php index e680a82c4aae8..fde63a4c3949e 100644 --- a/lib/private/Share20/ProviderFactory.php +++ b/lib/private/Share20/ProviderFactory.php @@ -22,6 +22,7 @@ use OCP\Files\IRootFolder; use OCP\Http\Client\IClientService; use OCP\IServerContainer; +use OCP\L10N\IFactory; use OCP\Mail\IMailer; use OCP\Security\IHasher; use OCP\Share\IManager; @@ -82,7 +83,7 @@ protected function defaultShareProvider() { $this->serverContainer->get(IRootFolder::class), $this->serverContainer->get(IMailer::class), $this->serverContainer->query(Defaults::class), - $this->serverContainer->getL10NFactory(), + $this->serverContainer->get(IFactory::class), $this->serverContainer->getURLGenerator(), $this->serverContainer->query(ITimeFactory::class), ); diff --git a/lib/private/TemplateLayout.php b/lib/private/TemplateLayout.php index 0ff56ece6356c..2e688f161bbc1 100644 --- a/lib/private/TemplateLayout.php +++ b/lib/private/TemplateLayout.php @@ -20,6 +20,7 @@ use OCP\INavigationManager; use OCP\IURLGenerator; use OCP\IUserSession; +use OCP\L10N\IFactory; use OCP\Support\Subscription\IRegistry; use OCP\Util; @@ -97,7 +98,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 @@ -189,8 +190,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); diff --git a/lib/private/legacy/OC_Util.php b/lib/private/legacy/OC_Util.php index 4b89b01469a46..14918dfe89ad8 100644 --- a/lib/private/legacy/OC_Util.php +++ b/lib/private/legacy/OC_Util.php @@ -14,6 +14,7 @@ use OCP\IGroupManager; use OCP\IURLGenerator; use OCP\IUser; +use OCP\L10N\IFactory; use OCP\Share\IManager; use Psr\Log\LoggerInterface; @@ -127,7 +128,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)) { @@ -347,7 +348,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"; diff --git a/lib/public/Util.php b/lib/public/Util.php index 885e2facc53ee..179d4066c9b9b 100644 --- a/lib/public/Util.php +++ b/lib/public/Util.php @@ -13,6 +13,7 @@ use bantu\IniGetWrapper\IniGetWrapper; use OC\AppScriptDependency; use OC\AppScriptSort; +use OCP\L10N\IFactory; use OCP\Mail\IMailer; use OCP\Share\IManager; use Psr\Container\ContainerExceptionInterface; @@ -207,7 +208,7 @@ public static function getScripts(): array { */ public static function addTranslations($application, $languageCode = null, $init = 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"; diff --git a/tests/lib/L10N/L10nTest.php b/tests/lib/L10N/L10nTest.php index 9a6d119330bac..38d0a5626b0f7 100644 --- a/tests/lib/L10N/L10nTest.php +++ b/tests/lib/L10N/L10nTest.php @@ -15,6 +15,7 @@ use OCP\IConfig; use OCP\IRequest; use OCP\IUserSession; +use OCP\L10N\IFactory; use Test\TestCase; /** @@ -219,7 +220,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) ); }