summaryrefslogtreecommitdiff
path: root/apt-pkg/pkgcache.cc
diff options
context:
space:
mode:
authorАлексей Шилин <rootlexx@mail.ru>2019-11-25 09:59:38 +0000
committerJulian Andres Klode <jak@debian.org>2019-11-25 09:59:38 +0000
commit19033186919b9c6d31ca3aabaacfb069a4b64f88 (patch)
tree13cc2899b6497f463d401091a9a6b8a603d9d3f3 /apt-pkg/pkgcache.cc
parent4afb07258fad5f9026ad25f579a871093a312ac5 (diff)
Search in all available description translations
When multiple translations of package descriptions are available, perform search in all of them. It allows using search patterns in any of the configured languages. Previously, only the first available translation was searched. As the result, patterns in e.g. English never matched packages which had their descriptions translated into local language. Closes: #490000
Diffstat (limited to 'apt-pkg/pkgcache.cc')
-rw-r--r--apt-pkg/pkgcache.cc48
1 files changed, 25 insertions, 23 deletions
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index ba9a39f13..160c58273 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -992,6 +992,23 @@ string pkgCache::PkgFileIterator::RelStr() /*{{{*/
return Res;
}
/*}}}*/
+// VerIterator::TranslatedDescriptionForLanguage - Return a DescIter for language/*{{{*/
+// ---------------------------------------------------------------------
+/* return a DescIter for the specified language
+ */
+pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescriptionForLanguage(StringView lang) const
+{
+ for (pkgCache::DescIterator Desc = DescriptionList(); Desc.end() == false; ++Desc)
+ if (lang == Desc.LanguageCode())
+ return Desc;
+
+ if (lang == "en")
+ return TranslatedDescriptionForLanguage("");
+
+ return DescIterator();
+}
+
+ /*}}}*/
// VerIterator::TranslatedDescription - Return the a DescIter for locale/*{{{*/
// ---------------------------------------------------------------------
/* return a DescIter for the current locale or the default if none is
@@ -1003,30 +1020,15 @@ pkgCache::DescIterator pkgCache::VerIterator::TranslatedDescription() const
for (std::vector<string>::const_iterator l = lang.begin();
l != lang.end(); ++l)
{
- pkgCache::DescIterator Desc = DescriptionList();
- for (; Desc.end() == false; ++Desc)
- if (*l == Desc.LanguageCode())
- break;
- if (Desc.end() == true)
- {
- if (*l == "en")
- {
- Desc = DescriptionList();
- for (; Desc.end() == false; ++Desc)
- if (strcmp(Desc.LanguageCode(), "") == 0)
- break;
- if (Desc.end() == true)
- continue;
- }
- else
- continue;
- }
- return Desc;
+ pkgCache::DescIterator Desc = TranslatedDescriptionForLanguage(*l);
+ if (Desc.IsGood())
+ return Desc;
}
- for (pkgCache::DescIterator Desc = DescriptionList();
- Desc.end() == false; ++Desc)
- if (strcmp(Desc.LanguageCode(), "") == 0)
- return Desc;
+
+ pkgCache::DescIterator Desc = TranslatedDescriptionForLanguage("");
+ if (Desc.IsGood())
+ return Desc;
+
return DescriptionList();
}