Skip to content

wxGUI: Extract menu strings with an ITS definition - #739

Open
echoix wants to merge 4 commits into
mainfrom
claude/brave-noether-cgh2c0
Open

echoix wants to merge 4 commits into
mainfrom
claude/brave-noether-cgh2c0

Conversation

@echoix

@echoix echoix commented Oct 11, 2026 •

Copy link
Copy Markdown
Owner

Description

Extract the wxGUI menu strings directly from the committed menu XML files with xgettext and an ITS rules file (locale/its/), instead of through the generated gui/wxpython/menustrings.py:

  • Labels, help texts and descriptions of toolboxes.xml, wxgui_items.xml and menudata_{modeler,psmap,pyedit}.xml are extracted. A gt:escapeRule keeps the & of keyboard accelerators.
  • Translator comments are in a type=...; key=value form, built from the XML: for example type=menu-item-label (text of a menu entry); tool=r.mask. A label gets its help text and a help text gets its label.
  • Template references point to committed XML files and lines.
  • The menustrings.py generation is removed from the Autotools and CMake builds, as well as the strings action of core/menutree.py (tree is now its default). The generation of menudata.xml and module_tree_menudata.xml and their installation stay in the default build of both build systems.
  • The console help text in gui_core/goutput.py is wrapped in _().
  • New doc/development/wxgui_menus.md describes how the menus are defined, built and translated.

Motivation and context

The main menu labels (&Raster, &Vector, ...) were missing from locale/templates/grasswxpy.pot, so they could not be translated on Weblate. menustrings.py was left empty when core/menutree.py failed, and make pot only checked that the file exists.

About 50 tool descriptions shown as menu help (label and description joined) are in no template, as before.

How has this been tested?

  • Autotools (Python 3.12 with wxPython): ./configure, make, then the wxGUI under a virtual display. The generated menu XML is installed after a single make and the menus load.
  • CMake: ninja regenerates the menu XML.
  • The pot recipe of locale/Makefile gives a grasswxpy.pot with &Raster, 3D r&aster and the console help text, no &, and a comment on each of the 759 strings from the XML files. make verify passes.
  • With a test German catalog, the menu bar and the console help text are shown translated in the running GUI.

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing
    functionality to not work as before)

Checklist

  • PR title provides summary of the changes and starts with one of the
    pre-defined prefixes
  • My code follows the code style
    of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

Parts of this change were prepared with AI assistance.

@echoix
echoix force-pushed the claude/brave-noether-cgh2c0 branch from f3c71cc to 0996679 Compare October 11, 2026 12:26
@echoix echoix changed the title wxGUI: Generate menu strings reliably for translation wxGUI: Extract menu strings with an ITS definition Oct 11, 2026
@echoix
echoix force-pushed the claude/brave-noether-cgh2c0 branch from 0996679 to 638b1cc Compare October 11, 2026 12:29
@echoix
echoix force-pushed the claude/brave-noether-cgh2c0 branch 3 times, most recently from c36d351 to d612d60 Compare October 11, 2026 12:43
The main menu labels of the wxGUI were missing from the translation
template, because the generated menustrings.py they came from could be
left empty when core/menutree.py failed, and 'make pot' only checked that
the file exists.

Extract the labels, help texts and descriptions of the wxGUI menu
definitions directly from the committed XML files with xgettext and an ITS
rules file instead. The template then points to the XML files and line
numbers in the repository, and no build step has to succeed before
'make pot'.

Add translator comments in a key=value form, with the kind of string as
"type" (menu-title, menu-item-label, menu-item-help) and its paired help
text, label or tool name, built from the XML, so translators can tell, for
example, a verb from a noun.

Remove the menustrings.py generation from the Autotools and CMake builds
accordingly. Translations of module descriptions used as menu items come
from the grassmods domain, which is a fallback of the gettext function.
Mark the console help text as translatable.

Parts of this change were prepared with AI assistance.
@echoix
echoix force-pushed the claude/brave-noether-cgh2c0 branch from d612d60 to b11e738 Compare October 11, 2026 12:46
The action printed the menu strings as _() calls for the generated
menustrings.py, which is no longer generated since the strings are
extracted from the XML files with an ITS definition. Make the tree action
the default one.

Parts of this change were prepared with AI assistance.
Removing the menustrings.py rules also removed what made the builds
generate and install the menudata.xml and module_tree_menudata.xml files:
the CMake build_menustrings target was the only one run by default, and the
Autotools rule had the installed copies as prerequisites. Make the CMake
build_module_tree_menudata target part of the default build, and copy the
generated files into the distribution from the Autotools default target.

Add a description of how the wxGUI menus are defined, built and translated.

Parts of this change were prepared with AI assistance.
…note

Fix the generator of the menu data and the paths of the XML files in the
README files and the toolboxes page, add the files that were missing there,
drop the recommendation of the broken update_menudata.py script and link
the description of the menu build and translation.

Parts of this change were prepared with AI assistance.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants