Skip to content

Commit 31cdcf6

Browse files
Merge pull request #29207 from nextcloud/backport/29004/stable22
[stable22] Fix translated app details
2 parents 164d118 + 982f956 commit 31cdcf6

File tree

5 files changed

+31
-22
lines changed

5 files changed

+31
-22
lines changed

apps/theming/lib/Controller/ThemingController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ public function getManifest($app) {
378378
$startUrl = $this->urlGenerator->getBaseUrl();
379379
$description = $this->themingDefaults->getSlogan();
380380
} else {
381-
$info = $this->appManager->getAppInfo($app);
381+
$info = $this->appManager->getAppInfo($app, false, $this->l10n->getLanguageCode());
382382
$name = $info['name'] . ' - ' . $this->themingDefaults->getName();
383383
$shortName = $info['name'];
384384
if (strpos($this->request->getRequestUri(), '/index.php/') !== false) {

apps/updatenotification/lib/Controller/APIController.php

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

3840
class APIController extends OCSController {
3941

@@ -46,23 +48,29 @@ class APIController extends OCSController {
4648
/** @var AppFetcher */
4749
protected $appFetcher;
4850

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

6369
$this->config = $config;
6470
$this->appManager = $appManager;
6571
$this->appFetcher = $appFetcher;
72+
$this->l10nFactory = $l10nFactory;
73+
$this->userSession = $userSession;
6674
}
6775

6876
/**
@@ -97,7 +105,7 @@ public function getAppList(string $newVersion): DataResponse {
97105
$this->appFetcher->setVersion($newVersion, 'future-apps.json', false);
98106

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

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

119+
$this->language = $this->l10nFactory->getUserLanguage($this->userSession->getUser());
120+
111121
$missing = array_diff($installedApps, $availableApps);
112122
$missing = array_map([$this, 'getAppDetails'], $missing);
113123
sort($missing);
@@ -128,8 +138,8 @@ public function getAppList(string $newVersion): DataResponse {
128138
* @param string $appId
129139
* @return string[]
130140
*/
131-
protected function getAppDetails($appId): array {
132-
$app = $this->appManager->getAppInfo($appId);
141+
protected function getAppDetails(string $appId): array {
142+
$app = $this->appManager->getAppInfo($appId, false, $this->language);
133143
return [
134144
'appId' => $appId,
135145
'appName' => $app['name'] ?? $appId,

apps/updatenotification/lib/Notification/Notifier.php

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

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

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

lib/private/Installer.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,8 @@ public function installApp(string $appId, bool $forceEnable = false): string {
112112
throw new \Exception('The appinfo/database.xml file is not longer supported. Used in ' . $appId);
113113
}
114114

115-
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true);
116-
117115
$l = \OC::$server->getL10N('core');
116+
$info = OC_App::getAppInfo($basedir.'/appinfo/info.xml', true, $l->getLanguageCode());
118117

119118
if (!is_array($info)) {
120119
throw new \Exception(
@@ -162,8 +161,7 @@ public function installApp(string $appId, bool $forceEnable = false): string {
162161
//run appinfo/install.php
163162
self::includeAppScript($basedir . '/appinfo/install.php');
164163

165-
$appData = OC_App::getAppInfo($appId);
166-
OC_App::executeRepairSteps($appId, $appData['repair-steps']['install']);
164+
OC_App::executeRepairSteps($appId, $info['repair-steps']['install']);
167165

168166
//set the installed version
169167
\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
@@ -981,13 +981,14 @@ public static function updateApp(string $appId): bool {
981981
}
982982

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

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

0 commit comments

Comments
 (0)