summaryrefslogtreecommitdiff
path: root/l10ntools/source/treemerge.cxx
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-03-15 15:42:05 +0100
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-03-16 12:27:32 +0100
commit15a13bafccb96e6ab0cc5a23af6dd46715fa22c5 (patch)
tree91b93ddc0f731aec2d5b19f1895545550872a119 /l10ntools/source/treemerge.cxx
parent516118b515fb577b1cc40e4b8d7dc06919b64675 (diff)
Get rid of generating temporary sdf file
Working: 1. Localize add header to po files. 2. Executables append po entries to po files. 3. Localize delete entryless po files and empty directories Plus a bunch of clean up. Change-Id: I58e300eaee4cee948203cc9d3e642ca9462d0d26
Diffstat (limited to 'l10ntools/source/treemerge.cxx')
-rw-r--r--l10ntools/source/treemerge.cxx47
1 files changed, 13 insertions, 34 deletions
diff --git a/l10ntools/source/treemerge.cxx b/l10ntools/source/treemerge.cxx
index 6529a10d200d..d259efcd9d46 100644
--- a/l10ntools/source/treemerge.cxx
+++ b/l10ntools/source/treemerge.cxx
@@ -24,20 +24,6 @@
namespace
{
- //Write out an sdf line
- static void lcl_WriteSDF(
- std::ofstream &aSDFStream, const OString& rText, const OString& rPrj,
- const OString& rActFileName, const OString& rID, const OString& rType )
- {
- OString sOutput( rPrj ); sOutput += "\t";
- sOutput += rActFileName;
- sOutput += "\t0\t";
- sOutput += rType; sOutput += "\t";
- sOutput += rID; sOutput += "\t\t\t\t0\ten-US\t";
- sOutput += rText; sOutput += "\t\t\t\t";
- aSDFStream << sOutput.getStr() << std::endl;
- }
-
//Convert xmlChar* to OString
static OString lcl_xmlStrToOString( const xmlChar* pString )
{
@@ -51,8 +37,7 @@ namespace
//Extract strings from nodes on all level recursively
static void lcl_ExtractLevel(
const xmlDocPtr pSource, const xmlNodePtr pRoot,
- const xmlChar* pNodeName, std::ofstream& rSDFStream,
- const OString& rPrj, const OString& rRoot )
+ const xmlChar* pNodeName, PoOfstream& rPOStream )
{
if( !pRoot->children )
{
@@ -66,21 +51,17 @@ namespace
xmlChar* pID = xmlGetProp(pCurrent, (const xmlChar*)("id"));
xmlChar* pText =
xmlGetProp(pCurrent, (const xmlChar*)("title"));
- lcl_WriteSDF(
- rSDFStream,
- lcl_xmlStrToOString( pText ),
- rPrj,
- common::pathnameToken(
- pSource->name, rRoot.getStr()),
- lcl_xmlStrToOString( pID ),
- lcl_xmlStrToOString( pNodeName ));
+
+ Export::writePoEntry(
+ "Treex", rPOStream, pSource->name, lcl_xmlStrToOString( pNodeName ),
+ lcl_xmlStrToOString( pID ), OString(), OString(), lcl_xmlStrToOString( pText ));
xmlFree( pID );
xmlFree( pText );
lcl_ExtractLevel(
pSource, pCurrent, (const xmlChar *)("node"),
- rSDFStream, rPrj, rRoot );
+ rPOStream );
}
}
}
@@ -238,28 +219,26 @@ TreeParser::~TreeParser()
}
//Extract strings form source file
-void TreeParser::Extract(
- const OString& rSDFFile, const OString& rPrj, const OString& rRoot )
+void TreeParser::Extract( const OString& rPOFile )
{
assert( m_bIsInitialized );
- std::ofstream aSDFStream(
- rSDFFile.getStr(), std::ios_base::out | std::ios_base::trunc );
- if( !aSDFStream.is_open() )
+ PoOfstream aPOStream( rPOFile, PoOfstream::APP );
+ if( !aPOStream.isOpen() )
{
std::cerr
- << "Treex error: Cannot open sdffile for extract: "
- << rSDFFile.getStr() << std::endl;
+ << "Treex error: Cannot open po file for extract: "
+ << rPOFile.getStr() << std::endl;
return;
}
xmlNodePtr pRootNode = xmlDocGetRootElement( m_pSource );
lcl_ExtractLevel(
m_pSource, pRootNode, (const xmlChar *)("help_section"),
- aSDFStream, rPrj, rRoot );
+ aPOStream );
xmlFreeDoc( m_pSource );
xmlCleanupParser();
- aSDFStream.close();
+ aPOStream.close();
m_bIsInitialized = false;
}