[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - l10ntools/source
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 21 12:40:50 UTC 2018
l10ntools/source/po.cxx | 27 +++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
New commits:
commit 52bc5ad50fefb649f5172f5da66e37cc4bb0d067
Author: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
AuthorDate: Sat Oct 27 13:45:43 2018 +0200
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Nov 21 13:40:26 2018 +0100
pocheck: don't choke on plural forms
Change-Id: I51a82ce5fc09d44ebc6f7c06c67b475ee2adf68b
Reviewed-on: https://gerrit.libreoffice.org/62419
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice at googlemail.com>
Tested-by: Jenkins
(cherry picked from commit b44b9c4519794d159b154a9713c10da1155a5198)
Reviewed-on: https://gerrit.libreoffice.org/63601
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/l10ntools/source/po.cxx b/l10ntools/source/po.cxx
index f1e37d53c20f..e784e3d025bb 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -32,7 +32,9 @@ private:
std::vector<OString> m_sReferences;
OString m_sMsgCtxt;
OString m_sMsgId;
+ OString m_sMsgIdPlural;
OString m_sMsgStr;
+ std::vector<OString> m_sMsgStrPlural;
bool m_bFuzzy;
bool m_bCFormat;
bool m_bNull;
@@ -117,7 +119,9 @@ GenPoEntry::GenPoEntry()
, m_sReferences( std::vector<OString>() )
, m_sMsgCtxt( OString() )
, m_sMsgId( OString() )
+ , m_sMsgIdPlural( OString() )
, m_sMsgStr( OString() )
+ , m_sMsgStrPlural( std::vector<OString>() )
, m_bFuzzy( false )
, m_bCFormat( false )
, m_bNull( false )
@@ -147,8 +151,16 @@ void GenPoEntry::writeToFile(std::ofstream& rOFStream) const
<< std::endl;
rOFStream << "msgid "
<< lcl_GenMsgString(m_sMsgId) << std::endl;
- rOFStream << "msgstr "
- << lcl_GenMsgString(m_sMsgStr) << std::endl;
+ if ( !m_sMsgIdPlural.isEmpty() )
+ rOFStream << "msgid_plural "
+ << lcl_GenMsgString(m_sMsgIdPlural)
+ << std::endl;
+ if ( !m_sMsgStrPlural.empty() )
+ for(auto & line : m_sMsgStrPlural)
+ rOFStream << line.copy(0,10) << lcl_GenMsgString(line.copy(10)) << std::endl;
+ else
+ rOFStream << "msgstr "
+ << lcl_GenMsgString(m_sMsgStr) << std::endl;
}
void GenPoEntry::readFromFile(std::ifstream& rIFStream)
@@ -195,11 +207,22 @@ void GenPoEntry::readFromFile(std::ifstream& rIFStream)
m_sMsgId = lcl_GenNormString(sLine.copy(6));
pLastMsg = &m_sMsgId;
}
+ else if (sLine.startsWith("msgid_plural "))
+ {
+ m_sMsgIdPlural = lcl_GenNormString(sLine.copy(13));
+ pLastMsg = &m_sMsgIdPlural;
+ }
else if (sLine.startsWith("msgstr "))
{
m_sMsgStr = lcl_GenNormString(sLine.copy(7));
pLastMsg = &m_sMsgStr;
}
+ else if (sLine.startsWith("msgstr["))
+ {
+ // assume there are no more than 10 plural forms...
+ // and that plural strings are never split to multi-line in po
+ m_sMsgStrPlural.push_back(sLine.copy(0,10) + lcl_GenNormString(sLine.copy(10)));
+ }
else if (sLine.startsWith("\"") && pLastMsg)
{
OString sReference;
More information about the Libreoffice-commits
mailing list