Opened 2 months ago
Last modified 6 weeks ago
#8436 new enhancement
Translate: Make locale glossaries available through the GlotPress API
| Reported by: | jeherve | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Translate Site & Plugins | Keywords: | has-patch |
| Cc: |
Description
I'm working on a project to help AI agents offer translations that respect a language's glossary. For that to work, they need to fetch the glossary for a locale (like https://translate.wordpress.org/locale/fr/default/glossary/) without scraping the page regularly to keep a local copy up to date.
I opened https://github.com/GlotPress/GlotPress/pull/2119 to add JSON glossary responses to GlotPress's API, with ?term= to look up a single term, and ?extended=1 to get the glossary the translation editor uses for a project (the project glossary merged with the locale glossary). The original discussion is in https://github.com/GlotPress/GlotPress/issues/2118.
Once translate.wordpress.org runs a GlotPress version with that change, project glossaries will work without anything else, for example:
https://translate.wordpress.org/api/projects/wp-plugins/akismet/stable/fr/default/glossary/?extended=1&term=plugin
Locale glossaries won't, though. wporg-gp-routes moves them from /languages/ to /locale/, but it only registers the /locale/.../glossary routes for regular requests, not for API requests. Today, https://translate.wordpress.org/api/locale/fr/default/glossary/ returns a 404 page.
I'm wondering if we could register the glossary route for API requests too, so that this works:
https://translate.wordpress.org/api/locale/fr/default/glossary/?term=plugin
Only the read-only route would be added; adding, editing, and importing entries would stay as they are.
This depends on GlotPress/GlotPress#2119. Until translate.wordpress.org runs a GlotPress version that includes it, that URL would return an empty JSON response instead of a 404, so the patch shouldn't be committed before then.
I have a patch ready, which I tested in the translate local environment against the GlotPress PR. I'll open a PR on the GitHub mirror once this ticket exists, so it gets linked here :)
Currently, we are quite restrictive when it comes to automatic translations. They can be helpful, but this should first be discussed with the Polyglots.
@tobifjellner Can you mentors/reps please have a look here.