Repository navigation
fix(translationtool): extract every string of a Vue template - #1037
Open
DerDreschner wants to merge 1 commit into
Open
DerDreschner wants to merge 1 commit into
DerDreschner wants to merge 1 commit into
Conversation
1 task done
susnux
force-pushed
the
fix/noid/vue-template-extraction
branch
from
November 29, 2026 19:32
8402c9d to
edb3844
Compare
nickvergessen
force-pushed
the
fix/noid/vue-template-extraction
branch
from
December 1, 2026 11:47
edb3844 to
98dea7d
Compare
The patterns for t() and n() in Vue templates matched each text
greedily up to the last quote of the line. A second call on a line was
swallowed by the first, which broke the generated file whenever the
text between them wasn't valid JavaScript. t('app', "…") and an n()
whose forms use different quotes matched none of the patterns and were
dropped without any warning. Each text is now a list of string
literals joined with +, each ending at its own closing quote, in any
kind of quotes. Like xgettext, comments may stand between the tokens
of a call, and a text ends before a + followed by anything other than
a string. The quantifiers are possessive, because otherwise the
comments allowed between tokens exhaust PCRE's backtrack limit, and a
text with thousands of escapes or joined parts its JIT stack. A
failing pattern now stops the run instead of dropping strings, also
deleting the generated files that would otherwise stay in the app.
The hint for each call now comes from its own position. Searching for
the call's text found the first occurrence, so two equal calls on
different lines both got the comment and location of the first one. A
TRANSLATORS comment on the line above or in the rest of the line only
reaches the first string of the line, as xgettext does with one on the
line above; the others get their location like any string without a
hint. The location now names the line of the call also when the call
starts a line, and a comment ends at its --> or */ instead of keeping
what follows it.
The calls stay grouped by the quotes of their first text, so the
order of the existing strings in the POT only changes where a call has
another call in its arguments or the old pattern wrote broken code. On
Mail and the server's apps this adds nine strings, completes one that
was cut off at its first quote, and otherwise only adds or cleans up
hints.
Left as they are: a template literal with ${…} and the whitespace
inside a text are written as before, although they differ from the
text at runtime, because changing them would change existing msgids. A
comment inside a template expression is assigned by its line, not by
its position as xgettext does: a TRANSLATORS comment between two calls
on a line now reaches the first one, where the old pattern happened to
give it to the second. Changing that also changes the lint's comment
rules.
Assisted-by: ClaudeCode:claude-opus-5-5
Signed-off-by: David Dreschner <david.dreschner@nextcloud.com>
DerDreschner
force-pushed
the
fix/noid/vue-template-extraction
branch
from
December 2, 2026 15:19
98dea7d to
ab3d8d0
Compare
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
Fixes how the translationtool reads
t()andn()in Vue templates, where some strings never reached Transifex. Stacked on #1035, which reworked the same function; the base isfeat/noid/lint-source-strings, so the diff only shows the fix.:title="t('app', 'Title')">{{ t('app', 'Label') }}the first match swallowed the second call. xgettext then only warned "unterminated string" about the generated file. Each text now ends at its own closing quote, respecting escapes.t('app', "…"), or ann()whose singular and plural use different quotes, matched none of the patterns and was silently dropped. The app ID and each text may now use any kind of quotes, and a text may be literals joined with+. As with xgettext in<script>, comments between the tokens of a call are skipped, and a text ends before a+followed by anything other than a string:'Hello ' + namegivesHello. Such a fragment can't be translated at runtime; contacts has one,Get from, and the lint reports it when it starts or ends with whitespace.TRANSLATORScomment on the line above or in the rest of the line only reaches the first string of the line, as xgettext does with a comment on the line above and as the developer manual says; later strings on that line get their location like any string without a hint. The location of a call at the start of a line now names that line instead of the one above, and a comment ends at its-->or*/instead of keeping</p>or*/"after it.The calls stay grouped by the quotes of their first text, so the order of existing strings in the POT only changes where a call has another call in its arguments or the old pattern wrote broken code.
Effect on real apps, comparing the POTs of Mail and the server's apps with #1035's tool:
You've sent this message on {date}andDelete {number} thread, dav'sAdd example event to user's calendar when they first log in, and four in settings.Set reminder forin files_reminders was cut off at its first quote and is now the fullSet reminder for '{fileName}'.Left as it is: a template literal with
${…}and the whitespace inside a text are written as before, although they differ from the text at runtime, because changing them would change existing msgids. A comment inside a template expression is assigned by its line, not by its position as xgettext does: a/* TRANSLATORS */between two calls on a line now reaches the first one, where #1035's greedy pattern happened to give it to the second, and one before a call or inside one is read like a comment on that line. The onlyTRANSLATORScomments inside template expressions in server and apps-extra, two in files and two in theming, follow their call and reach it. Fixing it changes the lint's comment rules from #1035 too, so it gets its own PR.Tested with
tests/test.shon xgettext 0.23, 0.26 and 1.0. Each part of the fix is covered by a fixture or test that fails without it. The stop on a failing pattern is tested through the<script>pattern, which fails first; the same check on the other patterns, andcheck-filesdeleting its temporary POT when reading it fails, aren't reached by the tests.Related
🤖 AI (if applicable)