From 704a486bfbb14c39e7ed2d631db42610a5ec9014 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:31:36 +0000 Subject: [PATCH 1/4] i18n: Replace strings constructed by parts with complete strings --- db/db.select/main.c | 2 +- imagery/i.landsat.toar/main.c | 9 +++++---- imagery/i.segment/region_growing.c | 4 ++-- lib/pngdriver/graph_set.c | 4 ++-- lib/psdriver/graph_set.c | 4 ++-- vector/v.generalize/main.c | 10 ++++++---- vector/v.in.ogr/main.c | 8 +++++--- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/db/db.select/main.c b/db/db.select/main.c index 3ce0163ea58..3ecd50de39b 100644 --- a/db/db.select/main.c +++ b/db/db.select/main.c @@ -101,7 +101,7 @@ int main(int argc, char **argv) } if (parms.test_only) - G_verbose_message(_("Test %s."), stat ? _("failed") : _("succeeded")); + G_verbose_message(stat ? _("Test failed.") : _("Test succeeded.")); db_close_database(driver); db_shutdown_driver(driver); diff --git a/imagery/i.landsat.toar/main.c b/imagery/i.landsat.toar/main.c index 36cfcf5f3d0..2516e97ed33 100644 --- a/imagery/i.landsat.toar/main.c +++ b/imagery/i.landsat.toar/main.c @@ -572,10 +572,11 @@ int main(int argc, char *argv[]) nrows = Rast_window_rows(); ncols = Rast_window_cols(); - G_important_message(_("Writing %s of <%s> to <%s>..."), - (frad->answer ? _("radiance") - : (lsat.band[i].thermal) ? _("temperature") - : _("reflectance")), + G_important_message((frad->answer + ? _("Writing radiance of <%s> to <%s>...") + : (lsat.band[i].thermal) + ? _("Writing temperature of <%s> to <%s>...") + : _("Writing reflectance of <%s> to <%s>...")), band_in, band_out); for (row = 0; row < nrows; row++) { G_percent(row, nrows, 2); diff --git a/imagery/i.segment/region_growing.c b/imagery/i.segment/region_growing.c index 967403a8aae..efb1216712d 100644 --- a/imagery/i.segment/region_growing.c +++ b/imagery/i.segment/region_growing.c @@ -1382,8 +1382,8 @@ static int set_candidate_flag(struct ngbr_stats *head, int value, G_debug(4, "set_candidate_flag"); if ((!(FLAG_GET(globals->candidate_flag, head->row, head->col))) != value) { - G_warning(_("Candidate flag is already %s"), - value ? _("set") : _("unset")); + G_warning(value ? _("Candidate flag is already set") + : _("Candidate flag is already unset")); return FALSE; } diff --git a/lib/pngdriver/graph_set.c b/lib/pngdriver/graph_set.c index 03c65ebbb8d..129cb61f3b9 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -97,8 +97,8 @@ int PNG_Graph_set(void) p = getenv("GRASS_RENDER_TRUECOLOR"); png.true_color = !p || strcmp(p, "FALSE") != 0; - G_verbose_message(_("png: truecolor status %s"), - png.true_color ? _("enabled") : _("disabled")); + G_verbose_message(png.true_color ? _("png: truecolor status enabled") + : _("png: truecolor status disabled")); p = getenv("GRASS_RENDER_FILE_MAPPED"); do_map = p && strcmp(p, "TRUE") == 0; diff --git a/lib/psdriver/graph_set.c b/lib/psdriver/graph_set.c index fad5d70d1bc..17c2ebd3d58 100644 --- a/lib/psdriver/graph_set.c +++ b/lib/psdriver/graph_set.c @@ -193,8 +193,8 @@ int PS_Graph_set(void) p = getenv("GRASS_RENDER_PS_TRAILER"); ps.no_trailer = p && strcmp(p, "FALSE") == 0; - G_verbose_message(_("ps: truecolor status %s"), - ps.true_color ? _("enabled") : _("disabled")); + G_verbose_message(ps.true_color ? _("ps: truecolor status enabled") + : _("ps: truecolor status disabled")); get_paper(); diff --git a/vector/v.generalize/main.c b/vector/v.generalize/main.c index 66d6bdf3e30..12629b27d6a 100644 --- a/vector/v.generalize/main.c +++ b/vector/v.generalize/main.c @@ -605,10 +605,12 @@ int main(int argc, char *argv[]) G_message("-----------------------------------------------------"); if (total_input != 0 && total_input != total_output) - G_done_msg(_("Number of vertices for selected features %s from %d to " - "%d (%d%% remaining)"), - simplification ? _("reduced") : _("changed"), total_input, - total_output, (total_output * 100) / total_input); + G_done_msg( + simplification ? _("Number of vertices for selected features " + "reduced from %d to %d (%d%% remaining)") + : _("Number of vertices for selected features " + "changed from %d to %d (%d%% remaining)"), + total_input, total_output, (total_output * 100) / total_input); else G_done_msg(" "); diff --git a/vector/v.in.ogr/main.c b/vector/v.in.ogr/main.c index 1da166fc766..33f0cae7cf2 100644 --- a/vector/v.in.ogr/main.c +++ b/vector/v.in.ogr/main.c @@ -1370,9 +1370,11 @@ int main(int argc, char *argv[]) } if (nogeom > 0) - G_warning(_("%d %s without geometry in input layer <%s> skipped"), - nogeom, nogeom == 1 ? _("feature") : _("features"), - layer_names[layer]); + G_warning( + n_("%d feature without geometry in input layer <%s> skipped", + "%d features without geometry in input layer <%s> skipped", + nogeom), + nogeom, layer_names[layer]); } delete_table = Vect_maptype(&Map) != GV_FORMAT_NATIVE; From 6f515299854a3746ce70bf05cb34228a00cdaf84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:35:24 +0000 Subject: [PATCH 2/4] i18n: Add translation comments to units --- lib/gis/units.c | 132 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 110 insertions(+), 22 deletions(-) diff --git a/lib/gis/units.c b/lib/gis/units.c index 22615ea9211..ae9eb7f92b9 100644 --- a/lib/gis/units.c +++ b/lib/gis/units.c @@ -206,28 +206,56 @@ const char *G_get_units_name(int units, int plural, int square) switch (units) { case U_UNKNOWN: if (square) - return plural ? _("square units") : _("square unit"); + return plural + // GTC: localized area units + ? _("square units") + // GTC: localized area units + : _("square unit"); else - return plural ? _("units") : _("unit"); + return plural + // GTC: localized units + ? _("units") + // GTC: localized units + : _("unit"); break; case U_METERS: if (square) - return plural ? _("square meters") : _("square meter"); + return plural + // GTC: localized area units + ? _("square meters") + // GTC: localized area units + : _("square meter"); else - return plural ? _("meters") : _("meter"); + return plural + // GTC: localized units + ? _("meters") + // GTC: localized units + : _("meter"); break; case U_KILOMETERS: if (square) - return plural ? _("square kilometers") : _("square kilometer"); + return plural + // GTC: localized area units + ? _("square kilometers") + // GTC: localized area units + : _("square kilometer"); else - return plural ? _("kilometers") : _("kilometer"); + return plural + // GTC: localized units + ? _("kilometers") + // GTC: localized units + : _("kilometer"); break; case U_ACRES: if (square) - return plural ? _("acres") : _("acre"); + return plural + // GTC: localized area units + ? _("acres") + // GTC: localized area units + : _("acre"); else return G_get_units_name(G_units(G_database_unit_name(1)), plural, square); @@ -235,7 +263,11 @@ const char *G_get_units_name(int units, int plural, int square) case U_HECTARES: if (square) - return plural ? _("hectares") : _("hectare"); + return plural + // GTC: localized area units + ? _("hectares") + // GTC: localized area units + : _("hectare"); else return G_get_units_name(G_units(G_database_unit_name(1)), plural, square); @@ -243,54 +275,110 @@ const char *G_get_units_name(int units, int plural, int square) case U_MILES: if (square) - return plural ? _("square miles") : _("square mile"); + return plural + // GTC: localized area units + ? _("square miles") + // GTC: localized area units + : _("square mile"); else - return plural ? _("miles") : _("mile"); + return plural + // GTC: localized units + ? _("miles") + // GTC: localized units + : _("mile"); break; case U_FEET: if (square) - return plural ? _("square feet") : _("square foot"); + return plural + // GTC: localized area units, do not confuse with US feet + ? _("square feet") + // GTC: localized area units, do not confuse with US foot + : _("square foot"); else - return plural ? _("feet") : _("foot"); + return plural + // GTC: localized units, do not confuse with US feet + ? _("feet") + // GTC: localized units, do not confuse with US foot + : _("foot"); break; case U_USFEET: if (square) - return plural ? _("square US feet") : _("square US foot"); + return plural + // GTC: localized area units, do not confuse with feet + ? _("square US feet") + // GTC: localized area units, do not confuse with foot + : _("square US foot"); else - return plural ? _("US feet") : _("US foot"); + return plural + // GTC: localized units, do not confuse with feet + ? _("US feet") + // GTC: localized units, do not confuse with foot + : _("US foot"); break; case U_DEGREES: if (square) - return plural ? _("square degrees") : _("square degree"); + return plural + // GTC: localized area units + ? _("square degrees") + // GTC: localized area units + : _("square degree"); else - return plural ? _("degrees") : _("degree"); + return plural + // GTC: localized units + ? _("degrees") + // GTC: localized units + : _("degree"); break; case U_YEARS: - return plural ? _("years") : _("year"); + return plural + // GTC: localized time units + ? _("years") + // GTC: localized time units + : _("year"); break; case U_MONTHS: - return plural ? _("months") : _("month"); + return plural + // GTC: localized time units + ? _("months") + // GTC: localized time units + : _("month"); break; case U_DAYS: - return plural ? _("days") : _("day"); + return plural + // GTC: localized time units + ? _("days") + // GTC: localized time units + : _("day"); break; case U_HOURS: - return plural ? _("hours") : _("hour"); + return plural + // GTC: localized time units + ? _("hours") + // GTC: localized time units + : _("hour"); break; case U_MINUTES: - return plural ? _("minutes") : _("minute"); + return plural + // GTC: localized time units + ? _("minutes") + // GTC: localized time units + : _("minute"); break; case U_SECONDS: - return plural ? _("seconds") : _("second"); + return plural + // GTC: localized time units + ? _("seconds") + // GTC: localized time units + : _("second"); break; } From 24f192ef3bde8601d5620f6109da15a41826f78e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 22 Jun 2025 02:57:36 +0000 Subject: [PATCH 3/4] i18n: Make strings reorderable for translation A few strings were flagged by when running xgettext, mentioning that format string with unnamed arguments cannot be properly localized: The translator cannot reorder the arguments. Please consider using a format string with named arguments, and a mapping instead of a tuple for the arguments. --- gui/wxpython/rlisetup/wizard.py | 6 +++--- gui/wxpython/vnet/vnet_core.py | 5 +++-- scripts/v.db.renamecolumn/v.db.renamecolumn.py | 6 +++++- scripts/v.import/v.import.py | 4 +++- scripts/v.pack/v.pack.py | 6 +++++- 5 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gui/wxpython/rlisetup/wizard.py b/gui/wxpython/rlisetup/wizard.py index c2485c28e86..00590e9bd0e 100644 --- a/gui/wxpython/rlisetup/wizard.py +++ b/gui/wxpython/rlisetup/wizard.py @@ -1855,11 +1855,11 @@ def newCat(self): GError( parent=self, message=_( - "The raster map <%s> already exists." + "The raster map <{map_name}> already exists." " Please remove or rename the maps " - "with the prefix '%s' or select the " + "with the prefix '{prefix}' or select the " "option to overwrite existing maps" - ).format(self.outname, self.outpref), + ).format(map_name=self.outname, prefix=self.outpref), ) self.parent.wizard.ShowPage(self.parent.samplingareapage) return diff --git a/gui/wxpython/vnet/vnet_core.py b/gui/wxpython/vnet/vnet_core.py index 7f610858552..0fadf24b790 100644 --- a/gui/wxpython/vnet/vnet_core.py +++ b/gui/wxpython/vnet/vnet_core.py @@ -637,8 +637,9 @@ def _runAn(self, analysis, output, params, flags, catPts): if len(catPts[cat[0]]) < 1: GMessage( parent=self, - message=_("Please choose '%s' and '%s' point.") - % (cats[0][1], cats[1][1]), + message=_("Please choose '{0}' and '{1}' point.").format( + cats[0][1], cats[1][1] + ), ) return False else: diff --git a/scripts/v.db.renamecolumn/v.db.renamecolumn.py b/scripts/v.db.renamecolumn/v.db.renamecolumn.py index 19db31f2719..b6345bfa0ce 100755 --- a/scripts/v.db.renamecolumn/v.db.renamecolumn.py +++ b/scripts/v.db.renamecolumn/v.db.renamecolumn.py @@ -101,7 +101,11 @@ def main(): # old col there? if not oldcoltype: - gs.fatal(_("Column <%s> not found in table <%s>") % (oldcol, table)) + gs.fatal( + _("Column <{column_name}> not found in table <{table_name}>").format( + column_name=oldcol, table_name=table + ) + ) # some tricks if driver in {"sqlite", "dbf"}: diff --git a/scripts/v.import/v.import.py b/scripts/v.import/v.import.py index a427e4bdc58..fcb3ddc988d 100755 --- a/scripts/v.import/v.import.py +++ b/scripts/v.import/v.import.py @@ -371,7 +371,9 @@ def main(): not gs.overwrite() and gs.find_file(output, element="vector", mapset=".")["mapset"] ): - gs.fatal(_("option <%s>: <%s> exists.") % ("output", output)) + gs.fatal( + _("option <{key}>: <{value}> exists.").format(key="output", value=output) + ) if options["extent"] == "region": gs.run_command("g.remove", type="vector", name=vreg, flags="f", quiet=True) diff --git a/scripts/v.pack/v.pack.py b/scripts/v.pack/v.pack.py index e39d52dbafe..35fe7544dba 100755 --- a/scripts/v.pack/v.pack.py +++ b/scripts/v.pack/v.pack.py @@ -83,7 +83,11 @@ def main(): ) try_remove(outfile) else: - grass.fatal(_("option <%s>: <%s> exists.") % ("output", outfile)) + grass.fatal( + _("option <{key}>: <{value}> exists.").format( + key="output", value=outfile + ) + ) # prepare for packing grass.verbose(_("Packing <%s>...") % (gfile["fullname"])) From f1683a8028975f152454cfdb975dbd212a1dba3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 22 Jun 2025 03:08:28 +0000 Subject: [PATCH 4/4] docs: Fix various typos --- display/d.legend/draw.c | 2 +- lib/htmldriver/graph_set.c | 2 +- lib/pngdriver/graph_set.c | 2 +- lib/psdriver/graph_set.c | 2 +- lib/raster/cats.c | 2 +- raster/r.spread/spread.c | 2 +- raster/r.univar/r.univar_main.c | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/display/d.legend/draw.c b/display/d.legend/draw.c index b3593bea448..d3353589d4d 100644 --- a/display/d.legend/draw.c +++ b/display/d.legend/draw.c @@ -247,7 +247,7 @@ void draw(const char *map_name, int maptype, int color, int thin, int lines, "Nothing to draw! (no categories with labels? out of range?)")); } - /* Figure number of lines, number of pixles per line and text size */ + /* Figure number of lines, number of pixels per line and text size */ dots_per_line = ((y1 - y0) / lines); /* switch to a smooth legend for CELL maps with too many cats */ diff --git a/lib/htmldriver/graph_set.c b/lib/htmldriver/graph_set.c index 7b48880aec1..2b7dea6f971 100644 --- a/lib/htmldriver/graph_set.c +++ b/lib/htmldriver/graph_set.c @@ -3,7 +3,7 @@ * started-up, or otherwise initialized happens here. This is called only at * the startup of the graphics driver. * - * The external variables define the pixle limits of the graphics surface. The + * The external variables define the pixel limits of the graphics surface. The * coordinate system used by the applications programs has the (0,0) origin * in the upper left-hand corner. Hence, * screen_left < screen_right diff --git a/lib/pngdriver/graph_set.c b/lib/pngdriver/graph_set.c index 129cb61f3b9..d22338737ab 100644 --- a/lib/pngdriver/graph_set.c +++ b/lib/pngdriver/graph_set.c @@ -71,7 +71,7 @@ static void map_file(void) started-up, or otherwise initialized happens here. This is called only at the startup of the graphics driver. - The external variables define the pixle limits of the graphics surface. The + The external variables define the pixel limits of the graphics surface. The coordinate system used by the applications programs has the (0,0) origin in the upper left-hand corner. Hence, screen_left < screen_right diff --git a/lib/psdriver/graph_set.c b/lib/psdriver/graph_set.c index 17c2ebd3d58..b33db00f307 100644 --- a/lib/psdriver/graph_set.c +++ b/lib/psdriver/graph_set.c @@ -3,7 +3,7 @@ * started-up, or otherwise initialized happens here. This is called only at * the startup of the graphics driver. * - * The external variables define the pixle limits of the graphics surface. The + * The external variables define the pixel limits of the graphics surface. The * coordinate system used by the applications programs has the (0,0) origin * in the upper left-hand corner. Hence, * screen_left < screen_right diff --git a/lib/raster/cats.c b/lib/raster/cats.c index 64b0c1f6f44..6eb3789daef 100644 --- a/lib/raster/cats.c +++ b/lib/raster/cats.c @@ -212,7 +212,7 @@ static CELL read_cats(const char *element, const char *name, const char *mapset, if (!full) { fclose(fd); if (num < 0) - return 0; /* coorect */ + return 0; /* correct */ return (CELL)num; } diff --git a/raster/r.spread/spread.c b/raster/r.spread/spread.c index 3ec6c0cee7c..b5aa36cb1d0 100644 --- a/raster/r.spread/spread.c +++ b/raster/r.spread/spread.c @@ -236,7 +236,7 @@ int cumulative(struct costHa *pres_cell, struct cell_ptrHa *to_cell, return 0; } -/****** function for updating the cumulative cost/time, possibaly ******** +/****** function for updating the cumulative cost/time, possibly ******** ****** back path x,y coordinates, both in the output(s) and the heap ********/ void update(struct costHa *pres_cell, int row, int col, double angle, diff --git a/raster/r.univar/r.univar_main.c b/raster/r.univar/r.univar_main.c index 7ae9ec68098..8b6fe8524ec 100644 --- a/raster/r.univar/r.univar_main.c +++ b/raster/r.univar/r.univar_main.c @@ -220,7 +220,7 @@ int main(int argc, char *argv[]) G_fatal_error("Can not read range for zoning raster"); Rast_get_range_min_max(&zone_range, &min, &max); if (Rast_read_cats(z, mapset, &(zone_info.cats))) - G_warning("no category support for zoning raster"); + G_warning("No category support for zoning raster"); zone_info.min = min; zone_info.max = max;