Skip to content

i18n: Use complete source strings instead of fragments (Python) - #8011

Merged
echoix merged 11 commits into
OSGeo:mainfrom
echoix:i18n-complete-source-strings-python
Oct 10, 2026
Merged

echoix merged 11 commits into
OSGeo:mainfrom
echoix:i18n-complete-source-strings-python

Conversation

@echoix

@echoix echoix commented Oct 4, 2026

Copy link
Copy Markdown
Member

This is a first start of fixing issues that I noted in comments in Weblate, for python files.

Description

Some messages were built from separately translated fragments, or from a runtime string passed to gettext, so translators cannot adapt word order or punctuation. These were flagged by comments on Weblate. This PR replaces them with complete format strings in the Python tools and the wxGUI; the C code is in a separate PR.

  • r.reclass.area: complete messages, one per combination of thresholds.
  • r.in.wms, v.what.strds, v.rast.stats, r.in.srtm, m.proj: error and status messages are single strings (no trailing-space fragments).
  • Temporal framework (core.py, temporal_algebra.py): the mapset error and the wrong-input error were built before being passed to gettext, so they were never translated.
  • wxGUI: render status bar, scatterplot title and axis labels, database table tab labels, GCP overwrite question, toolbar "Set map canvas for ... / Zoom to map" tooltips, parameter-dialog status text, mapset/type selector labels, model condition, layer group, psmap labels and distance measuring log are complete strings.
  • wxGUI RLi sample area title was _("Select sample area 1 of " + str(n)); it now uses the same msgid as the update just above it.
  • wxGUI tplot: the CSV error message ended in "or " with nothing after it. It now reads "Please change name of output CSV file or enable overwriting." Please check the wording matches the intent.
  • wxGUI preferences: removed the trailing space in "Random colors according to category number".

Motivation and context

Translators on Weblate reported that these messages cannot be translated correctly with a different word order.

How has this been tested?

ruff format and ruff check report no changes; the modified files compile.

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.

AI assistance (Claude) was used to find the affected strings and to draft these changes.

@echoix
echoix requested a review from ninsbl October 4, 2026 15:07
@github-actions github-actions Bot added GUI wxGUI related vector Related to vector data processing raster Related to raster data processing temporal Related to temporal data processing Python Related code is in Python libraries module misc labels Oct 4, 2026
echoix and others added 5 commits October 4, 2026 11:07
The verbose and fatal messages were assembled from fragments such as ' larger than or equal to %f hectares...', which translators cannot reorder. Use one complete string for each combination of thresholds.
The reason was appended to a translated string ending in 'Reason: '.
Cover the render status bar, scatterplot title and axis labels, RLi sample area title (previously a runtime string passed to gettext, so never translated), database table tab labels, GCP overwrite question, and two incomplete or trailing-space messages.
Replace messages assembled from translated fragments or passed to
gettext as already-built strings with complete format strings, in the
temporal framework, wxGUI toolbars, selectors and logs, and several
scripts. Also drop trailing spaces from a few messages.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@echoix
echoix force-pushed the i18n-complete-source-strings-python branch from f25496f to 9705e3b Compare October 4, 2026 15:07
@echoix echoix changed the title i18n: Use complete source strings instead of fragments (Python)I i18n: Use complete source strings instead of fragments (Python) Oct 6, 2026
@echoix
echoix requested a review from petrasovaa October 9, 2026 15:05
…eConnection

Co-authored-by: Edouard Choinière <27212526+echoix@users.noreply.github.com>
Applying the review suggestions for the mogrify and transaction mapset
errors kept the old fatal() calls unclosed before the new ones, which
made core.py fail to compile.
@echoix
echoix force-pushed the i18n-complete-source-strings-python branch from be2276f to d265a24 Compare October 10, 2026 13:38
@echoix
echoix force-pushed the i18n-complete-source-strings-python branch from 76a09d2 to f16b010 Compare October 10, 2026 13:46
@echoix

echoix commented Oct 10, 2026 •

Copy link
Copy Markdown
Member Author

Sorry for the noise. On a fresh mind, I relooked at the PR. I fine tuned some little extra messages that weren't in the initial PR, but that had similar messages than the ones that were changed in this PR, such as all of the similar messages are fixed in the same way.

Ai reviewed the different branches of r.reclass.area, where now the message isn't built by parts. See the table in the full output of the last review I made it do, even if it's worded for me, the table is still fine and cross-verifies the work:

Details

CI is still running on the new head. I'm checking the r.reclass.area message branches for each threshold combination.

I updated my local copy to your new head, f16b010; your latest commit there names the placeholder {pixel_count}. Then I reviewed the whole PR again against main (9c7baf5): 11 commits, 29 files. I found no correctness problems.

What changed since my last review is only in python/grass/temporal/core.py and scripts/r.reclass.area/r.reclass.area.py. The other 27 files are the same as when I first reviewed them.

  • core.py: all six Unable to … {reason} messages are now complete strings. _create_mapset_error_message() is translated too, so the whole error can be translated. No call site still builds a msgid at runtime.

  • r.reclass.area: I ran the threshold branching from the file under seven input combinations. In each case the message matches the range actually applied:

    lower, upper Message Range applied
    1, 5 ≥ 1.0 and ≤ 5.0 hectares 1 to 5
    1, none ≥ 1.0 hectares 1 to ∞
    none, 5 ≤ 5.0 hectares −∞ to 5
    0, none "without area size limits" −∞ to ∞
    0, 5 ≤ 5.0 hectares −∞ to 5
    2, 0 ≥ 2.0 hectares 2 to ∞
    0.00001, none ≥ 1e-05 hectares 0.00001 to ∞

    The "None" case is gone, and upper=0 correctly counts as no upper limit.

  • Both files parse and pass ruff check and ruff format --check.

I didn't build GRASS, so I didn't run the tool or its testsuite/. CI on f16b010 is still running: two checks have passed and 17 are queued or in progress.

Nits (all optional):

  1. Very small thresholds print in scientific notation. A value like 0.00001 hectares now prints as 1e-05; the old code printed 0.000010. Values that small are unlikely, so I'd leave it.
  2. Commit history. This only matters if the PR isn't squash-merged:
    • Four commits have no category prefix: e24da30, 5e1fdee, 53a4b7c and f16b010.
    • 1f55ab1 still has a Co-Authored-By: Claude trailer, which AGENTS.md asks to avoid.
    • e24da30 lists you as your own co-author. GitHub adds that trailer when you commit a suggestion.
    • Five commits are unsigned: 397ec0a, 4067a2c, 5d5fbba, 1f55ab1 and 9705e3b. Your d265a24 and f16b010 are also unsigned.
  3. PR description. "How has this been tested?" still says only ruff and compiling. You could mention that the r.reclass.area messages were checked against each threshold combination. The core.py bullet could also say that the mapset-access reason is now translated.

I haven't posted any of this to the PR.

@echoix

echoix commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

@ninsbl can you take a look here? Just to validate that I didn't miss something big (and AI either), I think it's fine

@ninsbl ninsbl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@echoix
echoix merged commit 8f75061 into OSGeo:main Oct 10, 2026
26 checks passed
@github-actions github-actions Bot added this to the 8.6.0 milestone Oct 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

GUI wxGUI related libraries misc module Python Related code is in Python raster Related to raster data processing temporal Related to temporal data processing vector Related to vector data processing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants