Only add localized package descriptions if component has no description

This will result in people either getting a translated description for
their language which matches what upstream provided, or getting the
fallback description.
This makes the code a bit simpler and might be more what upstream
projects and users expect.

I am not 100% sure yet that this is a good decision though, since it
means that there might be less translations...
On the other hand, we don't get completely different descriptions for
some languages, which might be very confusing.
This commit is contained in:
Matthias Klumpp 2016-08-30 05:30:29 +02:00
parent 2bcd73802e
commit b42c916733

View File

@ -233,20 +233,20 @@ public:
if (cpt.getKind () == ComponentKind.DESKTOP_APP) {
auto flags = cpt.getValueFlags;
cpt.setValueFlags (flags | AsValueFlags.NO_TRANSLATION_FALLBACK);
scope (exit) cpt.setActiveLocale ("C");
bool desc_from_pkg_hint_added = false;
foreach (ref lang, ref desc; pkg.description) {
cpt.setActiveLocale (lang);
if (cpt.getDescription ().empty) {
cpt.setDescription (desc, lang);
if (!desc_from_pkg_hint_added) {
addHint (cpt, "description-from-package", ["locale": lang]);
desc_from_pkg_hint_added = true;
}
cpt.setActiveLocale ("C");
if (cpt.getDescription ().empty) {
// component doesn't have a long description, add one from
// the packaging.
auto desc_added = false;
foreach (ref lang, ref desc; pkg.description) {
cpt.setDescription (desc, lang);
desc_added = true;
}
if (desc_added)
addHint (cpt, "description-from-package");
}
}
}
}