//
Locale Locale::fallback() const
{ return _pimpl->fallback(); }
+
+ Locale Locale::bestMatch( const LocaleSet & avLocales_r, const Locale & requested_r )
+ {
+ if ( ! avLocales_r.empty() )
+ {
+ for ( Locale check( requested_r ); check != noCode; check = check.fallback() )
+ {
+ if ( avLocales_r.find( check ) != avLocales_r.end() )
+ return check;
+ }
+ }
+ return noCode;
+ }
+
+
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ class Locale;
+ typedef std::tr1::unordered_set<Locale> LocaleSet;
+
///////////////////////////////////////////////////////////////////
//
// CLASS NAME : Locale
/** Return a fallback locale for this locale, when giving up, returns empty Locale() */
Locale fallback() const;
+ public:
+
+ /** Return the best match for \ref Locale \c requested_r within the available \c avLocales_r.
+ *
+ * If neither \c requested_r nor any of it's \ref fallback locales are available,
+ * \ref Locale::noCode is returned.
+ */
+ static Locale bestMatch( const LocaleSet & avLocales_r, const Locale & requested_r );
+
private:
/** Pointer to implementation */
RW_pointer<Impl> _pimpl;
}
//@}
- ///////////////////////////////////////////////////////////////////
-
- typedef std::tr1::unordered_set<Locale> LocaleSet;
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////