3434use OCP \AppFramework \OCSController ;
3535use OCP \IConfig ;
3636use OCP \IRequest ;
37+ use OCP \IUserSession ;
38+ use OCP \L10N \IFactory ;
3739
3840class 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 ,
0 commit comments