Page MenuHomePhabricator

SVG Translate: Give an error message for not supporting nested tspans [8Hours]
Closed, ResolvedPublicBUG REPORT

Description

As a SVG Translate user, I want to access labels, so that I can properly use the tool for translation.

Background: The user is experiencing the following issue: "This file does not have any labels available for translation. Please pick another image."

Resources:

Steps to Reproduce:
https://tools.wmflabs.org/svgtranslate/File:T250607.svg

Actual Results:

Expected Results:
Give an error message for not supporting nested tspans

Acceptance Criteria:

  • Fix label bug so that users can properly access label functionality and complete translation work in SVG Translate

Event Timeline

JoKalliauer updated the task description. (Show Details)Apr 19 2020, 8:38 AM

Do we know if this is a bug or if this is a constraint of SVG Translate? Pinging @Samwilson & @MusikAnimal, in case they know. Thanks!

aezell added a subscriber: aezell.EditedApr 28 2020, 4:16 PM

This is an implementation constraint, AFAIK. I vaguely remember the discussion when we built the tool. We decided that nested TSPANs represented a technical challenge greater than their prevalence in the wild.

That is, it was more work than it was worth. That viewpoint could certainly have changed with no info or new thinking about how to implement the support.

Potentially, we could skip the nested TSPANs and still allow users to translate the unnested ones. In that sense, this could be considered broken behavior since it completely fails now.

Potentially, we could skip the nested TSPANs and still allow users to translate the unnested ones. In that sense, this could be considered broken behavior since it completely fails now.

This is similar recomended in T248252
@aezell An warning that this text pattern is not supported is also to much work?

FYI:When does nested tspan occour using inkscape GUI
-convert flowRoot/flowPara to SVG1.1-text
-changing color/font-size within a line
-superscript und subscript: Dissussion two days ago (why the tool does not work): https://commons.wikimedia.org/wiki/User_talk:JoKalliauer#File:Carbon_cycle-cute_diagram.svg, relating to <text font-style="oblique"><tspan x="297.11255" y="83.187065">CO<tspan baseline-shift="sub" font-size="65%">2</tspan></tspan></text> in https://commons.wikimedia.org/wiki/File:Carbon_cycle-cute_diagram.svg

Glrx added a comment.Apr 28 2020, 4:54 PM
  1. Failing to give a reasonable message for this case looks like a bug. The SVG file contains text. A reasonable user saw the text, wanted to translate that text, and fired up the translate tool. Then tool told him there is no text to translate. Why shouldn't the user take that as anything but a counterfactual. There's an elephant in the room and the tool is telling the user it does not see an elephant.

The tool presumably found the text element, looked at it, and decided it could not process it. The report to the user should not be there are no labels for translation, but rather the tool should state that it found a label that was too complicated for it to process.

The advice "Please pick another image" is off the mark. The user wanted to translate the current image and may not care about any other image. Better advice would be the text in the SVG needs to be simplified for it can be processed by SVG Translate. There should be some text explaining what the tool can and cannot do.

  1. Refusing to translate this file is a reasonable course of action. The file currently does not have any switch elements, so it does not have any translations. The tool may decline to translate an entire image if that image has any labels it does not understand. That's a reasonable action, but if the tool takes that action, it should inform the user that's what happened.

I think we agree that even a better error message is a path forward. I'll leave it to @ifried to determine the priority.

We'll discuss this as a team. Thanks for the background & feedback, everyone!

ARamirez_WMF renamed this task from SVG Translate: Give an error message for not supporting nested tspans to SVG Translate: Give an error message for not supporting nested tspans [8Hours].EditedApr 28 2020, 11:51 PM
ARamirez_WMF added a subscriber: ARamirez_WMF.

Investigate error messages [8 hours]. After investigation, let's bring back to Moriel and Ilana.

It looks like it's possible to show a specific error about the nested tspans. Would we want this to also display the SVG fragment in question, to help with debugging? Something like the following:

Glrx added a comment.Apr 29 2020, 5:25 PM

The nested tspan is not "erroneous code" but rather legitimate SVG that the tool does not support.

Pointing to the tspan elements could be nice, but it can also be overwhelming. I have no problem reading SVG, but I'm not sure that the average user understands it. There may be a lot of tspan problems. If the file was made with Inkscape, even one tspan may have lots of attributes that just confuse the issue.

It is simpler to tell the user the parent text element could not be processed because it has nested tspan elements. If the text element has an id attribute, display that value so the text element can be unambiguously located. In addition, display the text element's .textContent (processed via something like XSLT normalize-space()). That string would confirm to the user that the text was seen.

,

@Samwilson I like this solution. (Maybe a bit different wording, as @Glrx explained.)

I like showing the xml-code as shown above, but I think you might add a helppage such as https://commons.wikimedia.org/wiki/Commons_talk:SVG_Translate_tool for asking questions, for Inkscape-uses/Adobe-Users/... that do not understand svg-reading.

Good ideas! Thanks. How about:

This file can not be translated with this tool because it contains unsupported SVG (nested tspan in #foo) in the following text:

Lorem ipsum

The question-mark icon links to the FAQ, for further help; is that clear enough or should there be a text link as well for this specific error?

Glrx added a comment.May 4 2020, 3:18 AM

The message looks OK (but beware that a single text element may have dozens of nested tspan elements.

The ? might be enough, but I didn't notice it until a week ago. Use your judgement.

ifried added a comment.May 8 2020, 5:44 PM

@Samwilson The above text looks good. You can add in the text, as written in the comment. Thank you!

Good idea, @Glrx. The patch above adds a general 'unsupported SVG' error, which can be given different reasons for each thing. It doesn't handle textpaths yet, but after it'll be easy to add that.

Patch is ready for review: https://github.com/wikimedia/svgtranslate/pull/303

Samwilson added a comment.EditedMay 21 2020, 10:06 PM

Patch merged and version 1.1.0 released.

dom_walden added a subscriber: dom_walden.

When I go to https://tools.wmflabs.org/svgtranslate/File:T250607.svg, get a message: "This file can not be translated with this tool because it contains unsupported SVG (nested tspan) in the following text: second inside tspan" (when English interface language is selected).

I tested loading a few different nested SVG files on https://svgtranslate.toolforge.org/.

For regression purposes, I also tested loading some non-nested SVG files.

Thanks for fixing! :-D The bug-request seems to be solve

If I check https://svgtranslate.toolforge.org/File:SVG_Translate_textpath.svg (mentioned in T250607#6122866 ) I still get. "This file does not have any labels available for translation. Please pick another image."

Maybe the bug-description was incomplete defined: It it runs into an unsupported pattern it should report, that the file contains unsupported patten (maybe not so important which one), instead of telling the file does not contain any label. So make a difference between chrashing script(?) and a script that finished without finding any text, or change the errormessae to "This tool did not find any labels, it may not contain any, or it chrashed on unsupported pattern. Please pick another image." Otherwise the errormessage is very missleading.

related bugs

  • T252347 is for supporting textPath
  • T248252 is for skipping unsupported pattern

Anyway I think this patch catches maybe most of the currently unsupported Svg-pattern.

ifried closed this task as Resolved.Jun 9 2020, 8:55 PM
ifried moved this task from Product sign-off to Done on the Community-Tech (Kanban-2019-20-Q4) board.

As the bug has now been reported as solved, I'm closing this ticket. The other bugs listed in the comment above can be reviewed separately. Thanks!