Repository navigation
feat(translationtool): lint the source strings a pull request adds - #1035
Merged
Merged
Conversation
1 task done
DerDreschner
force-pushed
the
feat/noid/lint-source-strings
branch
from
November 28, 2026 13:45
79666df to
351670e
Compare
DerDreschner
added a commit
to nextcloud/mail
that referenced
this pull request
Nov 28, 2026
Agents didn't follow the translation guidelines for new strings, and nothing in the code states the rules for the English text. The section now links the guidelines and adds the one rule no lint can check: a TRANSLATORS comment for an ambiguous string. The mechanical rules are left to the lint-source-strings check from nextcloud/docker-ci#1035. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
This was referenced Nov 28, 2026
The nightly sync pushes source strings to Transifex before validateTranslationFiles.sh checks them, so strings against the translation guidelines reach translators before anything complains. lint-source-strings checks an app's source strings against the translations page of the developer manual, so a workflow can catch them before merge. Rules are errors where a string breaks at runtime or the manual is explicit, and warnings where they can't be sure. With --base=<checkout> it extracts the base checkout too and only checks strings missing there, so existing strings never block a pull request. Findings name the source file and line, as plain text or, with --format=github, as annotations. Strings from Vue files and info.xml are extracted through generated files, so these now record which source line each of their lines came from. That also covers Vue <script> sections, whose strings had no source reference at all. The POT output is unchanged. It also stops create-pot-files from crashing on a Vue file whose <template> starts on line 1, which the lint job would hit on every pull request of such an app. Left for follow-ups: writing real .vue references into the POT, and letting validateTranslationFiles.sh use these rules, which needs a way to run only the existing ones in the nightly sync. Faster extraction is in a separate pull request. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
susnux
force-pushed
the
feat/noid/lint-source-strings
branch
from
November 29, 2026 19:32
351670e to
3023348
Compare
nickvergessen
approved these changes
Dec 1, 2026
nickvergessen
left a comment
Member
There was a problem hiding this comment.
AI reported some false positive warnings would be possible. But they just indicate bad translation strings never the less, so sounds good.
rotdrop
pushed a commit
to rotdrop/nextcloud-app-mail
that referenced
this pull request
Dec 1, 2026
Agents didn't follow the translation guidelines for new strings, and nothing in the code states the rules for the English text. The section now links the guidelines and adds the one rule no lint can check: a TRANSLATORS comment for an ambiguous string. The mechanical rules are left to the lint-source-strings check from nextcloud/docker-ci#1035. Assisted-by: ClaudeCode:claude-opus-5-5 Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New
translationtool.phar lint-source-strings [--base=<checkout>]task, for a per-PR workflow in the org template repository.Stacked on #1029, which updates gettext/gettext to v5; the base is
chore/noid/gettext-v5, so the diff only shows the lint task. Merge it after #1029.Today, bad source strings are only noticed after the nightly sync has pushed them to Transifex:
validateTranslationFiles.shruns aftertx push -s. This task checks the strings before merge, against the translations page of the developer manual.--base, the base checkout is extracted as well, and only strings missing everywhere in it are checked. Moving a string to another file or app, or moving an app folder, doesn't make it new. Existing strings never block a PR, so apps can adopt the check without cleaning up first.|,´/‘/’,..., any other space than U+00A0 before…, leading/trailing whitespace (not in theinfo.xmltexts, which aren't joined in code), contractions (don't,you're,can not),id/ids(not in URLs), HTML markup, plurals without any placeholder,%ninside a placeholder like%name%, aTRANSLATORScomment on the line of a Vue template string that the extraction also gives to the next line's string%noutsiden(), more than one placeholder without a position, or unpositioned mixed with positioned ones; a single%that doesn't start a placeholder (PHP always runsvsprintf(), so only%%shows a percent sign). Navigation names ininfo.xmlcount as PHP strings. Its name, summary and description aren't formatted at all, so no placeholder rule applies to them.%s/%1$s,{{name}}or{ name }, because only{name}and%nare replaced there%n, and more than one%swithout a name (Python can't reorder them,%(name)scan be)%nin only one plural form, a plural that shows its count with another placeholder than%n,%nin a JavaScriptt()(only replaced when a count is passed), a number placeholder (%d,{count},{seconds}…) outside a plural, placeholders named like{0}, a colon or another translation joined to a translation outside the string, a string sharing its line with a string whoseTRANSLATORScomment only reaches the first one, a comment that addresses translators without starting withTRANSLATORS, a string that gets aTRANSLATORScomment meant for the string above it (the POT shows the comment, and in the source it follows the end of a translation call, so xgettext gave it to the next string). That last one is reported once: on the string that gets the comment if it is new, otherwise on the string the comment follows. It reads the source with patterns, so it's a warning, not an error.<script>sections andinfo.xml; a finding about one occurrence of a repeated string names that occurrence. With--format=githubthey are printed as annotations. The POT stays the same for existing strings;expected.potonly changes because the new test fixtures add strings.It also fixes a crash of
create-pot-files, and so of the nightly sync, for a Vue file whose<template>starts on line 1 (getTranslatorHintWithVueSource()read the line before the first one).Tested with
tests/test.shon PHP 8.3 and 8.5, with xgettext 0.23 (as in this repository's CI), 0.26 and 1.0, and against Nextcloud Mail:t('mail', 'Checking the signature...')in a<script>gets one annotation on the right line ofThreadEnvelope.vue.t('mail', 'Sender') + ': ' + from.emailand{{ t('mail', 'Redirect URI') }}:.Follow-ups (not in this PR)
Found along the way. They change the POT, so they get their own pull requests.
Fixed in a stacked pull request:
<NcButton :title="t('app', 'Title')">{{ t('app', 'Label') }}</NcButton>, only the first string reaches the POT, xgettext just warns "unterminated string" about the generated file.t('app', "…")with the app ID in single and the text in double quotes isn't extracted at all, without any warning. Mail has one:You've sent this message on {date}inThreadEnvelope.vue.TRANSLATORScomment above a later occurrence of a repeated string doesn't reach the POT, becausegetTranslatorHintWithVueSource()finds the first occurrence by its text.Still open:
/* TRANSLATORS */between two calls on a line reaches the first one. Fixing it changes this PR's comment rules too.Next steps:
.vuefile names into the POT instead of the generated file's.TRANSLATORScomment abovet(when the string is on a later line, it has to be directly above the string.--add-commentswithout a tag) would make them exact.validateTranslationFiles.shuse these rules. The nightly sync needs a way to run only the existing ones, or it would flood every app.Related
#1028 makes the extraction about 17× faster, so a PR check with
--basetakes about 1 s instead of 20 s. Both PRs changecreateOrCheckPotFile(), so the second one to merge needs a small rebase and a rebuilt phar.Order: #1029, this PR, then publish the image ("Docker Publish" with
translations), then the template PR, because the template workflow runs the task incontinuous-integration-translations:latest.🤖 AI (if applicable)