@@ -238,33 +238,37 @@ async def get_components(
238238@inject
239239def get_component_by_id (
240240 id : str ,
241+ accept_language : str | None = Header (default = None ),
241242 component_registry : ComponentRegistry = Depends (lambda : di ["component_registry" ]),
242243) -> Dict [str , Any ]:
243- """Return an specific component using its id (the id is the component class name).
244+ """Return a specific component using its id (the id is the component class name).
244245
245- Parameters
246- ----------
247- id : str
248- A component identificator
246+ Parameters
247+ ----------
248+ id : str
249+ A component identificator
250+ accept_language : str | None
251+ The 'Accept-Language' header from the request to localize multilingual
252+ strings in the component schema, by default None.
249253 component_registry : ComponentRegistry
250- The current app component registry provided by dependency injection.
254+ The current app component registry provided by dependency injection.
251255
252- Returns
253- -------
254- dict
255- The retrieved component dict.
256+ Returns
257+ -------
258+ dict
259+ The retrieved component dict.
256260
257- Raises
258- ------
259- HTTPException
260- If the id does not exists in the registry.
261+ Raises
262+ ------
263+ HTTPException
264+ If the id does not exists in the registry.
261265 """
262266 if id not in component_registry :
263267 raise HTTPException (
264268 status_code = 404 ,
265269 detail = f"Component { id } not found in the registry." ,
266270 )
267- return _delete_class (component_registry [id ])
271+ return _filter_by_language ( _delete_class (component_registry [id ]), accept_language )
268272
269273
270274@router .post ("/" , status_code = status .HTTP_201_CREATED )
0 commit comments