Skip to content

Commit 240f9ed

Browse files
nickvergessenbackportbot[bot]
authored andcommitted
Fix translated app details
Signed-off-by: Joas Schilling <coding@schilljs.com>
1 parent e229cd3 commit 240f9ed

4 files changed

Lines changed: 30 additions & 19 deletions

File tree

apps/updatenotification/lib/Controller/APIController.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
use OCP\AppFramework\OCSController;
3636
use OCP\IConfig;
3737
use OCP\IRequest;
38+
use OCP\IUserSession;
39+
use OCP\L10N\IFactory;
3840

3941
class APIController extends OCSController {
4042

@@ -47,23 +49,29 @@ class APIController extends OCSController {
4749
/** @var AppFetcher */
4850
protected $appFetcher;
4951

50-
/**
51-
* @param string $appName
52-
* @param IRequest $request
53-
* @param IConfig $config
54-
* @param IAppManager $appManager
55-
* @param AppFetcher $appFetcher
56-
*/
57-
public function __construct($appName,
52+
/** @var IFactory */
53+
protected $l10nFactory;
54+
55+
/** @var IUserSession */
56+
protected $userSession;
57+
58+
/** @var string */
59+
protected $language;
60+
61+
public function __construct(string $appName,
5862
IRequest $request,
5963
IConfig $config,
6064
IAppManager $appManager,
61-
AppFetcher $appFetcher) {
65+
AppFetcher $appFetcher,
66+
IFactory $l10nFactory,
67+
IUserSession $userSession) {
6268
parent::__construct($appName, $request);
6369

6470
$this->config = $config;
6571
$this->appManager = $appManager;
6672
$this->appFetcher = $appFetcher;
73+
$this->l10nFactory = $l10nFactory;
74+
$this->userSession = $userSession;
6775
}
6876

6977
/**
@@ -98,7 +106,7 @@ public function getAppList(string $newVersion): DataResponse {
98106
$this->appFetcher->setVersion($newVersion, 'future-apps.json', false);
99107

100108
// Apps available on the app store for that version
101-
$availableApps = array_map(function (array $app) {
109+
$availableApps = array_map(static function (array $app) {
102110
return $app['id'];
103111
}, $this->appFetcher->get());
104112

@@ -109,6 +117,8 @@ public function getAppList(string $newVersion): DataResponse {
109117
], Http::STATUS_NOT_FOUND);
110118
}
111119

120+
$this->language = $this->l10nFactory->getUserLanguage($this->userSession->getUser());
121+
112122
$missing = array_diff($installedApps, $availableApps);
113123
$missing = array_map([$this, 'getAppDetails'], $missing);
114124
sort($missing);
@@ -129,8 +139,8 @@ public function getAppList(string $newVersion): DataResponse {
129139
* @param string $appId
130140
* @return string[]
131141
*/
132-
protected function getAppDetails($appId): array {
133-
$app = $this->appManager->getAppInfo($appId);
142+
protected function getAppDetails(string $appId): array {
143+
$app = $this->appManager->getAppInfo($appId, false, $this->language);
134144
return [
135145
'appId' => $appId,
136146
'appName' => $app['name'] ?? $appId,

apps/updatenotification/lib/Notification/Notifier.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ public function prepare(INotification $notification, string $languageCode): INot
135135
$notification->setLink($this->url->linkToRouteAbsolute('settings.AdminSettings.index', ['section' => 'overview']) . '#version');
136136
}
137137
} else {
138-
$appInfo = $this->getAppInfo($notification->getObjectType());
138+
$appInfo = $this->getAppInfo($notification->getObjectType(), $languageCode);
139139
$appName = ($appInfo === null) ? $notification->getObjectType() : $appInfo['name'];
140140

141141
if (isset($this->appVersions[$notification->getObjectType()])) {
@@ -195,7 +195,7 @@ protected function getAppVersions(): array {
195195
return \OC_App::getAppVersions();
196196
}
197197

198-
protected function getAppInfo($appId) {
199-
return \OC_App::getAppInfo($appId);
198+
protected function getAppInfo($appId, $languageCode) {
199+
return \OC_App::getAppInfo($appId, false, $languageCode);
200200
}
201201
}

lib/private/Installer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public function installApp(string $appId, bool $forceEnable = false): string {
117117
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);
118118

119119
$l = \OC::$server->getL10N('core');
120+
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true, $l->getLanguageCode());
120121

121122
if (!is_array($info)) {
122123
throw new \Exception(
@@ -171,8 +172,7 @@ public function installApp(string $appId, bool $forceEnable = false): string {
171172
//run appinfo/install.php
172173
self::includeAppScript($basedir . '/appinfo/install.php');
173174

174-
$appData = OC_App::getAppInfo($appId);
175-
OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
175+
OC_App::executeRepairSteps($appId, $info['repair-steps']['install']);
176176

177177
//set the installed version
178178
\OC::$server->getConfig()->setAppValue($info['id'], 'installed_version', OC_App::getAppVersion($info['id'], false));

lib/private/legacy/OC_App.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,13 +980,14 @@ public static function updateApp(string $appId): bool {
980980
}
981981

982982
\OC::$server->getAppManager()->clearAppsCache();
983-
$appData = self::getAppInfo($appId);
983+
$l = \OC::$server->getL10N('core');
984+
$appData = self::getAppInfo($appId, false, $l->getLanguageCode());
984985

985986
$ignoreMaxApps = \OC::$server->getConfig()->getSystemValue('app_install_overwrite', []);
986987
$ignoreMax = in_array($appId, $ignoreMaxApps, true);
987988
\OC_App::checkAppDependencies(
988989
\OC::$server->getConfig(),
989-
\OC::$server->getL10N('core'),
990+
$l,
990991
$appData,
991992
$ignoreMax
992993
);

0 commit comments

Comments
 (0)