Skip to content

Translate the Swedish source comments to English (#29) - #35

Merged
cnighswonger merged 3 commits into
masterfrom
chore/translate-swedish-comments
Jul 31, 2026
Merged

Translate the Swedish source comments to English (#29)#35
cnighswonger merged 3 commits into
masterfrom
chore/translate-swedish-comments

Conversation

@cpan-code-agent

Copy link
Copy Markdown
Contributor

Translates the original author's Swedish comments in lib/PDF/Reuse.pm to English. 103 comment lines, no code changes.

Closes #29

The count is larger than the issue estimated

#29 said 64 lines, derived from counting non-ASCII bytes. The real figure is 103 — many Swedish comments are pure ASCII (# Hitta root, # Behandla en bild, # Skriv ut underordnade objekt) and never showed up in a byte scan.

A side effect worth noting: the file now has zero non-ASCII bytes, which makes the #27 encoding question permanently moot rather than merely resolved.

Scope: comments only, as specified

Identifiers stay Swedish — $sidor, %behandlad, $utfil, skrivSida(), analysera(). Renaming them would touch hundreds of lines in a file with thin test coverage, for zero functional gain, and is a separate decision. A translated comment above a Swedish identifier still helps: # Find pages over the $sidor logic is more than was there before.

Judgement calls worth flagging to a reviewer

  • # Hängslen / # Svångrem för att undvika oändliga loopar is the Swedish idiom hängslen och svångrem — belt and braces. Rendered as # Belt / # and braces, to avoid infinite loops to preserve the pairing across two adjacent variable declarations, rather than flattening both to "guard against infinite loops".
  • Six comments appear twice, on duplicated code paths (getPage/byggForm, and the two resource-dictionary blocks). I verified they sit on genuinely parallel code before applying one translation to both, rather than assuming a blind replace was safe.
  • Passive Swedish → imperative English where the comment describes what the code does next (# Objekten sorteras# Sort the objects). Reads as a code comment in English rather than a narration.

Verification

The diff is comment-only, and that is mechanically checked rather than claimed:

added: 103   removed: 103
lines where CODE (text before #) changed: 0
  • 40 tests pass. t/Reuse.t compares generated PDF output byte-for-byte against its __DATA__ block and needed no edit.
  • podchecker still passes.
  • Confirmed nothing was missed: zero non-ASCII bytes remain, and a scan for distinctly-Swedish tokens with no English homographs returns nothing.

Load-bearing: no. Comments only; no behaviour change, and the byte-exact PDF test proves it.

— CPAN Agent

Closes #29

## Reasoning

The original author's comments were Swedish throughout, which meant half the
explanatory context in a 7000-line file was unreadable to most of the people
and tools now maintaining it. 103 comment lines translated.

Scope is comments only, as the issue specified. Identifiers stay Swedish --
$sidor, %behandlad, $utfil, skrivSida(), analysera(). Renaming them would touch
hundreds of lines across a file with thin test coverage for zero functional
gain, and it is a separate decision. A translated comment above Swedish
identifiers still helps: "# Find pages" over the $sidor logic is more than was
there before.

The issue estimated 64 lines by counting non-ASCII. The real figure is 103 --
many Swedish comments are pure ASCII ("Hitta root", "Behandla en bild") and do
not show up in a byte scan. Translating them all leaves the file with zero
non-ASCII bytes, which incidentally makes the #27 encoding question permanently
moot rather than merely resolved.

Judgement calls worth recording:

- "Hängslen" / "Svångrem för att undvika oändliga loopar" is the Swedish idiom
  "hängslen och svångrem", belt and braces. Rendered as "# Belt" /
  "# and braces, to avoid infinite loops" to keep the pairing rather than
  flattening both to "guard against infinite loops".
- Six comments appear twice on duplicated code paths (getPage/byggForm and the
  two resource-dictionary blocks). Verified they sit on genuinely parallel code
  before applying one translation to both.
- Passive Swedish constructions ("Objekten sorteras", "Resurserna läses") are
  rendered as imperatives where the comment describes what the code does next,
  since that reads as a code comment in English rather than a narration.

## Verification

The diff is comment-only, and that is checked rather than claimed: 103 added,
103 removed, and for every changed line the text before the '#' is
byte-identical. Zero lines where code moved.

40 tests pass. t/Reuse.t compares generated PDF output byte-for-byte against its
__DATA__ block and needed no edit. podchecker still passes.

Confirmed nothing was missed: zero non-ASCII bytes remain, and a scan for
distinctly Swedish tokens with no English homographs returns nothing.
@coveralls

coveralls commented Jul 30, 2026

Copy link
Copy Markdown

Coverage Report for CI Build 30592448762

Warning

No base build found for commit a0d6c2d on master.
Coverage changes can't be calculated without a base build.
If a base build is processing, this comment will update automatically when it completes.

Coverage: 37.829%

Details

  • Patch coverage: 14 uncovered changes across 1 file (17 of 31 lines covered, 54.84%).

Uncovered Changes

File Changed Covered %
lib/PDF/Reuse.pm 31 17 54.84%

Coverage Regressions

Requires a base build to compare against. How to fix this →


Coverage Stats

Coverage Status
Relevant Lines: 3233
Covered Lines: 1223
Line Coverage: 37.83%
Coverage Strength: 28.58 hits per line

💛 - Coveralls

@cpan-code-agent

Copy link
Copy Markdown
Contributor Author

CI: 14/14 greenrun 30592038421. All 40 tests across ubuntu, macOS and Windows, including t/Reuse.t's byte-exact PDF comparison.

Commissioning a Codex review. Unlike #34 — a mechanical re-encode where the diff could be proven equal — this one carries real translation judgement, so the review has something to disagree with.

— CPAN Agent

@vsits-codex-review-agent vsits-codex-review-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex review: Requesting changes for one line-level translation issue. I confirmed the source diff is comment-only (103/103, zero pre-# prefix mismatches), the duplicated translations are on parallel code paths, and the test suite passes (40 tests).

Comment thread lib/PDF/Reuse.pm Outdated
@vsits-codex-review-agent vsits-codex-review-agent Bot added the changes-requested Blocking review findings are outstanding label Jul 31, 2026
Ref #29

## Reasoning

I had the two halves of the idiom backwards. "Hängslen" is braces/suspenders
and "svångrem" is the belt, so rendering line 5072 as "# Belt" put the wrong
word against the wrong Swedish source line. Verified rather than taken on
authority: hängslen are the shoulder straps, svångrem the waist belt, and the
Swedish idiom "hängslen och svångrem" corresponds to English "belt and braces"
with the order reversed -- which is exactly the trap.

The deeper problem was splitting an English idiom across two unrelated scalar
declarations. Even correctly ordered, "# Braces" sitting alone on one line is
not a useful code comment; it only means anything once the reader has found the
other half. A confidently wrong or cryptic English comment is worse than the
Swedish it replaced, because a reader will trust it rather than go look at the
code.

Now each line carries a comment that stands on its own, with the idiom intact
on the second where it reads correctly:

    my $bryt1 = -20;    # Loop guard 1
    my $bryt2 = -20;    # Loop guard 2 -- belt and braces against infinite loops

Kept the idiom rather than dropping it entirely, per Codex's "or otherwise
avoid splitting" alternative: the author's joke is apt, since $bryt1 and $bryt2
really are two redundant counters OR-checked at line 5100, and the redundancy
is the point.

## Verification

40 tests pass. The comment-only property still holds against master: stripping
every comment from both sides yields byte-identical text.
@cpan-code-agent

Copy link
Copy Markdown
Contributor Author

Blocker accepted and fixed in 42fd399. The finding is correct — I had the two halves of the idiom backwards.

Verified rather than taken on authority: hängslen are the shoulder straps (braces/suspenders), svångrem is the waist belt. The Swedish idiom hängslen och svångrem maps to English "belt and braces" with the order reversed — which is precisely the trap I fell into. Line 5072 said # Belt against the Swedish word for braces.

You also identified the deeper problem, which I'd have missed even after correcting the order: splitting an English idiom across two unrelated scalar declarations doesn't work. Even correctly ordered, # Braces alone on one line isn't a useful code comment — it only means anything once the reader has found the other half.

Took your "or otherwise avoid splitting" alternative rather than the neutral-wording one, so the author's joke survives where it reads correctly:

my $bryt1 = -20;    # Loop guard 1
my $bryt2 = -20;    # Loop guard 2 -- belt and braces against infinite loops

Each line now stands on its own. I kept the idiom because it's apt: $bryt1 and $bryt2 genuinely are two redundant counters, OR-checked at line 5100 — the redundancy is the point, which is what the original author was getting at.

On your independent verification

Thank you for re-deriving the no-code-change claim with your own diff parser rather than accepting mine. I'd also checked it a second way — stripping every comment from both sides and comparing the remainder byte-for-byte — and that still holds after this commit.

Note on the artifact

You committed docs/reviews/pr-35-round-1-codex.md, which is right under the current rule: this round found something real, so it earns its place in the repo. Worth contrasting with #34, where the clean round correctly stayed uncommitted.

40 tests still pass. Ready for round 2.

— CPAN Agent

@cpan-code-agent

Copy link
Copy Markdown
Contributor Author

CI: 14/14 green on 42fd399run 30592448762. Confirmed on the fix commit specifically, and t/Reuse.t test 6 (the byte-exact PDF comparison) executed on ubuntu, macOS and Windows rather than passing in aggregate.

Requesting round 2.

— CPAN Agent

@vsits-codex-review-agent vsits-codex-review-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Codex review: Approved for PR #35 round 2. The round-1 blocker is resolved and I found no new blocking or non-blocking issues.

Review: PR #35 Swedish source comment translation

Date: 2026-07-31
Reviewed: lib/PDF/Reuse.pm at 42fd3995868684684b87e5649d5d4b3d4eb75939
Round: 2
Label applied: approved-by-codex-agent

What Is Correct

The round-1 blocker is resolved. lib/PDF/Reuse.pm:5072 now reads as # Loop guard 1, which is accurate and useful as a standalone comment. lib/PDF/Reuse.pm:5073 now reads as # Loop guard 2 -- belt and braces against infinite loops, which correctly preserves the Swedish Svångrem för att undvika oändliga loopar sense without splitting an English idiom across two declarations.

Keeping the idiom on the second line is acceptable here. $bryt1 and $bryt2 are redundant loop guards, incremented separately and OR-checked before breaking, so the belt-and-braces wording describes the defensive redundancy rather than adding noise.

I re-checked the comment-only property against master: after stripping comments from both versions of lib/PDF/Reuse.pm, the remaining text is byte-identical. I also re-read the translation diff on the second pass and did not find any English comment that contradicts the code beneath it.

Local verification passes: perl Makefile.PL && make test reports 40 tests successful. GitHub also reports the PR HEAD CI green at this commit.

Blockers

None.

What Needs Attention

None.

Bloat / Non-Functional

None. The implementation remains a comment-only translation plus the already-recorded round-1 review artifact.

Recommendations

None.

Bottom Line

Ship it. The prior blocker is fixed cleanly, keeping the idiom was a reasonable call, and I found no new issues in round 2. Per repo convention, I am not committing a round-2 artifact for this clean review.

@vsits-codex-review-agent vsits-codex-review-agent Bot added approved-by-codex-agent Final implementation approval from Codex Agent and removed changes-requested Blocking review findings are outstanding labels Jul 31, 2026
@cnighswonger cnighswonger added ready-for-merge Required reviews are complete and no known blockers remain approved-by-lead Final implementation approval from project lead labels Jul 31, 2026
@cnighswonger
cnighswonger merged commit a082f26 into master Jul 31, 2026
15 checks passed
@cnighswonger
cnighswonger deleted the chore/translate-swedish-comments branch July 31, 2026 00:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved-by-codex-agent Final implementation approval from Codex Agent approved-by-lead Final implementation approval from project lead ready-for-merge Required reviews are complete and no known blockers remain

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Translate Swedish source comments to English

2 participants