Skip to content

Copy code entries instead of translating them - #53

Merged
tamnd merged 1 commit into
mainfrom
restore-code-entries
Aug 18, 2026
Merged

Copy code entries instead of translating them#53
tamnd merged 1 commit into
mainfrom
restore-code-entries

Conversation

@tamnd

@tamnd tamnd commented Aug 18, 2026

Copy link
Copy Markdown
Owner

P07 says a doctest or a literal block is byte-identical to its msgid, because these are copied and never translated. 31 entries in the corpus were not, and the two ways they got there are both a layer being more forgiving than the one that checks it.

26 came in as human

sync.human_segments took any translated non-fuzzy entry from the mirror, and 136 of those are code. human is a provenance and not a grade: it says a person typed the string, and 30 of the 136 are a person having typed over the code. From tutorial/introduction.po:

File "<stdin>", line 1, in <module>     the English
File "1", line 1, in 2                  the translation

<stdin> and <module> are gone. Elsewhere it is the indentation inside a for body flattened to one space, the carets under a syntax error no longer under what they point at, and a column-aligned option table reflowed to single spaces. Every one is an example a reader copies out and then has to debug.

What they were made for is the comment translation, and that is worth less than the code. Comments are M8, with a prompt of their own and a check that every code line came back byte-identical, which is what classify.is_doctest has said all along.

The other 106 are already byte-identical and lose nothing by going. apply mints them from the msgid with passthrough=doctest on them, which is the same string with an accurate account of where it came from instead of a claim that somebody translated it.

5 came in as machine

From a run made before the classifier could recognise them. batch filters non-prose out, so nothing queues one now, but the segments outlived the rule that let them be asked. python fibo.py <arguments> was written into the corpus as python fibo.py <đối số>.

apply now copies a code entry whatever the memory holds, so the guarantee does not depend on no stale segment existing. The classifier has got stricter twice and will again, and each time it does the memory acquires another handful of translations of things that turned out to be code. What a string is worth is decided by what it is now, not by what an earlier run thought when it asked.

What is not touched

The human guard still comes first, so neither clause can quietly replace a reviewed string with the English. --refuzzy is the only way past it, which is how the 136 already in the corpus were rebuilt, and it was measured first: it touches those 136 and nothing else.

Only code is dropped, not everything the classifier calls non-prose. One no-op in the corpus is a :ref: whose display text a person translated correctly, and that is a bug in is_noop rather than a licence to throw the translation away.

load_human reconciles

It used to extend. An extend leaves all 136 in the memory for apply to write back, and the alternative was editing them out of the manifest by hand, which would make the memory something the content repo can no longer be rebuilt from.

Dropping is safe because the mirror is the only place a human segment comes from. There is no command that promotes a string to human, deliberately, so anything of that provenance was read out of Transifex and can be read again. Machine segments are left alone, being the one thing here that cannot be rebuilt without spending the run.

Measured

Over the real corpus, not a fixture.

before after
P07 code entries copied exactly 31 0
P05 format specifiers match 1 0
hard checks failing 6 4
findings 1,492 1,459
checks passed 28 30

P05's single finding was inside one of the same doctests: % operator read as a % o specifier, and the translation turned it into % t.

apply --check is clean. make check is green at 1,376 tests and 97.45% coverage.

Refs #11.

P07 says a doctest or a literal block is byte-identical to its msgid,
because these are copied and never translated. 31 entries in the corpus
were not, and the two ways they got there are both a layer being more
forgiving than the one that checks it.

26 came in as human. sync.human_segments took any translated non-fuzzy
entry from the mirror, and 136 of those are code. human is a provenance
and not a grade: it says a person typed the string, and 30 of the 136
are a person having typed over the code. From tutorial/introduction.po:

    File "<stdin>", line 1, in <module>     the English
    File "1", line 1, in 2                  the translation

<stdin> and <module> are gone. Elsewhere it is the indentation inside a
for body flattened to one space, the carets under a syntax error no
longer under what they point at, and a column-aligned option table
reflowed to single spaces. Every one is an example a reader copies out
and then has to debug. What they were made for is the comment
translation, and that is worth less than the code: comments are M8,
with a prompt of their own and a check that every code line came back
byte-identical.

The other 106 are already byte-identical and lose nothing by going.
apply mints them from the msgid with passthrough=doctest on them, which
is the same string with an accurate account of where it came from.

5 came in as machine, from a run made before the classifier could
recognise them. batch filters non-prose out, so nothing queues one now,
but the segments outlived the rule that let them be asked: python fibo.py
<arguments> was written into the corpus as python fibo.py <đối số>.
apply now copies a code entry whatever the memory holds, so the
guarantee does not depend on no stale segment existing. The classifier
has got stricter twice and will again, and each time it does the memory
acquires another handful of translations of things that turned out to be
code.

The human guard still comes first, so neither clause can quietly replace
a reviewed string with the English. --refuzzy is the only way past it,
which is how the 136 already in the corpus were rebuilt.

load_human reconciles now rather than extending. An extend leaves all
136 in the memory for apply to write back, and the alternative was
editing them out of the manifest by hand, which would make the memory
something the content repo can no longer be rebuilt from. Dropping is
safe because the mirror is the only place a human segment comes from:
there is no command that promotes a string to human, deliberately, so
anything of that provenance was read out of Transifex and can be read
again. Machine segments are left alone, being the one thing here that
cannot be rebuilt without spending the run.

Only code is dropped, not everything the classifier calls non-prose. One
no-op is a :ref: whose display text a person translated correctly, and
that is a bug in is_noop rather than a licence to throw the translation
away.

Kind.code is one property where P07 and human_segments held a copy of
the set each, and they disagreed about that :ref: entry.

Measured over the corpus: P07 31 to 0, P05 1 to 0, six hard checks
failing to four, 1 492 findings to 1 459.
@tamnd
tamnd merged commit c0c2e05 into main Aug 18, 2026
2 of 7 checks passed
@tamnd
tamnd deleted the restore-code-entries branch August 18, 2026 07:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant