[Libreoffice-commits] .: l10ntools/inc l10ntools/source

Andras Timar timar at kemper.freedesktop.org
Wed Sep 21 11:34:35 PDT 2011


 l10ntools/inc/export.hxx       |    8 ----
 l10ntools/inc/helpmerge.hxx    |    5 --
 l10ntools/inc/lngmerge.hxx     |    1 
 l10ntools/inc/xmlparse.hxx     |    1 
 l10ntools/source/cfglex.l      |    3 -
 l10ntools/source/export.cxx    |   50 -------------------------
 l10ntools/source/export2.cxx   |   79 -----------------------------------------
 l10ntools/source/helpex.cxx    |    4 --
 l10ntools/source/helpmerge.cxx |   36 ------------------
 l10ntools/source/lngex.cxx     |    4 --
 l10ntools/source/lngmerge.cxx  |   18 ---------
 l10ntools/source/srclex.l      |    4 --
 l10ntools/source/xrmlex.l      |    4 --
 l10ntools/source/xrmmerge.cxx  |    3 -
 14 files changed, 220 deletions(-)

New commits:
commit b57f55cf23ef11d446330fbbadd18803b5cbcc98
Author: Andras Timar <atimar at suse.com>
Date:   Wed Sep 21 19:27:44 2011 +0200

    remove unused (and buggy) language fallback functionality
    
    Fallback to en-US is done in translations module. Fallback to
    other languages is not supported, but if we ever needed it, it
    would be easier to solve the problem in a script language
    instead of C++ in translations module.

diff --git a/l10ntools/inc/export.hxx b/l10ntools/inc/export.hxx
index 8c42647..5206540 100644
--- a/l10ntools/inc/export.hxx
+++ b/l10ntools/inc/export.hxx
@@ -181,7 +181,6 @@ public:
     sal_uInt16 nTitleRefId;
 
     ByteString sTextTyp;
-    ByteStringHashMap aFallbackData;
     ByteStringHashMap aMergedLanguages;
 
     ExportList  *pStringList;
@@ -193,8 +192,6 @@ public:
     ByteString sPForm;
 
     void Dump();
-    void addFallbackData( ByteString& sId , const ByteString& sText );
-    bool getFallbackData( ByteString& sId , ByteString& sText);
 
     void addMergedLanguage(rtl::OString& rLang);
     bool isMerged(rtl::OString& rLang);
@@ -353,9 +350,6 @@ public:
     static void getRandomName( const ByteString& sPrefix , ByteString& sRandStr , const ByteString& sPostfix  );
     static void getCurrentDir( std::string& dir );
 
-    static ByteString GetFallbackLanguage( const ByteString nLanguage );
-    static void FillInFallbacks( ResData *pResData );
-    static void FillInListFallbacks( ExportList *pList, const ByteString &nSource, const ByteString &nFallback );
     static ByteString GetTimeStamp();
     static sal_Bool ConvertLineEnds( ByteString sSource, ByteString sDestination );
     static ByteString GetNativeFile( ByteString sSource );
@@ -376,8 +370,6 @@ private:
 
     ByteString FullId();                    // creates cur. GID
 
-    bool PairedListFallback( ByteString& sText , ResData& aResData );
-
     ByteString GetPairedListID      ( const ByteString& sText );
     ByteString GetPairedListString  ( const ByteString& sText );
     ByteString StripList    ( const ByteString& sText );
diff --git a/l10ntools/inc/helpmerge.hxx b/l10ntools/inc/helpmerge.hxx
index 2553624..a160b15 100644
--- a/l10ntools/inc/helpmerge.hxx
+++ b/l10ntools/inc/helpmerge.hxx
@@ -32,7 +32,6 @@
 #include <rtl/ustrbuf.hxx>
 #include <rtl/strbuf.hxx>
 #include <memory> /* auto_ptr */
-#include "tools/isofallback.hxx"
 
 #define MOVEFILE_REPLACE_EXISTING 0x01
 
@@ -44,10 +43,6 @@ private:
     bool       bUTF8;
     bool       bHasInputList;
 
-/// Copy fallback language String (ENUS,DE) into position of the numeric language iso code
-/// @PRECOND 0 < langIdx_in < MAX_IDX
-    static void FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in );
-
 #if OSL_DEBUG_LEVEL > 2
     /// Debugmethod, prints the content of the map to stdout
     static void Dump(LangHashMap* rElem_in , const ByteString sKey_in);
