Repository navigation
locale: Make pot file generation stable - #8010
Conversation
…d_sfa.c The message "One vertex registered" is used in build_nat.c with the plural "%" PRId64 " vertices registered" and in build_sfa.c with "%d vertices registered". A .pot file keeps only one plural form per singular msgid, and xgettext keeps the first one it reads. The input file list comes from find, whose order is not stable, so the template flipped between the two forms from one update to the next. Each flip changed the msgid and made the existing translations fuzzy. Use the 64-bit form in build_sfa.c as well, casting the int counters, so all three call sites share one msgid_plural. Prepared with AI assistance (Claude Code); the root cause was found from the history of locale/templates/grasslibs.pot. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The lists of files given to xgettext come from find, whose order depends on the filesystem and can differ between runners. When the same msgid is used with different plural forms, xgettext keeps the first one it reads, so the generated .pot files could change without any change in the code. Sort the lists with LC_ALL=C so that the order is the same everywhere. Prepared with AI assistance (Claude Code). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@nilason This was another pain point |
|
Let's cast to |
What do you mean? Anyways, if it’s a C-code change, then we need to change two other places; the problem comes from the fact that three copies of the string aren’t using the same placeholder type. This changes it to the same as the two others |
Instead of cast to grass_int64, we should cast to int64_t directly, in practice they are the same: Line 660 in 000a00f (and now this block may be removed: Lines 657 to 669 in 000a00f or at least be greatly reduced, but of course not with this PR.) |
nilason
left a comment
There was a problem hiding this comment.
This is what I meant, wouldn't this work with gettext?
Oh yes probably, but what about the PRId64? Is it ok like that, or you'd like to change the two other files that use PRId64 to something else? |
PRId64 is made to accompany int64_t, so that will be fine. |
Co-authored-by: Nicklas Larsson <n_larsson@yahoo.com>
Description
Stops
locale/templates/grasslibs.potfrom changing without any code change:libvector:build_sfa.cuses"%" PRId64 " vertices registered"(with a(grass_int64)cast) as the plural of "One vertex registered", likebuild_nat.c.locale:make potsorts itsxgettextinput file lists withLC_ALL=C sort.Motivation and context
"One vertex registered" is used with two different plural forms:
"%" PRId64 " vertices registered"inbuild_nat.cand"%d vertices registered"inbuild_sfa.c(twice). A.potfile keeps one plural form per msgid, andxgettextkeeps the first one it reads. The file lists come fromfind, whose order is not stable, so the template flips between the two forms. Each flip changes the msgid and marks the existing translations as fuzzy:The first commit removes this conflict. The second makes the order deterministic. The next
locale: Update translation filesPR may change entries once, then it should stay stable.CMake: no equivalent change is needed.
locale/CMakeLists.txtonly installs.mofiles ("TODO: implement update and creation"), somake potinlocale/Makefileis the only path that generates the.potfiles. If CMake gets.potgeneration later, its file lists need sorting too (e.g.list(SORT ...)).How has this been tested?
Locally, with GNU xgettext 0.21, running the same
xgettextoptions asmake poton the sorted file list and on the same list reversed:.pot, sorted vs reversed ordermain)%<PRId64>in one run and%din the otherThe modules, wxPython and scripts domains also give the same msgids in both orders. The only difference, in the modules domain, is the placement of three
#. GTCtranslator comments, which the sorted list makes deterministic.On my fork, I ran the
Periodic updateworkflow on this branch (update_pofalse). It built GRASS, ranmake potandmake verifysuccessfully, and opened a template-update PR against this branch. In that PR:grasslibs.potkeepsmsgid_plural "%<PRId64> vertices registered". The only changes are thebuild_sfa.cline numbers in the location comments, which moved with the edit, and the creation date.grassmods.potchanges only in the order and duplication of three#. GTCtranslator comments.grasswxpy.potchanges only in the creation date.Types of changes
Checklist
AI disclosure: the root cause was found and the changes prepared with Claude Code. I reviewed the diff.