Kaydet (Commit) 9ffe350a authored tarafından Christian Lohmaier's avatar Christian Lohmaier

pocheck: don't throw away Plural-Forms header

also don't change POT creation date when rewriting a po file, update
Po-Revision instead.
When creating templates, put X-Accelerator before X-Generator (like
pootle would order it)

Change-Id: I7fec4cb1c50e27b87decd9a892de3f01a02253ed
Reviewed-on: https://gerrit.libreoffice.org/63416
Tested-by: Jenkins
Reviewed-by: 's avatarChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>
üst 344773c6
......@@ -88,6 +88,7 @@ public:
friend class PoIfstream;
PoHeader( const OString& rExtSrc ); ///< Template Constructor
PoHeader( const OString& rExtSrc, const OString& rPoHeaderMsgStr );
~PoHeader();
PoHeader(const PoHeader&) = delete;
PoHeader& operator=(const PoHeader&) = delete;
......@@ -139,6 +140,7 @@ public:
bool eof() const { return m_bEof; }
void open(const OString& rFileName);
void open(const OString& rFileName, OString& sPoHeader);
void close();
void readEntry(PoEntry& rPo);
};
......
......@@ -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() );
......
......@@ -90,7 +90,8 @@ static void checkStyleNames(const OString& aLanguage)
"\nSee STR_POOLNUMRULE_*\n\n";
}
}
aPoInput.open(aPoPath);
OString sPoHdrMsg;
aPoInput.open(aPoPath, sPoHdrMsg);
if( !aPoInput.isOpen() )
{
std::cerr << "Warning: Cannot open " << aPoPath << std::endl;
......@@ -98,7 +99,7 @@ static void checkStyleNames(const OString& aLanguage)
}
PoOfstream aPoOutput;
aPoOutput.open(aPoPath+".new");
PoHeader aTmp("sw/inc");
PoHeader aTmp("sw/inc", sPoHdrMsg);
aPoOutput.writeHeader(aTmp);
bool bAnyError = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment