summaryrefslogtreecommitdiff
path: root/l10ntools/source/po.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'l10ntools/source/po.cxx')
-rw-r--r--l10ntools/source/po.cxx36
1 files changed, 34 insertions, 2 deletions
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index bb4a06c03f36..4e60d82160d3 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -446,6 +446,16 @@ namespace
}
}
+// when updating existing files (pocheck), reuse provided po-header
+PoHeader::PoHeader( const OString& rExtSrc, const OString& rPoHeaderMsgStr )
+ : m_pGenPo( new GenPoEntry() )
+ , m_bIsInitialized( false )
+{
+ m_pGenPo->setExtractCom("extracted from " + rExtSrc);
+ m_pGenPo->setMsgStr(rPoHeaderMsgStr);
+ m_bIsInitialized = true;
+}
+
PoHeader::PoHeader( const OString& rExtSrc )
: m_pGenPo( new GenPoEntry() )
, m_bIsInitialized( false )
@@ -462,8 +472,8 @@ PoHeader::PoHeader( const OString& rExtSrc )
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
- "X-Generator: LibreOffice\n"
- "X-Accelerator-Marker: ~\n"));
+ "X-Accelerator-Marker: ~\n"
+ "X-Generator: LibreOffice\n"));
m_bIsInitialized = true;
}
@@ -562,6 +572,28 @@ PoIfstream::~PoIfstream()
}
}
+void PoIfstream::open( const OString& rFileName, OString& rPoHeader )
+{
+ assert( !isOpen() );
+ m_aInPut.open( rFileName.getStr(), std::ios_base::in );
+
+ // capture header, updating timestamp and generator
+ std::string sTemp;
+ std::getline(m_aInPut,sTemp);
+ while( !sTemp.empty() && !m_aInPut.eof() )
+ {
+ std::getline(m_aInPut,sTemp);
+ OString sLine = OString(sTemp.data(),sTemp.length());
+ if (sLine.startsWith("\"PO-Revision-Date"))
+ rPoHeader += "PO-Revision-Date: " + lcl_GetTime() + "\n";
+ else if (sLine.startsWith("\"X-Generator"))
+ rPoHeader += "X-Generator: LibreOffice\n";
+ else if (sLine.startsWith("\""))
+ rPoHeader += lcl_GenNormString(sLine);
+ }
+ m_bEof = false;
+}
+
void PoIfstream::open( const OString& rFileName )
{
assert( !isOpen() );