summaryrefslogtreecommitdiff
path: root/l10ntools
diff options
context:
space:
mode:
authorChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-10-27 13:45:43 +0200
committerChristian Lohmaier <lohmaier+LibreOffice@googlemail.com>2018-10-27 16:31:33 +0200
commitb44b9c4519794d159b154a9713c10da1155a5198 (patch)
tree02740b10b1932bab933be1f9a1e3aa5660ce1a7c /l10ntools
parent8d21f814dff7b56e03c5c2526ede53d18584bbaa (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
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 27daba097a42..bb4a06c03f36 100644
--- a/l10ntools/source/po.cxx
+++ b/l10ntools/source/po.cxx
@@ -33,7 +33,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;
@@ -118,7 +120,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 )
@@ -148,8 +152,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)
@@ -196,11 +208,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;