appstream icon indicating copy to clipboard operation
appstream copied to clipboard

Add as_license_get_name() API

Open pwithnall opened this issue 3 years ago • 2 comments
trafficstars

For some functionality we want to implement in gnome-software it would be useful to have an API like:

const gchar		*as_license_get_name (const gchar *license_id);

It would return a translated string containing the human readable name of the given SPDX license ID.

This would only work for individual license IDs, not SPDX expressions because building a general-purpose translatable string to represent an arbitrary SPDX expression would be hard, and the end result would be very confusing to users (even if it could be perfectly localised).

For the case of a non-trivial SPDX expression, gnome-software will probably use a generic fallback string like “this app is licensed under a combination of free software licenses” or something.

The human-readable name of an SPDX license ID is given by the name field in licenses.json. Unfortunately it doesn’t look like they provide translated versions, so libappstream would have to carry the translations.

pwithnall avatar Jul 25 '22 15:07 pwithnall

This kind of ties into my long-term plan to make the whole licensing business more human-friendly (which would also involve AppStream's own license overview pages at freedesktop.org, so people have a better reference as to what AppStream thinks of their license, as well as translated quick overview information as to what a license does and doesn't permit and what that means. So, a bit like https://choosealicense.com/licenses/gpl-3.0/ but from an end-user point of view, and not just from a developer seeking to apply a license point of view.

For this particular issue, it's possibly a good idea to have the Python code generate a C struct from the JSON and export that, rather than having it generate a text file or embed the JSON and parse it every time we need license information... (this stuff is very performance sensitive when building AppStream metadata)

What I don't get is the localization - isn't "GPL" always "GPL" in every language? Or do you mean a literal translation of a string like "GNU General Public License"? If it's the latter, is that legally okay? Can we trust translators to translate license names properly so we don't run into issues, or should the translation be a static-ish list of officially legally vetted name translations?

ximion avatar Jul 25 '22 15:07 ximion

That sounds like an appealing long-term plan!

I can’t speak authoritatively on localisation, but I certainly think the “or later” wording of licenses like GPL-3.0-or-later could be localised. As one data point, it looks like CC localise their license names on their official website.

Trusting translators to translate the names correctly would be a matter of providing appropriate guidance and perhaps some occasional review.

It would probably make sense to get input from some translation teams before committing to a particular approach, as they will know much better than me what the issues will be.

(I should say that I don’t plan to work on this at the moment, which is why I filed it as an issue rather than an MR. I’m away until October.)

pwithnall avatar Jul 25 '22 15:07 pwithnall

There is prior art here.

GtkAboutDialog translates the names of a list of known licenses. Here is Nautilus' About dialog on a French system:

Capture d’écran de 2023-02-28 14-25-47

Licence publique générale GNU, version 3 ou ultérieure

And here is the À propos dialog of Kdenlive:

Capture d’écran de 2023-02-28 14-30-30

License : Version 3 de la License Générale Publique GNU

(I can't help but notice that French GTK calls it the LPG GNU, whereas French KDE calls it LGP GNU. 🤷🏻)

wjt avatar Feb 28 '23 14:02 wjt

You can give as_get_license_name a try now! (not sure if the name stays, might become as_spdx_get_license_name before 1.0 is released)

This should be in the 1.0 AppStream release soon, and hopefully this implementation is performant enough (if not, we can always use perfect hashsums later if needed).

ximion avatar Sep 25 '23 02:09 ximion

So, I had to partially revert this, as lawyers told me that you don't just simply translate the license name, it's part of the license just as much as the text. So we would need an official translation to make this work.

Annoyingly, SPDX embeds stuff that isn't part of the license name itself into the license as well (like "or later"), so, as a compromise the API will now produce translated names for some licenses, but not all.

This is definitely better, especially because some of the licenses have actually names in other languages, like French, and are inherently harder to translate. Of course, the as_spdx_get_license_name API stays, so you can use it to get a long-form license name, that just sometimes may not be translated for legal or practical reasons.

ximion avatar Oct 08 '23 04:10 ximion