API REST: filtro por idioma en /wp/v2/animals (?lang=es|eu)

- Polylang gratuito no filtra la API REST por idioma: el parámetro «lang» se pasa a la consulta.
- MCP: list_animals descarta además las fichas de otro idioma (funciona aunque WordPress aún no
  esté actualizado).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-25 23:03:55 +02:00
parent 3e7bc4dbc6
commit 83d1298dda
2 changed files with 11 additions and 1 deletions

View File

@@ -74,7 +74,7 @@ export function createBilagunServer({ api, publicUrl, remote = false }) {
params.set('status', includeDrafts ? 'publish,draft,pending' : 'publish');
if (search) params.set('search', search);
if (species) params.set('species', String(await speciesId(species, language)));
let animals = (await api(`/wp/v2/animals?${params}`)).map(summary);
let animals = (await api(`/wp/v2/animals?${params}`)).map(summary).filter((a) => a.language === language);
if (status) animals = animals.filter((a) => a.profile?.status === status);
return animals.map(({ id, name, wpStatus, profile, translationOf }) => ({ id, name, wpStatus, status: profile?.status, featured: profile?.featured, age: profile?.labels?.age, translationOf }));
}));