Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

component: Don't strip ";" from keywords before translating them #320

Merged
merged 1 commit into from
Jun 3, 2021

Conversation

iainlane
Copy link
Contributor

@iainlane iainlane commented Jun 3, 2021

We're failing to translate strings now, when the keywords ends with a
";" as they almost always do, e.g.:

Keywords=Drivers;Repositories;Repository;PPA;

because we strip the trailing semicolon off before translating, in order
to avoid having empty elements in the output.

Instead what we can do is process the list passed to
as_component_set_keywords and remove empties at that point. This
allows us to not modify the string retrieved from the desktop file, and
fixes finding translations.

@iainlane
Copy link
Contributor Author

iainlane commented Jun 3, 2021

I found this while I was trying to run asgen locally to reproduce ximion/appstream-generator#92, no idea why this didn't happen all the time, new code?

@iainlane iainlane force-pushed the keywords-no-strip-semicolon branch from 3bdc911 to a0c0425 Compare June 3, 2021 12:39
We're failing to translate strings now, when the keywords ends with a
";" as they almost always do, e.g.:

  Keywords=Drivers;Repositories;Repository;PPA;

because we strip the trailing semicolon off before translating, in order
to avoid having empty elements in the output.

Instead what we can do is process the list passed to
`as_component_set_keywords` and remove empties at that point. This
allows us to not modify the string retrieved from the desktop file, and
fixes finding translations.
@iainlane iainlane force-pushed the keywords-no-strip-semicolon branch from a0c0425 to 3aa36e0 Compare June 3, 2021 12:50
@ximion
Copy link
Owner

ximion commented Jun 3, 2021

Just to make sure I understood the problem: AS drops the trailing semicolon first before the Ubuntu-specific l10n-hook is invoked, therefore the corresponding string won't be found in the translation file?
I don't know why we didn't see this yet... Potentially the respective code was there, but not used in asgen yet...
The patch itself looks good to me, pushing the sanitization code into as_component_set_keywords is a good idea as well.

@iainlane
Copy link
Contributor Author

iainlane commented Jun 3, 2021

You got it. As we're ending up passing this string (which came from the .desktop file) to gettext then we can't modify it at all before doing that, or it won't be found.

@ximion
Copy link
Owner

ximion commented Jun 3, 2021

A unit test would be nice for this, as I am breaking Ubuntu far too easily... But that's also a bigger thing to write (although with the new callback function, we could just mock all the mo-file reading and extraction...), so let's merge this bugfix first :-)

@ximion ximion merged commit b6c9439 into ximion:master Jun 3, 2021
@iainlane iainlane deleted the keywords-no-strip-semicolon branch June 3, 2021 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants