diff options
author | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-11-15 13:19:31 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-11-17 11:50:46 +0100 |
commit | 9ffe350ae344e9863330fbb2405c37df6b9d0984 (patch) | |
tree | 5aefcc81146b6a06fde4aaf41633d79082c21e4e /l10ntools | |
parent | 344773c608ea28718b630590ee1023247aa62d63 (diff) |
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+LibreOffice@googlemail.com>
Diffstat (limited to 'l10ntools')
-rw-r--r-- | l10ntools/inc/po.hxx | 2 | ||||
-rw-r--r-- | l10ntools/source/po.cxx | 36 | ||||
-rw-r--r-- | l10ntools/source/pocheck.cxx | 5 |
3 files changed, 39 insertions, 4 deletions
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 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() ); diff --git a/l10ntools/source/pocheck.cxx b/l10ntools/source/pocheck.cxx index 49aa9551c3fb..14b9983ec20d 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; |