Repository navigation
Conversation
G_get_units_name() and G_projection_name() return translated text. Using it as data breaks in a translated locale: - G_database_units_to_meters_factor() compared the translated unit name with English names and returned 0 for projects without a conversion factor (e.g. XY), which breaks r.slope.aspect, r.sim.water and v.to.db. - G_units(NULL) and G_get_units_name() parsed the translated name of the database units to get the units code, which gave an unknown unit when the translation was not the English name (e.g. in French). - m.measure, r3.info, r3.out.netcdf and g.region wrote translated names into JSON, shell style output and files. Add G_get_units_name_untranslated(), G_projection_name_untranslated() and G_database_projection_name_untranslated() and use them for such data. Get the database units by code with G_database_unit(). Rast3d_get_vertical_unit() now returns the English name.
The tests check English messages, so many of them fail when run in a translated locale. Set LANGUAGE=C for the tests run with the gunittest invoker and with pytest, where the test files are not run with the invoker.
echoix
commented
Oct 11, 2026
An autotools configure run deletes conftest* files in the source tree, so a root conftest.py cannot hold the setting. Use a session fixture in the conftest.py of each directory with pytest tests instead.
Ruff rule RUF076 does not allow autouse fixtures. Set LANGUAGE when the conftest.py files are imported instead, which happens during collection, before any test runs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the test suite in a translated locale (de_DE, fr_FR, tr_TR) showed that translated text is used as data in several places, and that many tests assert English messages.
Code (libgis and tools)
G_database_units_to_meters_factor()compared the translated unit name with English names and returned 0 for projects without a conversion factor (e.g. XY). In de_DE and fr_FR this gave slope 0 instead of 45 inr.slope.aspect, length 0 inv.geometry, and failures inr.sim.water/r.sim.sediment.G_units(NULL)andG_get_units_name()parsed the translated name of the database units. This gave an unknown unit in French.m.measure(JSON, shell),r3.info(-g, JSON),r3.out.netcdf(value written into the file) andg.region(JSONcrs.name) used translated names.G_get_units_name_untranslated(),G_projection_name_untranslated()andG_database_projection_name_untranslated(); the translated functions are unchanged.Rast3d_get_vertical_unit()now returns the English name.Tests
LANGUAGE=Cis set for gunittest (invoker andtest()) and for pytest (a session fixture in theconftest.pyof each directory with tests; a rootconftest.pywould be deleted by an autotoolsconfigure), because the tests check English messages.Verification
Full gunittest and pytest runs (nc_spm_full_v2beta1, NLS enabled) under
C.UTF-8,de_DE.UTF-8,fr_FR.UTF-8andtr_TR.UTF-8give the same results with these changes: the same 9 failing gunittest files and the same 6 failing pytest tests plus 1 error as the baseline, all unrelated to the locale. Before the changes, 8 (de, fr) and 3 (tr) more gunittest files, and 108 (de), 115 (fr) and 15 (tr) more pytest tests, failed. The full runs were done before the pytest setting moved from a rootconftest.pyto the per-directory ones; the affected pytest files were run again in all four locales after the move.Not covered:
lib/ogsf/gsd_objs.c:1230,1236compares a translated unit name with"meters". It was found by reading and not built or tested here, so it is not changed.Larger use of AI: the investigation, the fixes and this text were prepared with an AI assistant (Claude Code). The
localizeflag inlib/gis/units.cis a mechanical change, with each_("...")literal kept soxgettextstill finds it.