1919use OCP \AppFramework \Http \Attribute \ApiRoute ;
2020use OCP \AppFramework \Http \DataResponse ;
2121use OCP \AppFramework \OCSController ;
22+ use OCP \IL10N ;
2223use OCP \IRequest ;
2324use OCP \IUser ;
2425use OCP \IUserManager ;
@@ -35,6 +36,7 @@ public function __construct(
3536 private FieldDefinitionService $ fieldDefinitionService ,
3637 private FieldValueService $ fieldValueService ,
3738 private IUserManager $ userManager ,
39+ private IL10N $ l10n ,
3840 private ?string $ userId ,
3941 ) {
4042 parent ::__construct (Application::APP_ID , $ request );
@@ -82,12 +84,12 @@ public function upsert(
8284 ?string $ currentVisibility = null ,
8385 ): DataResponse {
8486 if ($ this ->userId === null ) {
85- return new DataResponse (['message ' => 'Authenticated admin user is required ' ], Http::STATUS_UNAUTHORIZED );
87+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated admin user is required ' ) ], Http::STATUS_UNAUTHORIZED );
8688 }
8789
8890 $ definition = $ this ->fieldDefinitionService ->findById ($ fieldDefinitionId );
8991 if ($ definition === null || !$ definition ->getActive ()) {
90- return new DataResponse (['message ' => 'Field definition not found ' ], Http::STATUS_NOT_FOUND );
92+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field definition not found ' ) ], Http::STATUS_NOT_FOUND );
9193 }
9294
9395 try {
@@ -122,12 +124,12 @@ public function lookup(
122124 array |string |int |float |bool |null $ fieldValue = null ,
123125 ): DataResponse {
124126 if ($ this ->userId === null ) {
125- return new DataResponse (['message ' => 'Authenticated admin user is required ' ], Http::STATUS_UNAUTHORIZED );
127+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated admin user is required ' ) ], Http::STATUS_UNAUTHORIZED );
126128 }
127129
128130 $ definition = $ this ->fieldDefinitionService ->findByFieldKey ($ fieldKey );
129131 if ($ definition === null || !$ definition ->getActive ()) {
130- return new DataResponse (['message ' => 'Lookup field definition not found ' ], Http::STATUS_NOT_FOUND );
132+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Lookup field definition not found ' ) ], Http::STATUS_NOT_FOUND );
131133 }
132134
133135 try {
@@ -137,11 +139,11 @@ public function lookup(
137139 }
138140
139141 if ($ matches === []) {
140- return new DataResponse (['message ' => 'User not found for lookup field value ' ], Http::STATUS_NOT_FOUND );
142+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'User not found for lookup field value ' ) ], Http::STATUS_NOT_FOUND );
141143 }
142144
143145 if (count ($ matches ) > 1 ) {
144- return new DataResponse (['message ' => 'Multiple users match the lookup field value ' ], Http::STATUS_CONFLICT );
146+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Multiple users match the lookup field value ' ) ], Http::STATUS_CONFLICT );
145147 }
146148
147149 return new DataResponse ($ this ->serializeLookupResult ($ definition , $ matches [0 ]), Http::STATUS_OK );
@@ -174,12 +176,12 @@ public function search(
174176 int $ offset = 0 ,
175177 ): DataResponse {
176178 if ($ this ->userId === null ) {
177- return new DataResponse (['message ' => 'Authenticated admin user is required ' ], Http::STATUS_UNAUTHORIZED );
179+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated admin user is required ' ) ], Http::STATUS_UNAUTHORIZED );
178180 }
179181
180182 $ definition = $ this ->fieldDefinitionService ->findByFieldKey ($ fieldKey );
181183 if ($ definition === null || !$ definition ->getActive ()) {
182- return new DataResponse (['message ' => 'Search field definition not found ' ], Http::STATUS_NOT_FOUND );
184+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Search field definition not found ' ) ], Http::STATUS_NOT_FOUND );
183185 }
184186
185187 try {
0 commit comments