summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-10-27 13:45:43 +0200
committerCaolán McNamara <caolanm@redhat.com>2018-11-21 13:40:26 +0100
commit52bc5ad50fefb649f5172f5da66e37cc4bb0d067 (patch)
tree06703a3011e9571db17de4af773e106cff32be02 /l10ntools
parent6592cbe220e188bebf33cacce234923dca8eeaba (diff)
pocheck: don't choke on plural forms
Change-Id: I51a82ce5fc09d44ebc6f7c06c67b475ee2adf68b Reviewed-on: https://gerrit.libreoffice.org/62419 Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> Tested-by: Jenkins (cherry picked from commit b44b9c4519794d159b154a9713c10da1155a5198) Reviewed-on: https://gerrit.libreoffice.org/63601 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'l10ntools')
-rw-r--r--l10ntools/source/po.cxx27
1 files changed, 25 insertions, 2 deletions
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;