l10ntools/inc/po.hxx | 2 ++ l10ntools/source/po.cxx | 36 ++++++++++++++++++++++++++++++++++-- l10ntools/source/pocheck.cxx | 5 +++-- 3 files changed, 39 insertions(+), 4 deletions(-)
New commits: commit 03f2c4eb95d7c2d22e4240f0ebccb65981a68c86 Author: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> AuthorDate: Thu Nov 15 13:19:31 2018 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Wed Nov 21 13:41:24 2018 +0100 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: Christian Lohmaier <lohmaier+libreoff...@googlemail.com> (cherry picked from commit 9ffe350ae344e9863330fbb2405c37df6b9d0984) Reviewed-on: https://gerrit.libreoffice.org/63603 Reviewed-by: Caolán McNamara <caol...@redhat.com> Tested-by: Caolán McNamara <caol...@redhat.com> diff --git a/l10ntools/inc/po.hxx b/l10ntools/inc/po.hxx index e213f47e177a..aff8b88af100 100644 --- a/l10ntools/inc/po.hxx +++ b/l10ntools/inc/po.hxx @@ -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); }; diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx index e784e3d025bb..a120c52cdc86 100644 --- a/l10ntools/source/po.cxx +++ b/l10ntools/source/po.cxx @@ -445,6 +445,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 ) @@ -461,8 +471,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; } @@ -561,6 +571,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() ); diff --git a/l10ntools/source/pocheck.cxx b/l10ntools/source/pocheck.cxx index 4f7c7686757a..04b01121266d 100644 --- a/l10ntools/source/pocheck.cxx +++ b/l10ntools/source/pocheck.cxx @@ -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; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits