- // If not found, look for lang prefix (without country) instead
- for (LanguageList::const_iterator lit = lbeg; lit != lend; ++lit) {
- if (match(code, lit->second) == ApproximateMatch)
- return &lit->second;
+
+ // 2/ approximate with any known language
+ for (auto const & l : languagelist_) {
+ if (match(code, l.second) == ApproximateMatch)
+ return &l.second;
+ }
+ return nullptr;
+}
+
+
+Language const * Languages::getFromCode(string const & code,
+ set<Language const *> const & tryfirst) const
+{
+ // 1/ exact match with tryfirst list
+ for (auto const * lptr : tryfirst) {
+ if (match(code, *lptr) == ExactMatch)
+ return lptr;
+ }
+
+ // 2/ approximate match with tryfirst list
+ for (auto const * lptr : tryfirst) {
+ Match const m = match(code, *lptr);
+ if (m == ApproximateMatch || m == VeryApproximateMatch)
+ return lptr;