1919use OCP \AppFramework \Http \Attribute \NoAdminRequired ;
2020use OCP \AppFramework \Http \DataResponse ;
2121use OCP \AppFramework \OCSController ;
22+ use OCP \IL10N ;
2223use OCP \IRequest ;
2324
2425/**
@@ -32,6 +33,7 @@ public function __construct(
3233 private FieldDefinitionService $ fieldDefinitionService ,
3334 private FieldValueService $ fieldValueService ,
3435 private FieldAccessService $ fieldAccessService ,
36+ private IL10N $ l10n ,
3537 private ?string $ userId ,
3638 ) {
3739 parent ::__construct (Application::APP_ID , $ request );
@@ -52,7 +54,7 @@ public function __construct(
5254 #[ApiRoute(verb: 'GET ' , url: '/api/v1/me/values ' )]
5355 public function index (): DataResponse {
5456 if ($ this ->userId === null ) {
55- return new DataResponse (['message ' => 'Authenticated user is required ' ], 401 );
57+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated user is required ' ) ], 401 );
5658 }
5759
5860 $ definitions = $ this ->fieldDefinitionService ->findActiveOrdered ();
@@ -113,20 +115,20 @@ public function upsert(
113115 ?string $ currentVisibility = null ,
114116 ): DataResponse {
115117 if ($ this ->userId === null ) {
116- return new DataResponse (['message ' => 'Authenticated user is required ' ], 401 );
118+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated user is required ' ) ], 401 );
117119 }
118120
119121 $ definition = $ this ->fieldDefinitionService ->findById ($ fieldDefinitionId );
120122 if ($ definition === null || !$ definition ->getActive ()) {
121- return new DataResponse (['message ' => 'Field definition not found ' ], 404 );
123+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field definition not found ' ) ], 404 );
122124 }
123125
124126 if (!$ this ->fieldAccessService ->canEditValue ($ this ->userId , $ this ->userId , $ definition , false )) {
125- return new DataResponse (['message ' => 'Field cannot be edited by the user ' ], 403 );
127+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field cannot be edited by the user ' ) ], 403 );
126128 }
127129
128130 if ($ currentVisibility !== null && !$ this ->fieldAccessService ->canChangeVisibility ($ this ->userId , $ this ->userId , false )) {
129- return new DataResponse (['message ' => 'Field visibility cannot be changed by the user ' ], 403 );
131+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field visibility cannot be changed by the user ' ) ], 403 );
130132 }
131133
132134 try {
@@ -160,20 +162,20 @@ public function updateVisibility(
160162 string $ currentVisibility ,
161163 ): DataResponse {
162164 if ($ this ->userId === null ) {
163- return new DataResponse (['message ' => 'Authenticated user is required ' ], 401 );
165+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Authenticated user is required ' ) ], 401 );
164166 }
165167
166168 $ definition = $ this ->fieldDefinitionService ->findById ($ fieldDefinitionId );
167169 if ($ definition === null || !$ definition ->getActive ()) {
168- return new DataResponse (['message ' => 'Field definition not found ' ], 404 );
170+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field definition not found ' ) ], 404 );
169171 }
170172
171173 if (!$ this ->fieldAccessService ->canEditValue ($ this ->userId , $ this ->userId , $ definition , false )) {
172- return new DataResponse (['message ' => 'Field cannot be edited by the user ' ], 403 );
174+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field cannot be edited by the user ' ) ], 403 );
173175 }
174176
175177 if (!$ this ->fieldAccessService ->canChangeVisibility ($ this ->userId , $ this ->userId , false )) {
176- return new DataResponse (['message ' => 'Field visibility cannot be changed by the user ' ], 403 );
178+ return new DataResponse (['message ' => $ this -> l10n -> t ( 'Field visibility cannot be changed by the user ' ) ], 403 );
177179 }
178180
179181 try {
0 commit comments