diff --git a/l10ntools/inc/lngmerge.hxx b/l10ntools/inc/lngmerge.hxx
index 8aaf98d..e658817 100644
--- a/l10ntools/inc/lngmerge.hxx
+++ b/l10ntools/inc/lngmerge.hxx
@@ -53,7 +53,6 @@ private:
     bool bQuiet;
     std::vector<ByteString> aLanguages;
 
-    void FillInFallbacks( ByteStringHashMap Text );
     bool isNextGroup(  ByteString &sGroup_out , ByteString &sLine_in);
     void ReadLine( const ByteString &sLine_in , ByteStringHashMap &rText_inout );
     void WriteSDF( SvFileStream &aSDFStream , ByteStringHashMap &rText_inout ,
diff --git a/l10ntools/inc/xmlparse.hxx b/l10ntools/inc/xmlparse.hxx
index b2603c0..1c5f0d0 100644
--- a/l10ntools/inc/xmlparse.hxx
+++ b/l10ntools/inc/xmlparse.hxx
@@ -36,7 +36,6 @@
 #include "tools/string.hxx"
 #define ENABLE_BYTESTRING_STREAM_OPERATORS
 #include "tools/stream.hxx"
-#include "tools/isofallback.hxx"
 #include "export.hxx"
 #include "xmlutil.hxx"
 
diff --git a/l10ntools/source/cfglex.l b/l10ntools/source/cfglex.l
index feb2882..94648a6 100644
--- a/l10ntools/source/cfglex.l
+++ b/l10ntools/source/cfglex.l
@@ -188,10 +188,7 @@ main( int argc, char* argv[])
 		fprintf( stdout, " -g[:dtd]: enables generation of properties (dtds if :dtd is set) - in this case FileOut is the output path\n" );
 		fprintf( stdout, " -d: enables generation of *.don if work is done\n" );
 		fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
-		fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
 		fprintf( stdout, "     f1, f2,... are also elements of (de,en-US...)\n" );
-		fprintf( stdout, "     Example: -L de,es=en-US\n" );
-		fprintf( stdout, "              Restriction to de and es, en-US will be fallback for es\n" );
 		return 1;
 	}
 
diff --git a/l10ntools/source/export.cxx b/l10ntools/source/export.cxx
index d31ed2b..7bff49b 100644
--- a/l10ntools/source/export.cxx
+++ b/l10ntools/source/export.cxx
@@ -350,14 +350,6 @@ void ResData::Dump(){
     printf("\n");
 }
 
-void ResData::addFallbackData( ByteString& sId_in , const ByteString& sText_in ){
-    aFallbackData[ sId_in ] = sText_in;
-}
-bool ResData::getFallbackData( ByteString& sId_in , ByteString& sText_inout ){
-    sText_inout = aFallbackData[ sId_in ];
-    return sText_inout.Len() > 0;
-}
-
 void ResData::addMergedLanguage(rtl::OString& rLang)
 {
     aMergedLanguages[rLang] = rtl::OString(RTL_CONSTASCII_STRINGPARAM("1"));
@@ -1169,8 +1161,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
         (  pResData->sTitle[ SOURCE_LANGUAGE ].getLength()))
 
        {
-        FillInFallbacks( pResData );
-
         ByteString sGID = pResData->sGId;
         ByteString sLID;
         if ( !sGID.Len())
@@ -1255,7 +1245,6 @@ sal_Bool Export::WriteData( ResData *pResData, sal_Bool bCreateNew )
                 }
             }
     }
-    FillInFallbacks( pResData );
     if ( pResData->pStringList ) {
         ByteString sList( "stringlist" );
         WriteExportList( pResData, pResData->pStringList, sList, bCreateNew );
@@ -1476,27 +1465,6 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
     }else
         (*pCurEntry)[ m_sListLang ] = rText;
 
-    // Remember en-US fallback string, so each list has the same amount of elements
-    if ( Export::isSourceLanguage( m_sListLang ) ) {
-        if( nList == LIST_PAIRED ){
-            const ByteString sPlist("pairedlist");
-            ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sId , GetPairedListID( rLine ) , sFilename );
-            pResData->addFallbackData( sKey , rText );
-        }
-        // new fallback
-        else{
-            const ByteString sPlist("list");
-            ByteString a( pResData->sGId );
-            a.Append( "." );
-            a.Append( pResData->sId );
-            sal_Int64 x = nListIndex+1;
-            ByteString b(rtl::OString::valueOf(x));
-            ByteString sKey = MergeDataFile::CreateKey( sPlist , a , b  , sFilename );
-            pResData->addFallbackData( sKey , rText );
-        }
-        // new fallback
-    }
-
     if ( Export::isSourceLanguage( m_sListLang ) ) {
         if( nList == LIST_PAIRED ){
             (*pCurEntry)[ SOURCE_LANGUAGE ] = rLine;
@@ -1507,7 +1475,6 @@ void Export::InsertListEntry( const ByteString &rText, const ByteString &rLine )
         pList->NewSourceLanguageListEntry();
     }
 
-    //printf("Export::InsertListEntry ResData.id = %s ResData.ListData = %s\n",pResData->sId.GetBuffer() ,(*pCurEntry)[ m_sListLang ].GetBuffer());
     nListIndex++;
 }
 
