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/02/10 15:16:45 UTC

svn commit: r1444550 - in /openoffice/branches/l10n/main/l10ntools/source: gConSrc.hxx gConSrcWrap.cxx gConSrclex.l gL10nMem.cxx gLang.hxx

Author: jani
Date: Sun Feb 10 14:16:44 2013
New Revision: 1444550

URL: http://svn.apache.org/r1444550
Log:
added index handling of keys

Modified:
    openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
    openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
    openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
    openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
    openoffice/branches/l10n/main/l10ntools/source/gLang.hxx

Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx?rev=1444550&r1=1444549&r2=1444550&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrc.hxx Sun Feb 10 14:16:44 2013
@@ -46,6 +46,7 @@ class convert_src_impl : public convert_
     void registerKey(std::string &sText);
     
     void saveData(std::string& sText);
+    void saveItemList(std::string& sText);
     void copyData(std::string& sText);
 
   private:

Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx?rev=1444550&r1=1444549&r2=1444550&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrcWrap.cxx Sun Feb 10 14:16:44 2013
@@ -176,6 +176,53 @@ void convert_src_impl::saveData(std::str
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
+void convert_src_impl::saveItemList(std::string &sText)
+{
+  int    nL, nE;
+  std::string sKey, sUseText;
+
+  // write text for merge
+  if (mbMergeMode)
+    writeSourceFile(msCollector + sText);
+  msCollector.clear();
+
+  // locate key and extract it
+  for (nL = 0; nL < (int)mcStack.size(); ++nL)
+	if (mcStack[nL] != "dummy")
+	  sKey += (nL > 0 ? "." : "") + mcStack[nL];
+
+  // loop and find all texts
+  for (int cnt = 0, nL = 0; nL < (int)sText.size();)
+  {
+    // Is it a real text
+	nL = sText.find('\"', nL);
+    if (nL == std::string::npos)
+      break;
+	nE = sText.find('\"', nL+1);
+    sUseText = sText.substr(nL+1,nE-nL-1);
+    nL = nE +1;
+	mcMemory.setEnUsKey(sKey, sUseText, ++cnt);
+  }
+
+  if (mbMergeMode)
+  {
+    // get all languages (includes en-US)
+    std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey);
+    std::string                   sNewLine;
+    nL = cExtraLangauges.size();
+
+    for (int i = 0; i < nL; ++i)
+    {
+      sNewLine = "<value xml:lang=\"" + cExtraLangauges[i]->msLanguage + "\">" +
+	             cExtraLangauges[i]->msText + "</value>";
+      writeSourceFile(sNewLine);
+    }
+  }
+}
+
+
+
+/**********************   I M P L E M E N T A T I O N   **********************/
 void convert_src_impl::copyData(std::string &sText)
 {
   msCollector += sText;

Modified: openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l?rev=1444550&r1=1444549&r2=1444550&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gConSrclex.l Sun Feb 10 14:16:44 2013
@@ -59,28 +59,29 @@
 /*******************   R U L E S   D E F I N I T I O N S   *******************/
 %%
 
-[bB][iI][tT][mM][aA][pP][ ]+[a-zA-Z]+[^\{]*                          |
-[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE][ ]+[a-zA-Z]+[^\{]*      |
-[eE][dD][iI][tT][ ]+[a-zA-Z]+[^\{]*                                  |
-[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]*  |
-[cC][oO][nN][tT][rR][oO][lL][ ]+[a-zA-Z]+[^\{]*                      |
-[eE][rR][rR][oO][rR][bB][oO][xX][ ]+[a-zA-Z]+[^\{]*                  |
-[fF][iI][xX][eE][dD][tT][eE][xX][tT][ ]+[a-zA-Z]+[^\{]*              |
-[iI][mM][aA][gG][eE][ ]+[a-zA-Z]+[^\{]*                              |
-[iI][mM][aA][gG][eE][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]*      |
-[iI][tT][eE][mM][lL][iI][sS][tT][ ]+[a-zA-Z]+[^\{]*                  |
-[hH][eE][lL][pP][bB][uU][tT][oO][mM][ ]+[a-zA-Z]+[^\{]*              |
-[mM][eE][nN][uU][ ]+[a-zA-Z]+[^\{]*                                  |
-[mM][eE][nN][uU][iI][tT][eE][mM][ ]+[a-zA-Z]+[^\{]*                  |
-[mM][oO][dD][aA][lL][dD][iI][aA][lL][oO][gG][ ]+[a-zA-Z]+[^\{]*      |
-[mM][uU][lL][tT][iI][lL][iI][nN][eE][dD][iI][tT][ ]+[a-zA-Z]+[^\{]*  |
-[pP][aA][gG][eE][iI][tT][eE][mM][ ]+[a-zA-Z]+[^\{]*                  |
-[pP][aA][gG][eE][lL][iI][sS][tT][ ]+[a-zA-Z]+[^\{]*                  |
-[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN][ ]+[a-zA-Z]+[^\{]*          |
-[sS][tT][rR][iI][nN][gG][ ]+[a-zA-Z]+[^\{]*                          |
-[tT][aA][bB][cC][oO][nN][tT][rR][oO][lL][ ]+[a-zA-Z]+[^\{]*          |
-[tT][aA][bB][dD][iI][aA][lL][oO][gG][ ]+[a-zA-Z]+[^\{]*              |
-[tT][aA][bB][pP][aA][gG][eE][ ]+[a-zA-Z]+[^\{]*                      {
+[bB][iI][tT][mM][aA][pP]\ +[a-zA-Z]+[^\{]*                          |
+[bB][uU][tT][tT][oO][nN][iI][mM][aA][gG][eE]\ +[a-zA-Z]+[^\{]*      |
+[eE][dD][iI][tT]\ +[a-zA-Z]+[^\{]*                                  |
+[cC][aA][nN][cC][eE][lL][bB][uU][tT][tT][oO][nN]\ +[a-zA-Z]+[^\{]*  |
+[cC][oO][nN][tT][rR][oO][lL]\ +[a-zA-Z]+[^\{]*                      |
+[eE][rR][rR][oO][rR][bB][oO][xX]\ +[a-zA-Z]+[^\{]*                  |
+[fF][iI][xX][eE][dD][tT][eE][xX][tT]\ +[a-zA-Z]+[^\{]*              |
+[iI][mM][aA][gG][eE]\ +[a-zA-Z]+[^\{]*                              |
+[iI][mM][aA][gG][eE][bB][uU][tT][tT][oO][nN]\ +[a-zA-Z]+[^\{]*      |
+[iI][tT][eE][mM][lL][iI][sS][tT]\ +[a-zA-Z]+[^\{]*                  |
+[hH][eE][lL][pP][bB][uU][tT][oO][mM]\ +[a-zA-Z]+[^\{]*              |
+[mM][eE][nN][uU]\ +[a-zA-Z]+[^\{]*                                  |
+[mM][eE][nN][uU][iI][tT][eE][mM]\ +[a-zA-Z]+[^\{]*                  |
+[mM][oO][dD][aA][lL][dD][iI][aA][lL][oO][gG]\ +[a-zA-Z]+[^\{]*      |
+[mM][uU][lL][tT][iI][lL][iI][nN][eE][dD][iI][tT]\ +[a-zA-Z]+[^\{]*  |
+[pP][aA][gG][eE][iI][tT][eE][mM]\ +[a-zA-Z]+[^\{]*                  |
+[pP][aA][gG][eE][lL][iI][sS][tT]\ +[a-zA-Z]+[^\{]*                  |
+[pP][uU][sS][hH][bB][uU][tT][tT][oO][nN]\ +[a-zA-Z]+[^\{]*          |
+[sS][tT][rR][iI][nN][gG]\ +[a-zA-Z]+[^\{]*                          |
+[sS][tT][rR][iI][nN][gG][aA][rR][rR][aA][yY]\ +[a-zA-Z]+[^\{]*      |
+[tT][aA][bB][cC][oO][nN][tT][rR][oO][lL]\ +[a-zA-Z]+[^\{]*          |
+[tT][aA][bB][dD][iI][aA][lL][oO][gG]\ +[a-zA-Z]+[^\{]*              |
+[tT][aA][bB][pP][aA][gG][eE]\ +[a-zA-Z]+[^\{]*                      {
   std::string text(yytext);
   convert_src::mcpImpl->pushKey(text);
 }
@@ -113,19 +114,24 @@
   convert_src::mcpImpl->pushNoKey(text);
 }
 
-[hH][eE][lL][pP][iI][dD][ \t]+'='[ \t]+[a-zA-Z]+[^;]*                 |
-[iI][dD][eE][nN][tT][iI][fF][iI][eE][rR][ \t]*"="[ \t]*[a-zA-Z]+[^;]* {
+[hH][eE][lL][pP][iI][dD]\ *"="\ *[a-zA-Z]+[^;]*                 |
+[iI][dD][eE][nN][tT][iI][fF][iI][eE][rR]\ *"="\ *[a-zA-Z]+[^;]* {
   std::string text(yytext);
   convert_src::mcpImpl->registerKey(text);
 }
 
-[mM][eE][sS][sS][aA][gG][eE][ \t]*"["[ \t]*"en-US"[ \t]*"]"[ \t]+"="[^\n]*                         |
-[qQ][uU][iI][cC][kK][hH][eE][lL][pP][tT][eE][xX][tT][ \t]*"["[ \t]*"en-US"[ \t]*"]"[ \t]+"="[^\n]* |
-[tT][eE][xX][tT][ \t]*"["[ \t]*"en-US"[ \t]*"]"[ \t]+"="[^\n]*                                     {
+[mM][eE][sS][sS][aA][gG][eE]\ *"["\ *"en-US"\ *"]"\ *"="[^\n]*                         |
+[qQ][uU][iI][cC][kK][hH][eE][lL][pP][tT][eE][xX][tT]\ *"["\ *"en-US"\ *"]"\ *"="[^\n]* |
+[tT][eE][xX][tT]\ *"["\ *"en-US"\ *"]"\ *"="[^\n]*                                     {
   std::string text(yytext);
   convert_src::mcpImpl->saveData(text);
 }
 
+[iI][tT][eE][mM][lL][iI][sS][tT]\ *"["\ *"en-US"\ *"]"\ *"="[ \n]+"{"[^\}]*"};"       {
+  std::string text(yytext);
+  convert_src::mcpImpl->saveItemList(text);
+}
+
 "}"[ ]*";" {
   std::string text(yytext);
   convert_src::mcpImpl->popKey(text);

Modified: openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx?rev=1444550&r1=1444549&r2=1444550&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gL10nMem.cxx Sun Feb 10 14:16:44 2013
@@ -27,19 +27,20 @@
  *****************************************************************************
  * This is the translation memory that links between the converts (from source
  * files) and to the language files. The memory contains the actual text info
- *****************************************************************************/
+ ***********************d******************************************************/
 
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
 l10nMem_entry::l10nMem_entry(const std::string& srSourceFile, const std::string& srModuleName,
                              const std::string& srKey,        const std::string& srLanguage,
-                             const std::string& srText)
+                             const std::string& srText,       const int iIndex)
                             : msSourceFile(srSourceFile),
                               msModuleName(srModuleName),
                               msKey(srKey),
                               msLanguage(srLanguage),
-                              msText(srText)
+                              msText(srText),
+							  miIndex(iIndex)
 {
 }
 
@@ -77,9 +78,14 @@ void l10nMem::save(const std::string& sr
 
 	
   for (i = 0; i < (int)mcMemory.size(); ++i)
+  {
 	outputFile << mcMemory[i].msModuleName << "\t" << mcMemory[i].msSourceFile << "\t"
-	           << mcMemory[i].msKey   << "\t" << mcMemory[i].msLanguage  << "\t"
-               << mcMemory[i].msText  << std::endl;
+	           << mcMemory[i].msKey;
+	if (mcMemory[i].miIndex)
+	  outputFile << ":" << mcMemory[i].miIndex;
+	outputFile << "\t" << mcMemory[i].msLanguage  << "\t"
+               << mcMemory[i].msText << std::endl;
+  }
   // JIX
 }
 
@@ -111,11 +117,11 @@ void l10nMem::setModuleName(const std::s
 
 
 /**********************   I M P L E M E N T A T I O N   **********************/
-void l10nMem::setEnUsKey(const std::string& srKey, const std::string& srText)
+void l10nMem::setEnUsKey(const std::string& srKey, const std::string& srText, int iIndex)
 {
   std::string baseLanguage = "en-US";
   mcMemory.push_back(l10nMem_entry(msCurrentSourceFileName, msCurrentModuleName,
-                                   srKey, baseLanguage, srText));
+                                   srKey, baseLanguage, srText, iIndex));
 }
 
 

Modified: openoffice/branches/l10n/main/l10ntools/source/gLang.hxx
URL: http://svn.apache.org/viewvc/openoffice/branches/l10n/main/l10ntools/source/gLang.hxx?rev=1444550&r1=1444549&r2=1444550&view=diff
==============================================================================
--- openoffice/branches/l10n/main/l10ntools/source/gLang.hxx (original)
+++ openoffice/branches/l10n/main/l10ntools/source/gLang.hxx Sun Feb 10 14:16:44 2013
@@ -43,7 +43,7 @@ class l10nMem_entry
 {
   public:
     l10nMem_entry(const std::string& srSourceFile, const std::string& srModuleName, const std::string& srKey,
-                  const std::string& srLanguage,   const std::string& srText);
+                  const std::string& srLanguage,   const std::string& srText,       const int iIndex);
     ~l10nMem_entry();
 
     std::string msSourceFile;
@@ -51,6 +51,7 @@ class l10nMem_entry
     std::string msKey;
     std::string msLanguage;
     std::string msText;
+	int         miIndex;
 
   private:
 };
@@ -67,7 +68,7 @@ class l10nMem
 	void clear();
     void setFileName(const std::string& srSourceFile);
     void setModuleName(const std::string& srModuleName);
-    void setEnUsKey(const std::string& srKey, const std::string& srText);
+    void setEnUsKey(const std::string& srKey, const std::string& srText, int iIndex = 0);
     std::vector<l10nMem_entry *>& getLanguagesForKey(const std::string& srKey);
 
   private: