Propagate ZConfig::setTextLocale to pool. (bnc#588850)
authorMichael Andres <ma@suse.de>
Fri, 26 Mar 2010 18:23:37 +0000 (19:23 +0100)
committerMichael Andres <ma@suse.de>
Fri, 26 Mar 2010 18:30:39 +0000 (19:30 +0100)
zypp/ZConfig.cc
zypp/sat/Pool.cc
zypp/sat/Pool.h
zypp/sat/detail/PoolImpl.cc
zypp/sat/detail/PoolImpl.h

index f39e3ab..16bf5ef 100644 (file)
@@ -27,6 +27,8 @@ extern "C"
 #include "zypp/PathInfo.h"
 #include "zypp/parser/IniDict.h"
 
+#include "zypp/sat/Pool.h"
+
 using namespace std;
 using namespace zypp::filesystem;
 using namespace zypp::parser;
@@ -583,6 +585,8 @@ namespace zypp
     {
       WAR << "Overriding text locale (" << _pimpl->cfg_textLocale << "): " << locale_r << endl;
       _pimpl->cfg_textLocale = locale_r;
+#warning prefer signal
+      sat::Pool::instance().setTextLocale( locale_r );
     }
   }
 
index b07df4e..4e5c072 100644 (file)
@@ -179,6 +179,9 @@ namespace zypp
 
    /////////////////////////////////////////////////////////////////
 
+    void Pool::setTextLocale( const Locale & locale_r )
+    { myPool().setTextLocale( locale_r ); }
+
     void Pool::setRequestedLocales( const LocaleSet & locales_r )
     { myPool().setRequestedLocales( locales_r ); }
 
index bcd92e3..b60d6bc 100644 (file)
@@ -167,6 +167,11 @@ namespace zypp
       public:
         /** \name Requested locales. */
         //@{
+       /** Set the default language for retrieving translated texts.
+        * Updated when calling \ref ZConfig::setTextLocale.
+        */
+       void setTextLocale( const Locale & locale_r );
+
         /** Set the requested locales.
          * Languages to be supported by the system, e.g. language specific
          * packages to be installed.
index 68f9d33..9ead4a1 100644 (file)
@@ -248,19 +248,8 @@ namespace zypp
         }
         if ( ! _pool->languages )
         {
-          std::vector<std::string> fallbacklist;
-          for ( Locale l( ZConfig::instance().textLocale() ); l != Locale::noCode; l = l.fallback() )
-          {
-            fallbacklist.push_back( l.code() );
-          }
-          dumpRangeLine( MIL << "pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
-
-          std::vector<const char *> fallbacklist_cstr;
-          for_( it, fallbacklist.begin(), fallbacklist.end() )
-          {
-            fallbacklist_cstr.push_back( it->c_str() );
-          }
-          ::pool_set_languages( _pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
+         // initial seting
+         const_cast<PoolImpl*>(this)->setTextLocale( ZConfig::instance().textLocale() );
         }
       }
 
@@ -394,6 +383,23 @@ namespace zypp
         MIL << "New Solver Locales: " << locale2Solver << endl;
       }
 
+      void PoolImpl::setTextLocale( const Locale & locale_r )
+      {
+       std::vector<std::string> fallbacklist;
+       for ( Locale l( locale_r ); l != Locale::noCode; l = l.fallback() )
+       {
+         fallbacklist.push_back( l.code() );
+       }
+       dumpRangeLine( MIL << "pool_set_languages: ", fallbacklist.begin(), fallbacklist.end() ) << endl;
+
+       std::vector<const char *> fallbacklist_cstr;
+       for_( it, fallbacklist.begin(), fallbacklist.end() )
+       {
+         fallbacklist_cstr.push_back( it->c_str() );
+       }
+       ::pool_set_languages( _pool, &fallbacklist_cstr.front(), fallbacklist_cstr.size() );
+      }
+
       void PoolImpl::setRequestedLocales( const LocaleSet & locales_r )
       {
         depSetDirty( "setRequestedLocales" );
index b5f59cf..38afc60 100644 (file)
@@ -199,6 +199,7 @@ namespace zypp
         public:
           /** \name Requested locales. */
           //@{
+         void setTextLocale( const Locale & locale_r );
           void setRequestedLocales( const LocaleSet & locales_r );
           bool addRequestedLocale( const Locale & locale_r );
           bool eraseRequestedLocale( const Locale & locale_r );