Skip to content

Commit

Permalink
Merge pull request #40141 from summersab/refactor/OC-Server-getL10NFa…
Browse files Browse the repository at this point in the history
…ctory
  • Loading branch information
skjnldsv authored May 30, 2024
2 parents dee0eb2 + 4d9199f commit 5866e49
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
3 changes: 2 additions & 1 deletion lib/private/Share20/ProviderFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
);
Expand Down
7 changes: 4 additions & 3 deletions lib/private/TemplateLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
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 @@ -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;

Expand Down Expand Up @@ -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)) {
Expand Down Expand Up @@ -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";
Expand Down
3 changes: 2 additions & 1 deletion lib/public/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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";
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 @@ -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)
);
}

Expand Down

0 comments on commit 5866e49

Please sign in to comment.