Page MenuHomePhabricator

Troubles when using section editing
Closed, DuplicatePublicBUG REPORT

Description

I think someone must have reported this?

When using section editing, the <!--T:N--> of the next section title is included at the end of the edit area. And since MediaWiki forces a trailing newline when submitting, the translation mark is not immediately followed by the next title, which throws an error to the user. This causes big inconvenience, the section editing is nearly not available.

eg. Full page:

<translate>
<!--T:1-->
== Foo ==
bar
<!--T:2-->
== Baz ==
</translate>

When editing section "Foo", the user sees:

== Foo ==
bar
<!--T:2-->

Even if the user removes the trailing newline, it will be added when sending to the server side. And finally the error checker sees:

<translate>
<!--T:1-->
== Foo ==
bar
<!--T:2-->

== Baz ==
</translate>

Is it possible to not include the translation mark in the edit area, or to try removing newlines when checking the translation?

Event Timeline

Reedy renamed this task from [Extension:Translate]Troubles when using section editing to Troubles when using section editing.Mar 27 2026, 3:01 PM

This is not the recommended markup. The recommended markup would be:

<translate>
== Foo == <!--T:1-->

<!--T:2-->
bar

== Baz == <!--T:3-->
</translate>

And with the recommended markup, section editing starts working (mostly – it does include an empty line between the <translate> and == Foo == <!--T:1-->, but that causes at most some extra white space on the page, no saving error).

This is not the recommended markup. The recommended markup would be:

<translate>
== Foo == <!--T:1-->

<!--T:2-->
bar

== Baz == <!--T:3-->
</translate>

And with the recommended markup, section editing starts working (mostly – it does include an empty line between the <translate> and == Foo == <!--T:1-->, but that causes at most some extra white space on the page, no saving error).

Oh, I see. A newline should be put between the section header and the content after that, so that the mark will not be generated before the header.

Is it possible to add a category for the marking that is not recommended?

As far as I know, Translate hasn’t used tracking categories until now, but I guess it could. Or it could surface this problem on the Special:PageTranslation interface (which is used by translation admins), where it already surfaces some potential issues, for example around the usage of translation variables (<tvar name="…">).

And while some markup recommendations are hard to verify algorithmically, this one should be relatively easy: if a translation unit contains a line that looks like a heading (starts and ends with one or more equals signs), but also other lines, it should be flagged. This algorithm may cause false positives, for example if those equals signs are in a template parameter or code block in which they don’t actually count as headings, but false positives are fine as long as it’s just a warning.