Page MenuHomePhabricator

sparql comments shorten the script text once translated
Closed, InvalidPublicBUG REPORT

Description

Steps to replicate the issue (include links if applicable):

What happens?:

What should have happened instead?:

  • at least the complete script should appear as it is on the EN page even if comments are not translated

Software version (on Special:Version page; skip for WMF-hosted wikis like Wikipedia):

Other information (browser name/version, screenshots, etc.):

Event Timeline

Tacsipacsi subscribed.

This is invalid markup, in two ways.

  • The SPARQL contains literal pipe (|) characters. These are template parameter separators, so shouldn’t appear in parameter values; instead, {{!}} should be used in parameter values. (I don’t know if {{!}} would break the examples on query.wikidata.org, though, which interprets this page somehow.) {{SPARQL}} tries to be smart and fix these by iterating over unnamed parameters and assuming that they continue the query parameter. This works more or less reliably as long as all those continuation parameters are indeed unnamed.
  • However, the part starting with wdt:P18 isn’t unnamed – it contains an equals sign (in <span lang="en" dir="ltr" class="mw-content-ltr">), which MediaWiki interprets as the parameter name (so it’s a parameter named wdt:P18 wd:Q16 . # <span lang, and has a value starting with "en" dir="ltr" class="mw-content-ltr">canadian). {{SPARQL}} won’t search for a parameter named wdt:P18 wd:Q16 . # <span lang, which is understandable.

If the first problem didn’t exist, the whole SPARQL would appear, but it would still include visibly <span lang="en" dir="ltr" class="mw-content-ltr">. Fortunately there is a way to suppress this markup, which is the nowrap attribute – and this completely solves the second problem, making the workaround employed by {{SPARQL}} for the first problem be effective, and the desired result appear.

On one side the SPARQL of the EN page is the same and works so pipes are not disturbing there.
The nowrap is really effective but not as a general rule for SPARQL comments.
Thanks for analysis but error message should be signalled at least to warn the translator admin.

On one side the SPARQL of the EN page is the same and works so pipes are not disturbing there.

As I explained above, it’s supported in a hackish and fragile way by the template. (There’s no less hackish or less fragile way to support it. It should generally just be avoided.) This support works on the English page, but breaks when the markup added by Translate comes into the play. Just because something doesn’t cause visible breakage at one place, one cannot state that it certainly doesn’t contribute to breakage somewhere else.

The nowrap is really effective but not as a general rule for SPARQL comments.

Actually, it should be generally used in SPARQL comments, just like in all code blocks. The markup normally added by Translate doesn’t work in code blocks anyway, and it just adds clutter for readers (see for example how this mediawiki.org page looked like before you translated the PHP comments, due to those translation units not having nowrap at the time), when it doesn’t completely break the output like here.

Thanks for analysis but error message should be signalled at least to warn the translator admin.

The problem with this request is that there is no error. The wikitext is perfectly valid (syntactically correct), it just doesn’t do what the author wanted it to do. I’ve even seen cases (I no longer remember where) in which this garbage was intentionally used by a template to detect untranslated text. Software cannot read minds, so it cannot say for sure that this is wrong, and we don’t really have infrastructure for “this is unlikely, but not impossible, to be what you mean” sort of messages. Save errors, tracking categories, lint errors are all designed to handle definite errors. (Linters of software code, like ESLint and PHP_CodeSniffer we use, have ways to suppress false positives, so they can confidently flag things that are likely, but not certain, to be errors. The MediaWiki linter doesn’t have any suppression mechanism.)