return ret;
}
+ Locale fallback() const
+ {
+ // blah_BLAH
+ if ( _country.hasCode() )
+ {
+ return Locale(_language.code());
+ }
+ else
+ {
+ if (_language.code() == "en" )
+ { // no fallback for english
+ return Locale();
+ }
+ else if ( (_language.code() == "") )
+ { // for empty locale, we give up
+ return Locale();
+ }
+ else
+ { // for all others, english
+ return Locale("en");
+ }
+ }
+ return Locale();
+ }
+
private:
LanguageCode _language;
std::string Locale::name() const
{ return _pimpl->name(); }
+ ///////////////////////////////////////////////////////////////////
+ //
+ // METHOD NAME : Locale::
+ // METHOD TYPE :
+ //
+ Locale Locale::fallback() const
+ { return _pimpl->fallback(); }
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
/** Return the name made of language and country name. */
std::string name() const;
+ /** Return a fallback locale for this locale, when giving up, returns empty Locale() */
+ Locale fallback() const;
+
private:
/** Pointer to implementation */
RW_pointer<Impl> _pimpl;
#include <iostream>
//#include "zypp/base/Logger.h"
+#include "zypp/ZYppFactory.h"
+#include "zypp/ZYpp.h"
+
#include "zypp/base/String.h"
#include "zypp/TranslatedText.h"
{ setText(text, lang); }
std::string text( const Locale &lang = Locale() ) const
- { return translations[lang]; }
+ {
+ // if there is no translation for this
+ if ( translations[lang].empty() )
+ {
+ // first, detect the locale
+ ZYpp::Ptr z = getZYpp();
+ Locale detected_lang( z->getTextLocale() );
+ if ( translations[detected_lang].empty() )
+ {
+ Locale fallback_locale = detected_lang.fallback();
+ while ( fallback_locale != Locale() )
+ {
+ if ( ! translations[fallback_locale].empty() )
+ return translations[fallback_locale];
+
+ fallback_locale = fallback_locale.fallback();
+ }
+ // we gave up, there are no translations with fallbacks
+ // last try, emtpy locale
+ Locale empty_locale;
+ if ( ! translations[empty_locale].empty() )
+ return translations[empty_locale];
+ else
+ return std::string();
+ }
+ else
+ {
+ return translations[detected_lang];
+ }
+ }
+ else
+ {
+ return translations[lang];
+ }
+ }
std::set<Locale> locales() const
{
{ return std::string(); }
Vendor SuseTagsPackageImpl::vendor() const
- { return Vendor(); }
+ { return _source.vendor(); }
Label SuseTagsPackageImpl::license() const
{ return _license; }
RPMPackageImpl::RPMPackageImpl(
const RpmHeader::constPtr data
)
- : _summary(data->tag_summary()),
+ : _summary(data->tag_summary(), Locale("en")),
_description(),
_buildtime(data->tag_buildtime()),
_buildhost(data->tag_buildhost()),
_dir_sizes(parsed.dirSizes),
#endif
{
- _description.setText(data->tag_description());
+ // we know we are reading english.
+ _description.setText(data->tag_description(), Locale("en"));
data->tag_du(_disk_usage);
}