Repository navigation
Conversation
Capture screenshots of the Layer Manager notebook pages and of each Preferences page, and write a manifest of the grasswxpy messages shown in each screenshot so that they can later be uploaded to Weblate and linked to the source strings as visual context. Visible strings are found without OCR: the translation function is wrapped to map rendered text back to messages (including messages with placeholders), and the widget tree of the captured window is walked to collect the shown text. Messages are keyed by (msgctxt, msgid) so that templates with contexts work as well. The screen is read with ImageMagick because wx.ScreenDC returns stale content with GTK 3. With a fixed project path, two runs give identical images and manifests. Written with the help of Claude Code.
Add weblate_upload.py, which synchronizes the output of wxgui_capture.py to a Weblate component using the REST API of Weblate 5.16.2: screenshots are created on the source language by name, their image is replaced only when the pixels differ, and their links to source strings are added or removed to match the manifest. Only screenshots with the managed name prefix are modified, and --prune deletes those no longer captured. --dry-run prints the planned changes. The API token is read from the WEBLATE_TOKEN environment variable. The tests run the uploader against a fake API server modeling the 5.16.2 responses (hyperlinked units, no id in the creation response, trailing slashes required by the router). They are skipped when requests is not installed. Move both tools from locale/screenshots to utils/weblate_screenshots because a tests directory under locale/ makes pytest's importlib mode shadow the standard library locale module. Written with the help of Claude Code.
|
Is there a way to not tie ourselves too much to the upload or Weblate? Like allowing us to manually do the work? Can there be a zipped artifact upload in the job that updates the translations, which contains the images and the references to the strings , eg, what's needed to link the images? Do you think the screenshots could be usable for documentation purposes? |
Add a reusable workflow which builds GRASS with the GUI, runs wxgui_capture.py under Xvfb, and uploads the PNG files and the manifest of the strings they show as an artifact. This keeps the screenshots usable without Weblate: they can be downloaded and linked by hand, or synchronized with weblate_upload.py. The periodic update workflow calls it, since its update-i18n job builds without the GUI, and it also runs for pull requests changing it or the screenshot tools. Resolve ImageMagick's import tool to a full path and exit with a clear message when it is missing. Written with the help of Claude Code.
Yes. The capture output doesn't depend on Weblate: it's PNG files plus
Added in 79c0438. The new reusable workflow
Partly:
I'd keep the docs use as a possible follow-up once there are more scenarios. Generated by Claude Code |
The grass command exits when GRASS_CONFIG_DIR points to a directory which does not exist.
Match the other reusable workflow calls, which zizmor now checks in pre-commit.
The manifest listed strings which are not visible in the screenshots: tooltips, window titles (drawn by the window manager), labels of icon-only toolbar tools, tabs of notebooks which hide them for a single page, and widgets clipped out of view by their parents. Leave these out and add the visible items of tree widgets, such as the tool tree. Prefer an exact match of the rendered text, so that a "&File" menu does not also match a "File" label used elsewhere. Add the file:line locations of each string from the template, as Weblate shows them, to ease linking strings by hand. Written with the help of Claude Code.
Tooltips are not drawn in screenshots, so give each tool of icon-only toolbars its own copy of the screenshot with the tool framed, linked to its tooltip. AUI toolbars give the position of their tools. wx.ToolBar does not with GTK, so a tool is found by toggling its enabled state and comparing the toolbar before and after. Add a tool-tree scenario capturing each category of the tool tree expanded in turn, page by page, linked only to the items of that category which are entirely in view. Look up text made of parts separated by several spaces part by part, as the tree shows the label of a tool followed by its command. Written with the help of Claude Code.
The endpoints and responses it uses are the same in Weblate 5.16.2 and 2026.10.1.
Description
Prototype for giving translators visual context on Weblate for the grasswxpy domain, without storing images in the repository.
utils/weblate_screenshots/wxgui_capture.pycaptures the Layer Manager notebook pages, each Preferences page, and each category of the tool tree expanded in turn, under Xvfb. It writes PNG files and amanifest.jsonlisting the grasswxpy messages, keyed by(msgctxt, msgid), that are drawn in each screenshot, with their file:line locations from the template as Weblate shows them..github/workflows/wxgui_screenshots.ymlbuilds GRASS with the GUI, runs the capture, and uploads the PNG files and the manifest as thewxgui-screenshotsartifact. Periodic update calls it, and it also runs for pull requests that change it or the tools. The screenshots can then be linked by hand or synchronized with the uploader below.utils/weblate_screenshots/weblate_upload.pysynchronizes that output to a Weblate component through the REST API, using only endpoints that are the same in Weblate 5.16.2 and 2026.10.1:--prunedeletes those that are no longer captured, and--dry-runprints the planned changes.Motivation and context
Weblate shows screenshots next to the strings they are linked to. Generating and linking them automatically keeps them current without binary churn in Git.
How has this been tested?
Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
Written with the help of Claude Code.