diff --git a/src/libcalamares/GlobalStorage.cpp b/src/libcalamares/GlobalStorage.cpp index 32ae02191..3fc7d0fa9 100644 --- a/src/libcalamares/GlobalStorage.cpp +++ b/src/libcalamares/GlobalStorage.cpp @@ -125,33 +125,6 @@ GlobalStoragePythonWrapper::insert( const std::string& key, CalamaresPython::variantFromPyObject( value ) ); } -bp::list -GlobalStoragePythonWrapper::gettext_languages() const -{ - bp::list pyList; - QVariant localeConf_ = m_gs->value( "localeConf" ); - if ( localeConf_.canConvert< QVariantMap >() ) - { - QVariant lang_ = localeConf_.value< QVariantMap >()[ "LANG" ]; - if ( lang_.canConvert< QString >() ) - { - QString lang = lang_.value< QString >(); - pyList.append( lang.toStdString() ); - if ( lang.indexOf( '.' ) > 0) - { - lang.truncate( lang.indexOf( '.' ) ); - pyList.append( lang.toStdString() ); - } - if ( lang.indexOf( '_' ) > 0) - { - lang.truncate( lang.indexOf( '_' ) ); - pyList.append( lang.toStdString() ); - } - } - } - return pyList; -} - bp::list GlobalStoragePythonWrapper::keys() const { diff --git a/src/libcalamares/GlobalStorage.h b/src/libcalamares/GlobalStorage.h index 92def182e..ff8d32682 100644 --- a/src/libcalamares/GlobalStorage.h +++ b/src/libcalamares/GlobalStorage.h @@ -87,10 +87,6 @@ public: int remove( const std::string& key ); boost::python::api::object value( const std::string& key ) const; - // Special case to simplify Python code, gets localeConf["LANG"] - // from the global store, in list form with language variants - // expanded (e.g [ "en_GB.UTF-8", "en_GB", "en" ] ). - boost::python::list gettext_languages() const; private: Calamares::GlobalStorage* m_gs; }; diff --git a/src/libcalamares/PythonJob.cpp b/src/libcalamares/PythonJob.cpp index f6ae92384..bad463fa7 100644 --- a/src/libcalamares/PythonJob.cpp +++ b/src/libcalamares/PythonJob.cpp @@ -86,8 +86,7 @@ BOOST_PYTHON_MODULE( libcalamares ) .def( "insert", &CalamaresPython::GlobalStoragePythonWrapper::insert ) .def( "keys", &CalamaresPython::GlobalStoragePythonWrapper::keys ) .def( "remove", &CalamaresPython::GlobalStoragePythonWrapper::remove ) - .def( "value", &CalamaresPython::GlobalStoragePythonWrapper::value ) - .def( "gettext_languages", &CalamaresPython::GlobalStoragePythonWrapper::gettext_languages ); + .def( "value", &CalamaresPython::GlobalStoragePythonWrapper::value ); // libcalamares.utils submodule starts here bp::object utilsModule( bp::handle<>( bp::borrowed( PyImport_AddModule( "libcalamares.utils" ) ) ) ); @@ -217,6 +216,14 @@ BOOST_PYTHON_MODULE( libcalamares ) "Applying the function to a string obscured by this function will result " "in the original string." ); + + + bp::def( + "gettext_languages", + &CalamaresPython::gettext_languages, + bp::args(), + "Returns list of languages (most to least-specific) for gettext." + ); } diff --git a/src/libcalamares/PythonJobApi.cpp b/src/libcalamares/PythonJobApi.cpp index 10b66b39f..1e84d3130 100644 --- a/src/libcalamares/PythonJobApi.cpp +++ b/src/libcalamares/PythonJobApi.cpp @@ -208,4 +208,31 @@ obscure( const std::string& string ) return CalamaresUtils::obscure( QString::fromStdString( string ) ).toStdString(); } +std::list< std::string > +gettext_languages() +{ + bp::list pyList; + QVariant localeConf_ = m_gs->value( "localeConf" ); + if ( localeConf_.canConvert< QVariantMap >() ) + { + QVariant lang_ = localeConf_.value< QVariantMap >()[ "LANG" ]; + if ( lang_.canConvert< QString >() ) + { + QString lang = lang_.value< QString >(); + pyList.append( lang.toStdString() ); + if ( lang.indexOf( '.' ) > 0) + { + lang.truncate( lang.indexOf( '.' ) ); + pyList.append( lang.toStdString() ); + } + if ( lang.indexOf( '_' ) > 0) + { + lang.truncate( lang.indexOf( '_' ) ); + pyList.append( lang.toStdString() ); + } + } + } + return pyList; +} + } diff --git a/src/libcalamares/PythonJobApi.h b/src/libcalamares/PythonJobApi.h index a3443ad76..09835b2ed 100644 --- a/src/libcalamares/PythonJobApi.h +++ b/src/libcalamares/PythonJobApi.h @@ -61,6 +61,10 @@ std::string check_target_env_output( const boost::python::list& args, std::string obscure( const std::string& string ); +std::string gettext_path(); + +std::list< std::string > gettext_languages(); + void debug( const std::string& s ); inline int _handle_check_target_env_call_error( int ec, const QString& cmd );