Skip to content

i18n: Improve C source strings flagged on Weblate - #720

Closed
echoix wants to merge 9 commits into
mainfrom
i18n-complete-source-strings
Closed

echoix wants to merge 9 commits into
mainfrom
i18n-complete-source-strings

Conversation

@echoix

@echoix echoix commented Oct 3, 2026 •

Copy link
Copy Markdown
Owner

Description

Fix C source strings flagged by comments on Weblate: messages built from separately translated fragments or with a substituted word, which translators cannot adapt, plus a few typos and an inconsistent term.

  • r.in.pdal: the point count messages used _(GPOINT_COUNT_FORMAT " points ..."). xgettext extracted a fragment, and the msgid at runtime (%llu points ...) matched no catalog entry, so they were never translated. They now use PRIu64, so the msgid is the same whatever the type of the count, and the final message is split into sentences with one placeholder each.
  • r.reclass, r.horizon, v.rectify, db.dbf: no more strings translated in pieces or with a substituted word.
  • v.class: translate the column headers instead of the %15s%15s%15s format string, with translator comments.
  • lib/gis/view.c: remove leading spaces in the window overlap warnings.
  • v.in.ogr, v.profile: fix typos.
  • SQLite driver: "SQLite" (the database engine) spelled consistently.

Positional placeholders (%1$s) are not used. With plain snprintf/vsnprintf they are not interpreted on MSVC (the output is $s $s), so messages that would need reordering are split into sentences with one placeholder each. They do work on MinGW.

Motivation and context

Translators cannot reorder or adapt text that is split across several _() calls or filled with a substituted word, and some strings were never translated at all (r.in.pdal).

How has this been tested?

Built by CI on Linux, macOS, MinGW and MSVC. Positional placeholder support was checked with a small C program on MSVC and MinGW64 (MSYS2), with and without libintl.

For the PRIu64 messages: xgettext with the options of locale/Makefile extracts %<PRIu64> points found in region.; after msgfmt and a French catalog, a program using unsigned long long and unsigned long counts printed the translated message with the number substituted in both cases.

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 from the Weblate comments and to draft these changes.

Comment thread db/drivers/dbf/dbfexe.c Outdated
Comment on lines +65 to +66
db_d_append_error(_("SQL parser error (%s) in statement:\n%s\n"),
st->errmsg, sql);

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Is there a usual way to allow reordering placeholders like in python? It needs to be possible to compile with all our platforms.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

POSIX positional arguments (%1$s) are the usual gettext way, but I have not confirmed they work on all our platforms. The Windows CRT printf does not support them, and I have not checked whether libintl covers it for our MinGW/MSVC builds. There is no use of %N$ anywhere in the tree to rely on. For this message the order is not a practical problem, since the error text is in parentheses and the statement is on its own line. If you prefer, I can split it into two complete messages instead.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

How should it be checked on windows?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I could not test it here, as I had no Windows compiler available. A direct check is a small C program built with each toolchain we ship (MSYS2/MinGW and MSVC via OSGeo4W) that calls snprintf(buf, sizeof buf, "%2$s %1$s", "a", "b"), run from the existing Windows CI. Also relevant is the vsnprintf in G_vasprintf() (lib/gis/asprintf.c), which is what G_message() and G_fatal_error() use. Until that is confirmed, I would avoid positional placeholders and restructure the strings so the order does not matter.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I split it in 5cdf757 so this no longer depends on positional placeholders: SQL parser error: %s and Statement: %s are now two complete messages, each with a single placeholder.

Comment thread raster/r.in.pdal/main.cpp Outdated
Comment thread raster/r.reclass/main.c
Comment thread gui/wxpython/rlisetup/wizard.py Outdated
Comment thread gui/wxpython/tplot/frame.py Outdated
Comment thread gui/wxpython/core/render.py Outdated
@github-actions github-actions Bot added the GUI label Oct 3, 2026
@echoix
echoix force-pushed the i18n-complete-source-strings branch from 89a6fb3 to b0edf13 Compare October 3, 2026 21:08
@echoix echoix changed the title Translation: Use complete source strings instead of fragments Translation: Use complete source strings instead of fragments (C) Oct 3, 2026
@echoix

echoix commented Oct 3, 2026

Copy link
Copy Markdown
Owner Author

This PR is now C-only. The Python and wxGUI changes moved to #724. The commits were rebuilt (one per tool), so earlier commit hashes in the replies above no longer exist; dbfexe.c is now the split version (SQL parser error: %s and Statement: %s). The Windows check for positional placeholders is in #722: they fail with plain snprintf/vsnprintf on MSVC and MinGW.

@echoix echoix changed the title Translation: Use complete source strings instead of fragments (C) Translation: Improve C source strings flagged on Weblate Oct 3, 2026
@echoix echoix changed the title Translation: Improve C source strings flagged on Weblate i18n: Improve C source strings flagged on Weblate Oct 4, 2026
Comment thread db/drivers/sqlite/db.c
Comment thread general/g.findfile/main.c Outdated
Comment thread lib/manage/read_list.c Outdated
Comment thread raster/r.in.pdal/main.cpp
Comment thread raster/r.in.pdal/main.cpp Outdated
Comment thread vector/v.class/main.c Outdated
@echoix
echoix force-pushed the i18n-complete-source-strings branch from 731702f to f1da28e Compare October 4, 2026 15:47
echoix added 8 commits October 4, 2026 11:53
Join the 'Illegal reclass rule' and 'invalid reclass rule' messages instead of translating their pieces separately.
The msgids were built with a preprocessor macro inside _(), so xgettext
extracted a fragment and the runtime msgid never matched a catalog entry.
Write the format with PRIu64, as done for other 64-bit values in translated
strings, so the msgid is the same whatever the type of the count.

Report the final counts in separate messages, each with a single
placeholder, instead of one message built with snprintf().
The direction was a separately translated word substituted into the sentence, which cannot agree in gender or case in all languages.
The error was split over two warnings and a fatal error, so the sentence was
translated in pieces. Use complete sentences with a single placeholder each,
so that no positional placeholders are needed.
The message was joined from separately translated fragments. Use two complete messages with one placeholder each.
The format string '%15s%15s%15s' was translated, which splits a table header over three untranslatable arguments. Translate each column header instead.
Leading whitespace in a msgid is easy to lose or misplace in translations.
Fix 'where' for 'were' and the capitalized 'Your'.
@echoix
echoix force-pushed the i18n-complete-source-strings branch from f1da28e to 0a48f5a Compare October 4, 2026 15:55
@echoix echoix closed this Oct 10, 2026
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.

1 participant