Broken UI and errors in Fluent string with empty attribute
Here's the string https://pontoon.mozilla.org/hye/firefox/browser/browser/places.ftl/?search=places-open-in-container-tab&string=243435
My checks were triggered, because Pontoon committed a non parseable entity to hg
places-open-in-container-tab =
.label = Բացել նոր ներդիրում
.accesskey =
I'm not sure how the localizer got there, but now Pontoon breaks in all possible ways:
- Switching to FTL mode, then back, will hide the input fields.
- Trying to reject or approve the translation will result in a blank page.
Looks like there's a tab character in the accesskey value, which allowed the user to submit a broken string in first place.
So the string contains a tab character, but it gets removed when we serialize the string to send it to VCS or show it in the FTL source editor.
@eemeli Does that look like a bug in python-fluent? If tab character is valid in the value, why do we drop it on re-serialization?
from fluent.syntax import ast, FluentParser, FluentSerializer
parser = FluentParser()
serializer = FluentSerializer()
string = """places-open-in-container-tab =
.label = Բացել նոր ներդիրում
.accesskey =
"""
string
'places-open-in-container-tab =\n .label = Բացել նոր ներդիրում\n .accesskey = \t\n'
serializer.serialize(parser.parse(string))
'places-open-in-container-tab =\n .label = Բացել նոր ներդիրում\n .accesskey = \n'
Yes, that looks like a python-fluent bug. According to the spec, only spaces are included in blank_inline, and effectively tabs should be considered here as inline_text, i.e. a part of the message's value.
The syntax js parser in the playground also doesn't show the tab as part of the TextElement.
Seems like recent updates to the editor have fixed the Pontoon side of the issue. 👍
@eemeli Do we track the python-fluent part somewhere?
@mathjazz This has been fixed in python-fluent, but hasn't yet been included in a release of it. That's currently blocked by waiting for projectfluent/python-fluent#180 to land. If you feel like reviewing that we could get this forward... 😇