Page MenuHomePhabricator

Partial translations result in the fallback language being duplicated in the SVG
Closed, ResolvedPublic3 Estimated Story Points

Description

When writing a partial translation into an SVG, any strings that are left out are filled with their values from the fallback language. This results in what appears to be a correct translation, because we do want to fallback when a particular string is missing, but we don't want to do this by actually duplicating the strings in the file.

This bug is my fault, for introducing SvgFile::setTranslations().

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

@Samwilson My understanding is that the way we do this is by omitting adding translations for labels that are left out and it will automatically default to showing the fallback language for those labels. Is that correct?

Yeah that's what's supposed to happen. :) So the actual labels in the file should only be in the languages they say they are (apart from the fallback). It's up to the renderer to resolve the missing ones and fall back appropriately; we're currently forcing it to do so by actually inserting the values (and ending up with things like <text systemLanguage="eo">Hello</text> instead of <text systemLanguage="eo">Saluton</text>).

Niharika set the point value for this task to 3.Feb 7 2019, 12:11 AM
Niharika moved this task from Needs Discussion to Up Next (May 6-17) on the Community-Tech board.

I tested this with the following on the staging instance.

image.png (890×1 px, 87 KB)

I downloaded the file after adding those translations. I see the following in the SVG -

<text xml:space="preserve" x="330" y="188.07648" id="text2989-es" sodipodi:linespacing="125%" systemLanguage="es">
    <tspan x="330" y="188.07648" text-decoration="normal" font-style="normal" font-weight="normal" id="tspan2991-es" sodipodi:role="line">Hello! How</tspan>
    <tspan x="330" y="238.07648" text-decoration="normal" font-style="normal" font-weight="normal" id="tspan2993-es" sodipodi:role="line">beeeeeeee</tspan>
</text>

and...

<text xml:space="preserve" x="101.42857" y="318.64789" id="text2995-es" sodipodi:linespacing="125%" systemLanguage="es">
    <tspan x="101.42857" y="318.64789" text-decoration="normal" font-style="normal" font-weight="normal" id="tspan2997-es" sodipodi:role="line">I'm
well,</tspan>
    <tspan x="101.42857" y="368.64789" text-decoration="normal" font-style="normal" font-weight="normal"
id="tspan2999-es" sodipodi:role="line">baaaaaaaa</tspan>
  </text>

My understanding is that this should not be happening. Is that correct? @MaxSem @Samwilson @Mooeypoo

@Niharika, can't repro - let's look at this in person tomorrow.

@MaxSem Should we move this back to In Dev per our desk conversation the other day?

Can't do this. The <select>s choose between one level of nested elements (<text> in our case). Falling back between the <tspan>s appears to be impossible.

Illustration:


Here, commenting out one of the <tspan> elements doesn't make it fall back, instead it just disappears:
test.png (140×320 px, 2 KB)

To me, it looks like the code does the right thing. Everything that we could fix has already been fixed (<text> elements aren't getting duplicated anymore).

@MaxSem - I am not sure I understand.

Can't do this. The <select>s choose between one level of nested elements (<text> in our case). Falling back between the <tspan>s appears to be impossible.

Doesn't that basically mean that we are still duplicating the labels when the user doesn't provide a translation if there are tspans in the file? A majority of files use tspan elements.
Can you say more on why falling back between tspans seems impossible?

@Mooeypoo @Samwilson Do you have any thoughts on this?

No, we're no longer duplicating the labels since 1378e56d03a7b8f5b0b738cd2012a05a8e4ac099. I'm not sure about the extra other markup that's being inserted, I don't think it matters though and in most cases probably doesn't change anything (and the bits where it does are tracked in other tasks).

I reckon this can be closed.

Niharika moved this task from QA to Q3 2018-19 on the Community-Tech-Sprint board.
Niharika moved this task from In progress to Done on the SVG Translate Tool board.