@@ -2135,23 +2102,6 @@ void Export::MergeRest( ResData *pResData, sal_uInt16 nMode )
                             if( !bText )
                                 bText = pEntrys->GetTransex3Text( sText , STRING_TYP_TEXT, SOURCE_LANGUAGE , sal_False );
 
-                            // Use fallback, if data is missing in sdf file
-                            if( !bText && bPairedList )
-                            {
-                                if( pResData->isMerged( sCur ) )
-                                    break;
-                                const ByteString sPlist("pairedlist");
-                                ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
-                                bText = pResData->getFallbackData( sKey , sText );
-                            }
-                            else if ( !bText ) // new fallback
-                            {
-                                if( pResData->isMerged( sCur ) ) break;
-                                const ByteString sPlist("list");
-                                ByteString sKey = MergeDataFile::CreateKey( sPlist , pResData->sGId , pResData->sId , sFilename );
-                                bText = pResData->getFallbackData( sKey , sText );
-                            } // new fallback
-
                             if ( bText && sText.Len())
                             {
                                 if ( nIdx == 1 )
diff --git a/l10ntools/source/export2.cxx b/l10ntools/source/export2.cxx
index 1150d3e..60ca704 100644
--- a/l10ntools/source/export2.cxx
+++ b/l10ntools/source/export2.cxx
@@ -30,7 +30,6 @@
 #include "precompiled_l10ntools.hxx"
 #include "export.hxx"
 #include <tools/datetime.hxx>
-#include <tools/isofallback.hxx>
 #include <stdio.h>
 #include <osl/time.h>
 #include <osl/process.h>
@@ -378,84 +377,6 @@ void Export::InitForcedLanguages( bool bMergeMode ){
 }
 
 /*****************************************************************************/
-ByteString Export::GetFallbackLanguage( const ByteString nLanguage )
-/*****************************************************************************/
-{
-    rtl::OString sFallback=nLanguage;
-    GetIsoFallback( sFallback );
-    return sFallback;
-}
-
-/*****************************************************************************/
-void Export::FillInFallbacks( ResData *pResData )
-/*****************************************************************************/
-{
-    for (size_t n = 0; n < aLanguages.size(); ++n)
-    {
-        ByteString sCur = aLanguages[ n ];
-        if (isAllowed(sCur))
-        {
-            ByteString nFallbackIndex = GetFallbackLanguage( sCur );
-            if( nFallbackIndex.Len() )
-            {
-                if (pResData->sText[ sCur ].isEmpty())
-                    pResData->sText[ sCur ] =
-                        pResData->sText[ nFallbackIndex ];
-
-                if (pResData->sHelpText[ sCur ].isEmpty())
-                    pResData->sHelpText[ sCur ] =
-                        pResData->sHelpText[ nFallbackIndex ];
-
-                if (pResData->sQuickHelpText[ sCur ].isEmpty())
-                    pResData->sQuickHelpText[ sCur ] =
-                        pResData->sQuickHelpText[ nFallbackIndex ];
-
-                if (!pResData->sTitle[ sCur ].isEmpty())
-                    pResData->sTitle[ sCur ] =
-                        pResData->sTitle[ nFallbackIndex ];
-
-                if ( pResData->pStringList )
-                    FillInListFallbacks(
-                        pResData->pStringList, sCur, nFallbackIndex );
-
-                if ( pResData->pPairedList )
-                    FillInListFallbacks(
-                        pResData->pPairedList, sCur, nFallbackIndex );
-
-                if ( pResData->pFilterList )
-                    FillInListFallbacks(
-                        pResData->pFilterList, sCur, nFallbackIndex );
-
-                if ( pResData->pItemList )
-                    FillInListFallbacks(
-                        pResData->pItemList, sCur, nFallbackIndex );
-
-                if ( pResData->pUIEntries )
-                    FillInListFallbacks(
-                        pResData->pUIEntries, sCur, nFallbackIndex );
-            }
-        }
-    }
-}
-
-/*****************************************************************************/
-void Export::FillInListFallbacks(
-    ExportList *pList, const ByteString &nSource, const ByteString &nFallback )
-/*****************************************************************************/
-{
-    for (size_t i = 0; i < pList->size(); ++i)
-    {
-        ExportListEntry *pEntry = (*pList)[ i ];
-        if ( (*pEntry )[nSource].isEmpty() )
-        {
-            ( *pEntry )[ nSource ] = ( *pEntry )[ nFallback ];
-            ByteString x = ( *pEntry )[ nSource ];
-            ByteString y = ( *pEntry )[ nFallback ];
-        }
-    }
-}
-
-/*****************************************************************************/
 ByteString Export::GetTimeStamp()
 /*****************************************************************************/
 {
diff --git a/l10ntools/source/helpex.cxx b/l10ntools/source/helpex.cxx
index 20b5e3f..5c94b92 100644
--- a/l10ntools/source/helpex.cxx
+++ b/l10ntools/source/helpex.cxx
@@ -181,10 +181,6 @@ void Help()
     fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
     fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
     fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (en-US,fr,de...)\n" );
-    fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
-    fprintf( stdout, "     f1, f2,... are also elements of (en-US,fr,de...)\n" );
-    fprintf( stdout, "     Example: -L fr=en-US\n" );
-    fprintf( stdout, "              Restriction to fr, en-US will be fallback for fr\n" );
     fprintf( stdout, " -LF: Force the creation of that languages\n" );
 
 }
diff --git a/l10ntools/source/helpmerge.cxx b/l10ntools/source/helpmerge.cxx
index 8fa37a3..9e744b2 100644
--- a/l10ntools/source/helpmerge.cxx
+++ b/l10ntools/source/helpmerge.cxx
@@ -48,38 +48,6 @@
 #include <direct.h>
 #endif
 
-/*****************************************************************************/
-void HelpParser::FillInFallbacks( LangHashMap& rElem_out, ByteString sLangIdx_in ){
-/*****************************************************************************/
-    static const ByteString ENGLISH_LANGUAGECODE( "en-US" );
-    ByteString sCur;
-    XMLElement* pTmp     = NULL;
-    XMLElement* pTmp2    = NULL;
-
-    sCur = sLangIdx_in;
-    rtl::OString sFallback( sCur );
-    GetIsoFallback( sFallback );
-    if( (rElem_out.find( sFallback ) != rElem_out.end()) && rElem_out[ sFallback ] != NULL ){
-        pTmp2 = rElem_out[ sFallback ];
-        pTmp = new XMLElement( *pTmp2 )  ; // Copy
-        pTmp->SetPos( pTmp2->GetPos()+1 );
-        pTmp->ChangeLanguageTag( String( sLangIdx_in , RTL_TEXTENCODING_ASCII_US) );
-        rElem_out[ sLangIdx_in ] = pTmp;
-        pTmp2 = NULL;
-    }
-    else if( (rElem_out.find( ENGLISH_LANGUAGECODE ) != rElem_out.end()) && rElem_out[ ENGLISH_LANGUAGECODE ] != NULL ){// No English
-        pTmp2 = rElem_out[ ENGLISH_LANGUAGECODE ];
-        pTmp = new XMLElement( *pTmp2 )  ; // Copy
-        pTmp->SetPos( pTmp2->GetPos()+1 );
-        pTmp->ChangeLanguageTag( String( sLangIdx_in , RTL_TEXTENCODING_ASCII_US) );
-        rElem_out[ sCur ] = pTmp;
-        pTmp2 = NULL;
-    }else{
-        fprintf(stdout,"ERROR: No Fallback found for language %s:\n",sCur.GetBuffer());
-        rElem_out[ sCur ]=new XMLElement(); // Use dummy element
-    }
-}
-
 #if OSL_DEBUG_LEVEL > 2
 void HelpParser::Dump(XMLHashMap* rElem_in)
 {
@@ -201,10 +169,6 @@ bool HelpParser::CreateSDF(
         for( unsigned int n = 0; n < aLanguages.size(); n++ )
         {
             sCur = aLanguages[ n ];
-            if(pElem->find( sCur )==pElem->end())
-            {
-                FillInFallbacks( *pElem , sCur );
-            }
             pXMLElement = (*pElem)[ sCur ];
 
             if( pXMLElement != NULL )
diff --git a/l10ntools/source/lngex.cxx b/l10ntools/source/lngex.cxx
index 70709f3..1d7827a 100644
--- a/l10ntools/source/lngex.cxx
+++ b/l10ntools/source/lngex.cxx
@@ -159,10 +159,6 @@ void Help()
     fprintf( stdout, " FileOut:  Destination file (*.*)\n" );
     fprintf( stdout, " DataBase: Mergedata (*.sdf)\n" );
     fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
-    fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
-    fprintf( stdout, "     f1, f2,... are also elements of (de,en-US...)\n" );
-    fprintf( stdout, "     Example: -L de,es=en-US\n" );
-    fprintf( stdout, "              Restriction to de and es, en-US will be fallback for es\n" );
 }
 
 /*****************************************************************************/
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index 8281073..f166595 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -86,23 +86,6 @@ LngParser::~LngParser()
 }
 
 /*****************************************************************************/
-void LngParser::FillInFallbacks( ByteStringHashMap Text )
-/*****************************************************************************/
-{
-    ByteString sCur;
-    for( unsigned int n = 0; n < aLanguages.size(); n++ ){
-        sCur = aLanguages[ n ];
-
-        if( Export::isAllowed( sCur ) ){
-            ByteString sFallbackLang = Export::GetFallbackLanguage( sCur );
-            if( sFallbackLang.Len() ){
-                Text[ sCur ] = Text[ sFallbackLang ];
-            }
-        }
-    }
-}
-
-/*****************************************************************************/
 sal_Bool LngParser::CreateSDF(
     const ByteString &rSDFFile, const ByteString &rPrj,
     const ByteString &rRoot )
@@ -163,7 +146,6 @@ sal_Bool LngParser::CreateSDF(
     if ( bExport ) {
            ByteString sTimeStamp( Export::GetTimeStamp());
         ByteString sCur;
-        FillInFallbacks( rText_inout );
         for( unsigned int n = 0; n < aLanguages.size(); n++ ){
             sCur = aLanguages[ n ];
             ByteString sAct = rText_inout[ sCur ];
diff --git a/l10ntools/source/srclex.l b/l10ntools/source/srclex.l
index eb2b6af..d357d5c 100644
--- a/l10ntools/source/srclex.l
+++ b/l10ntools/source/srclex.l
@@ -273,10 +273,6 @@ main( int argc, char* argv[])
 		fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
 		fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
 		fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US...)\n" );
-		fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
-		fprintf( stdout, "     f1, f2,... are also elements of (de,en-US...)\n" );
-		fprintf( stdout, "     Example: -L de,es=en-US\n" );
-		fprintf( stdout, "              Restriction to de and es, en-US will be fallback for es\n" );
 		return 1;
 	}
     
diff --git a/l10ntools/source/xrmlex.l b/l10ntools/source/xrmlex.l
index 29b2081..de5b5df 100644
--- a/l10ntools/source/xrmlex.l
+++ b/l10ntools/source/xrmlex.l
@@ -193,10 +193,6 @@ main( int argc, char* argv[])
 		fprintf( stdout, " -u: [english] and [german] are allowed, Id is Taken from DataBase \n" );
 		fprintf( stdout, " -NOUTF8: disable UTF8 as language independent encoding\n" );
 		fprintf( stdout, " -L: Restrict the handled languages. l1,l2,... are elements of (de,en-US,es...)\n" );
-		fprintf( stdout, "     A fallback language can be defined like this: l1=f1.\n" );
-		fprintf( stdout, "     f1, f2,... are also elements of (de,en-US,es...)\n" );
-		fprintf( stdout, "     Example: -L en-US,es=de\n" );
-		fprintf( stdout, "              Restriction to es and en-US, de will be fallback for 99\n" );
 		return 1;
 	}
 	pFile = GetXrmFile();
diff --git a/l10ntools/source/xrmmerge.cxx b/l10ntools/source/xrmmerge.cxx
index 586223a..36e888d 100644
--- a/l10ntools/source/xrmmerge.cxx
+++ b/l10ntools/source/xrmmerge.cxx
@@ -537,9 +537,6 @@ void XRMResExport::EndOfText(
     (void) rCloseTag;       // FIXME
 
     if ( pResData && pOutputStream ) {
-
-        Export::FillInFallbacks( pResData );
-
         ByteString sTimeStamp( Export::GetTimeStamp());
         ByteString sCur;
         for( unsigned int n = 0; n < aLanguages.size(); n++ ){


More information about the Libreoffice-commits mailing list