You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ja...@apache.org on 2013/03/11 22:08:23 UTC

svn commit: r1455330 - in /openoffice/branches/l10n/main/l10ntools/source: gCon.cxx gCon.hxx gConPo.hxx gConPoWrap.cxx gConPolex.l gHandler.cxx gL10nMem.cxx gL10nMem.hxx gL10nMemDB.cxx gLang.hxx

Author: jani
Date: Mon Mar 11 21:08:23 2013
New Revision: 1455330

URL: http://svn.apache.org/r1455330
Log:
read/write of .po files works !!! 

Modified:
    openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
    openoffice/branches/l10n/main/l10ntools/source/gCon.hxx
    openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
    openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
    openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
    openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
    openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
    openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
    openoffice/branches/l10n/main/l10ntools/source/gLang.hxx

Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.cxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.cxx Mon Mar 11 21:08:23 2013
@@ -129,14 +129,16 @@ void convert_gen_impl::startSave(const s
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void convert_gen::save(const std::string& sKey,
-                      const std::string& sENUStext,
-                      const std::string& sText,
-                      bool               bFuzzy)
+void convert_gen::save(const std::string& sFileName,
+                       const std::string& sKey,
+                       const std::string& sENUStext,
+                       const std::string& sText,
+                       bool               bFuzzy)
 {
-  convert_gen_impl::mcImpl->save(sKey, sENUStext, sText, bFuzzy);
+  convert_gen_impl::mcImpl->save(sFileName, sKey, sENUStext, sText, bFuzzy);
 }
-void convert_gen_impl::save(const std::string& sKey,
+void convert_gen_impl::save(const std::string& sFileName,
+                            const std::string& sKey,
                             const std::string& sENUStext,
                             const std::string& sText,
                             bool               bFuzzy)

Modified: openoffice/branches/l10n/main/l10ntools/source/gCon.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gCon.hxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gCon.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gCon.hxx Mon Mar 11 21:08:23 2013
@@ -54,7 +54,8 @@ class convert_gen_impl
     virtual void startSave(const std::string& sTargetDir,
                            const std::string& sLanguage,
                            const std::string& sFile);
-    virtual void save(const std::string& sKey,
+    virtual void save(const std::string& sFileName,
+                      const std::string& sKey,
                       const std::string& sENUStext,
                       const std::string& sText,
                       bool               bFuzzy);

Modified: openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPo.hxx Mon Mar 11 21:08:23 2013
@@ -51,9 +51,11 @@ class convert_po : public convert_gen_im
     void setKey    (char *syyText);
     void setMsgId  (char *syyText);
     void setMsgStr (char *syyText);
+    void handleNL  (char *syyText);
 
   private:
-    std::string  msValue;
+    std::string  msId;
+    std::string  msStr;
     std::string  msKey;
     bool         mbFuzzy;
     std::filebuf outBuffer;
@@ -63,7 +65,8 @@ class convert_po : public convert_gen_im
     void startSave(const std::string& sTargetDir,
                    const std::string& sLanguage,
                    const std::string& sFile);
-    void save(const std::string& sKey,
+    void save(const std::string& sFileName,
+              const std::string& sKey,
               const std::string& sENUStext,
               const std::string& sText,
               bool               bFuzzy);

Modified: openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPoWrap.cxx Mon Mar 11 21:08:23 2013
@@ -64,11 +64,26 @@ namespace PoWrap
 /**********************   I M P L E M E N T A T I O N   **********************/
 void convert_po::startLook(char *syyText)
 {
-  //JIX startLook
+ std::string sFileName, sNewKey;
+ int         i;
+
+
+ handleNL(syyText);
+ if (!msKey.size() || !msId.size() || !msStr.size())
+    return;
+
+  // split key into filename and real key
+  i         = msKey.find(":");
+  sFileName = msKey.substr(0, i);
+  sNewKey   = msKey.substr(i+1);
+
+  // load in db
+  mcMemory.loadEntryKey(miLineNo, sFileName, sNewKey, msId, msStr, mbFuzzy);
+
+  // and prepare for new entry
   msKey.clear();
-  msValue.clear();
-  mbExpectId  =
-  mbExpectStr = false;
+  msId.clear();
+  msStr.clear();
 }
 
 
@@ -77,12 +92,18 @@ void convert_po::startLook(char *syyText
 void convert_po::setValue(char *syyText)
 {
   int inx;
-
+  std::string sText(syyText);
 
   // find terminating "
-  msValue = syyText;
-  for (inx =  msValue.size(); msValue[--inx] != '\"';)
-  msValue.erase(inx);
+  for (inx =  sText.size(); sText[--inx] != '\"';) ;
+  sText.erase(inx);
+
+  if (mbExpectId)
+    msId = sText;
+  if (mbExpectStr)
+    msStr = sText;
+  mbExpectId  =
+  mbExpectStr = false;
 }
 
 
@@ -104,11 +125,11 @@ void convert_po::setKey(char *syyText)
 
 
   // skip "#:" and any blanks
-  for (syyText += 2; *syyText == ' ' || *syyText == '\t';) ;
+  for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ;
   msKey = syyText;
 
   // remove trailing blanks
-  for (i = msKey.size() -1; msKey[i] == ' ' || msKey[i] == '\t'; --i) ;
+  for (i = msKey.size() -1; msKey[i] == '\r' || msKey[i] == ' ' || msKey[i] == '\t'; --i) ;
   msKey.erase(i+1);
 }
 
@@ -135,9 +156,19 @@ void convert_po::setMsgStr(char *syyText
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
+void convert_po::handleNL(char *syyText)
+{
+  mbExpectId  =
+  mbExpectStr = false;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
 void convert_po::execute()
 {
   PoWrap::yylex();
+  startLook("");
 }
 
  
@@ -178,20 +209,32 @@ void convert_po::startSave(const std::st
           << "#* under the License."                                           << std::endl
           << "#*"                                                              << std::endl
           << "#************************************************************"   << std::endl
-          << std::endl;
+          << "msgid \"\""                                                      << std::endl
+          << "msgstr \"\""                                                     << std::endl
+          << "\"Project-Id-Version: AOO-4-xx\\n\""                             << std::endl
+          << "\"POT-Creation-Date: \\n\""                                      << std::endl
+          << "\"PO-Revision-Date: \\n\""                                       << std::endl
+          << "\"Last-Translator: genLang (build process)\\n\""                 << std::endl
+          << "\"Language-Team: \\n\""                                          << std::endl
+          << "\"MIME-Version: 1.0\\n\""                                        << std::endl
+          << "\"Content-Type: text/plain; charset=iso-8859-1\\n\""             << std::endl
+          << "\"Content-Transfer-Encoding: 8bit\\n\""                          << std::endl
+          << "\"X-Generator: genLang\\n\""                                     << std::endl
+          << std::endl;
 }
 
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void convert_po::save(const std::string& sKey,
+void convert_po::save(const std::string& sFileName,
+                      const std::string& sKey,
                       const std::string& sENUStext,
                       const std::string& sText,
                       bool               bFuzzy)
 {
   std::ostream outFile(&outBuffer);
 
-  outFile << std::endl << "#: " + sKey << std::endl;
+  outFile << std::endl << "#: " << sFileName << ":" << sKey << std::endl;
   if (bFuzzy)
     outFile << "#, fuzzy" << std::endl;
   outFile << "msgid  \"" << sENUStext << "\"" << std::endl

Modified: openoffice/branches/l10n/main/l10ntools/source/gConPolex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConPolex.l?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConPolex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConPolex.l Mon Mar 11 21:08:23 2013
@@ -100,13 +100,13 @@ SPACE [ \t]*
 }
 
 
-<<EOF>> {
+\n\r*\n {
   LOCptr->startLook(yytext);
 }
 
 
-\n\r*\n {
-  LOCptr->startLook(yytext);
+\n {
+  LOCptr->handleNL(yytext);
 }
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gHandler.cxx Mon Mar 11 21:08:23 2013
@@ -264,7 +264,7 @@ void handler::runExtractMerge(bool bMerg
   }
 
   // and generate language file
-  mcMemory.save(msPoOutDir, bKid);
+  mcMemory.save(msPoOutDir, bKid, (msPoDir != msPoOutDir));
 }
 
 
@@ -293,7 +293,7 @@ void handler::runConvert()
   }
 
   // and generate language file
-  mcMemory.save(msPoOutDir, false);
+  mcMemory.save(msPoOutDir, false, (msPoDir != msPoOutDir));
 }
 
 
@@ -427,7 +427,7 @@ void handler::loadL10MEM()
   // load texts from en_US po file (master)
   {
     // tell system
-    l10nMem::showDebug("gLang loading master text from file " + sLoad);
+    l10nMem::showDebug("gLang loading master text from file " + sLoad + sMod);
 
     // and load file
     mcMemory.setLanguage("", true, false);
@@ -437,13 +437,14 @@ void handler::loadL10MEM()
   // loop through all languages and load text
   for (std::vector<std::string>::iterator siLang = mvLanguages.begin(); siLang != mvLanguages.end(); ++siLang)
   {
-    sLoad = msPoDir + *siLang;
-
-    // tell system
-    l10nMem::showDebug("gLang loading text from language file " + sLoad);
+    sLoad = msPoDir + *siLang + "/";
 
     // get converter and extract files
     mcMemory.setLanguage(*siLang, true, false);
+
+    // tell system
+    l10nMem::showDebug("gLang loading text from language file " + sLoad + sMod);
+
     convert_gen(mcMemory, sLoad, sMod).execute(false, true);
   }
 }

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Mon Mar 11 21:08:23 2013
@@ -95,10 +95,8 @@ bool l10nMem::checkKey(const std::string
      { return l10nMem_impl::mcImpl->mcDb.locateKey(0, sKey, sText, false); }
 void l10nMem::setSourceKey(int iL, const std::string& sF, const std::string& sK, const std::string& sT)
      { l10nMem_impl::mcImpl->setSourceKey(iL, sF, sK, sT); }
-void l10nMem::reorganize()
-     { l10nMem_impl::mcImpl->mcDb.reorganize(); }
-void l10nMem::save(const std::string& sT, bool bK)
-     { l10nMem_impl::mcImpl->save(*this, sT, bK); }
+void l10nMem::save(const std::string& sT, bool bK, bool bF)
+     { l10nMem_impl::mcImpl->save(*this, sT, bK, bF); }
 void l10nMem::dumpMem(const std::string& sT)
      { l10nMem_impl::mcImpl->dumpMem(sT); }
 
@@ -205,28 +203,36 @@ void l10nMem_impl::setSourceKey(int     
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void l10nMem_impl::save(l10nMem& cMem, const std::string& sTargetDir, bool bKid)
+void l10nMem_impl::save(l10nMem& cMem, const std::string& sTargetDir, bool bKid, bool bForce)
 {
-  //JIX save HANDLE KID
-  if (mbInError)
-    throw l10nMem::showError("Cannot save due to previous errors");
+  int iE, iEsize  = mcDb.mcENUSlist.size();
+  int iL, iLsize  = mcDb.mcLangList.size();
+  int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
+  std::string sFileName = msModuleName + ".po";
+
+  // and reorganize db if needed
+  mcDb.reorganize();
+
+  // no save if there has been errors
+  if(!needWrite(sFileName, bForce))
+    return;
 
-  int iE, iEsize = mcDb.mcENUSlist.size();
-  int iL, iLsize = mcDb.mcLangList.size();
-  std::string fileName = msModuleName + ".po";
+  //JIX save HANDLE KID
 
   // Save en_US
   {
-    convert_gen savePo(cMem, sTargetDir, fileName);
+    convert_gen savePo(cMem, sTargetDir, sFileName);
 
-    savePo.startSave(sTargetDir, "en_US", fileName);
+    savePo.startSave(sTargetDir, "en_US", sFileName);
     for (iE = 1; iE < iEsize; ++iE)
     {
       l10nMem_enus_entry& cE     = mcDb.mcENUSlist[iE];
-      std::string         newKey = mcDb.mcFileList[cE.miFileInx].msFileName + ":" + cE.msKey;
 
+      // remove deleted entries
+      if (cE.meState == l10nMem::ENTRY_DELETED)
+        continue;
 
-      savePo.save(newKey, cE.msText, cE.msText, false);
+      savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msText, cE.msText, false);
     }
     savePo.endSave();
   }
@@ -234,18 +240,20 @@ void l10nMem_impl::save(l10nMem& cMem, c
   // save all languages
   for (iL = 1; iL < iLsize; ++iL)
   {
-    convert_gen savePo(cMem, sTargetDir, fileName);
+    convert_gen savePo(cMem, sTargetDir, sFileName);
 
-    savePo.startSave(sTargetDir, mcDb.mcLangList[iL], fileName);
+    savePo.startSave(sTargetDir, mcDb.mcLangList[iL], sFileName);
     for (iE = 1; iE < iEsize; ++iE)
     {
       l10nMem_enus_entry& cE     = mcDb.mcENUSlist[iE];
       l10nMem_lang_entry& cL     = cE.mcLangList[iL];
       bool                bF     = cL.mbFuzzy || (cE.meState == l10nMem::ENTRY_CHANGED);
-      std::string         newKey = mcDb.mcFileList[cE.miFileInx].msFileName + ":" + cE.msKey;
 
+      // remove deleted entries
+      if (cE.meState == l10nMem::ENTRY_DELETED)
+        continue;
 
-      savePo.save(newKey, cE.msText, cL.msText, false);
+      savePo.save(mcDb.mcFileList[cE.miFileInx].msFileName, cE.msKey, cE.msText, cL.msText, bF);
     }
     savePo.endSave();
   }
@@ -254,14 +262,15 @@ void l10nMem_impl::save(l10nMem& cMem, c
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void l10nMem_impl::dumpMem(const std::string& srTargetFile)
+void l10nMem_impl::dumpMem(const std::string& sFileName)
 {
-  std::string x;
+  // and reorganize db if needed
+  mcDb.reorganize();
 
-  if (mbInError)
-    throw l10nMem::showError("Cannot generate fast load file due to previous errors");
+  // no save if there has been errors
+  if(!needWrite(sFileName, true))
+    return;
 
-  x = srTargetFile;
   // JIX (dumpMem)
 }
 
@@ -273,7 +282,7 @@ void l10nMem_impl::formatAndShowText(con
   std::string& cFile = mcDb.mcFileList[mcDb.miCurFileInx].msFileName;
 
   std::cerr << sType;
-  if (cFile.size())
+  if (mcDb.miCurFileInx > 0)
     std::cerr << " in " << mcDb.mcFileList[mcDb.miCurFileInx].msFileName;
   if (iLineNo)
     std::cerr << "(" << iLineNo << ")";
@@ -283,6 +292,47 @@ void l10nMem_impl::formatAndShowText(con
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
+bool l10nMem_impl::needWrite(const std::string sFileName, bool bForce)
+{
+  int iE, iEsize  = mcDb.mcENUSlist.size();
+  int iCntDeleted = 0, iCntChanged = 0, iCntAdded = 0;
+
+  // no save if there has been errors
+  if (mbInError)
+    throw l10nMem::showError("Cannot save due to previous errors");
+
+  // Check number of changes
+  for (iE = 1; iE < iEsize; ++iE)
+  {
+    l10nMem_enus_entry& cur = mcDb.mcENUSlist[iE];
+    if (cur.meState == l10nMem::ENTRY_ADDED)
+      ++iCntAdded;
+    if (cur.meState == l10nMem::ENTRY_CHANGED)
+      ++iCntChanged;
+    if (cur.meState == l10nMem::ENTRY_DELETED)
+      ++iCntDeleted;
+  }
+  iCntDeleted -= iCntChanged;
+  if (!iCntAdded && !iCntChanged && !iCntDeleted)
+  {
+    std::cout << "genLang: No changes in " <<   sFileName;
+    if (bForce)
+      std::cout << ", -o switch used, so files are saved" << std::endl;
+    else
+      std::cout << " skipping \"save\"" << std::endl;
+    return bForce;
+  }
+
+  std::cout << "genLang statistics: " << iCntDeleted << " deleted, "
+                                      << iCntChanged << " changed, "
+                                      << iCntAdded   << " added entries in "
+                                      << sFileName   << std::endl;
+  return true;
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
 void l10nMem_impl::convEntryKey(int                iLineNo,
                                const std::string& sSourceFile,
                                const std::string& sKey,

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.hxx Mon Mar 11 21:08:23 2013
@@ -54,6 +54,7 @@ class l10nMem_enus_entry
                        const std::string&   sText,
                        int                  iLineNo,
                        int                  iFileInx,
+                       int                  iLangSize,
                        l10nMem::ENTRY_STATE eState);
     ~l10nMem_enus_entry();
 
@@ -93,7 +94,6 @@ class l10nMem_db
     int                             miCurENUSinx;
     int                             miCurLastENUSinx;
     bool                            mbNeedWrite;
-    bool                            mbReorganizeNeeded;
     bool                            mbConvertMode;
     std::vector<l10nMem_enus_entry> mcENUSlist;
     std::vector<l10nMem_file_entry> mcFileList;
@@ -120,7 +120,7 @@ class l10nMem_db
                          const std::string& sKey,
                          const std::string& sText,
                          bool               bThrow = true);
-    void reorganize();
+    void reorganize     ();
     void addKey         (int                  iLineNo,
                          const std::string&   sKey,
                          const std::string&   sText,
@@ -156,7 +156,8 @@ class l10nMem_impl
 
     void save         (l10nMem& cMem,
                        const std::string& sTargetDir,
-                       bool               bKid);
+                       bool               bKid,
+                       bool               bForce);
     void dumpMem      (const std::string& sTargetDir);
 
   private:
@@ -168,6 +169,7 @@ class l10nMem_impl
     bool                                mbInError;
 
     void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText);
+    bool needWrite        (const std::string sFileName, bool bForce);
     void convEntryKey     (int                iLineNo,
                            const std::string& sSourceFile,
                            const std::string& sKey,

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMemDB.cxx Mon Mar 11 21:08:23 2013
@@ -55,6 +55,7 @@ l10nMem_enus_entry::l10nMem_enus_entry(c
                                        const std::string&   sText,
                                        int                  iLineNo,
                                        int                  iFileInx,
+                                       int                  iLangSize,
                                        l10nMem::ENTRY_STATE eState)
                                       :
                                        msKey(sKey),
@@ -63,6 +64,8 @@ l10nMem_enus_entry::l10nMem_enus_entry(c
                                        miFileInx(iFileInx),
                                        miLineNo(iLineNo)
 {
+  for (int i = 0; i < iLangSize; ++i)
+    mcLangList.push_back(l10nMem_lang_entry("", false));
 }
 
 
@@ -100,12 +103,11 @@ l10nMem_db::l10nMem_db()
                        miCurENUSinx(0),
                        miCurLastENUSinx(0),
                        mbNeedWrite(false),
-                       mbReorganizeNeeded(false),
                        mbConvertMode(false)
 {
-  mcFileList.push_back(l10nMem_file_entry("", 0));
-  mcLangList.push_back("");
-  mcENUSlist.push_back(l10nMem_enus_entry("", "", 0, 0, l10nMem::ENTRY_DELETED));
+  mcFileList.push_back(l10nMem_file_entry("-genLang-", 0));
+  mcLangList.push_back("-genLang-");
+  mcENUSlist.push_back(l10nMem_enus_entry("-genLang-", "-genLang-", 0, 0, 0, l10nMem::ENTRY_DELETED));
 }
 
 
@@ -145,10 +147,14 @@ void l10nMem_db::setLanguage(const std::
 
   // regular load or convert of old po files
   mbConvertMode = bConvert;
+  miCurFileInx  = 0;
 
   // With no languages selected only en_US is generated
   if (!sLanguage.size())
+  {
     miCurLangInx = 0;
+    return;
+  }
 
   // en_US is loaded as master and cannot be loaded again
   if (sLanguage == "en_US")
@@ -226,6 +232,39 @@ void l10nMem_db::loadLangKey(int        
 /**********************   I M P L E M E N T A T I O N   **********************/
 void l10nMem_db::reorganize()
 {
+  int iE, iEsize  = mcENUSlist.size();
+  int iD, iDsize;
+  std::vector<int> listDel, listAdd;
+
+
+  // Check number of changes
+  for (iE = 1; iE < iEsize; ++iE)
+  {
+    l10nMem_enus_entry& cur = mcENUSlist[iE];
+    if (cur.meState == l10nMem::ENTRY_ADDED)
+      listAdd.push_back(iE);
+    if (cur.meState == l10nMem::ENTRY_DELETED)
+      listDel.push_back(iE);
+  }
+  if (!listDel.size() || !listAdd.size())
+    return;
+
+  // loop through added text and see if key match deleted text
+  iEsize = listAdd.size();
+  iDsize = listDel.size();
+  for (iE = 0; iE < iEsize; ++iE)
+  {
+    l10nMem_enus_entry& curAdd = mcENUSlist[listAdd[iE]];
+    for (iD = 0; iD < iDsize && mcENUSlist[listDel[iD]].msKey != curAdd.msKey; ++iD) ;
+    if (iD == iDsize)
+      continue;
+
+    // Update deleted entry (original), because lang is connected here
+    l10nMem_enus_entry& curDel = mcENUSlist[listDel[iD]];
+    curDel.msText  = curAdd.msText;
+    curDel.meState = l10nMem::ENTRY_CHANGED;
+    curAdd.meState = l10nMem::ENTRY_DELETED;
+  }
   // JIX (reorganize)
 }
 
@@ -272,6 +311,7 @@ void l10nMem_db::addKey(int             
 {
   // JIX. addKey, handle fuzzy bit in lang (if changed).
   miCurENUSinx = mcENUSlist.size();
-  mcENUSlist.push_back(l10nMem_enus_entry(sKey, sText, iLineNo, miCurFileInx, eStat));
+  mcENUSlist.push_back(l10nMem_enus_entry(sKey, sText, iLineNo, miCurFileInx,
+                                          mcLangList.size(), eStat));
   miCurLastENUSinx = mcFileList[miCurFileInx].miEnd = miCurENUSinx;
 }

Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1455330&r1=1455329&r2=1455330&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Mon Mar 11 21:08:23 2013
@@ -83,10 +83,10 @@ class l10nMem
                        const std::string& sFilename,
                        const std::string& sKey,
                        const std::string& sText);
-    void reorganize    ();
 
     void save         (const std::string& sTargetDir,
-                       bool               bKid);
+                       bool               bKid,
+                       bool               bForce);
     void dumpMem      (const std::string& sTargetDir);
 
 };
@@ -107,7 +107,8 @@ class convert_gen
     void startSave(const std::string& sTargetDir,
                    const std::string& sLanguage,
                    const std::string& sFile);
-    void save(const std::string& sKey,
+    void save(const std::string& sFileName,
+              const std::string& sKey,
               const std::string& sENUStext,
               const std::string& sText,
               bool               bFuzzy);