diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-10-05 15:48:01 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-10-09 09:52:33 +0200 |
commit | 283229f5bc27ce23456b9cbd9aff75ff44707105 (patch) | |
tree | ecadd85a8937555c8404290ac19c0af6baf4f266 /unotools/source/i18n | |
parent | cc6d591e1c4202afdbc30a76fd56d66b7547fa34 (diff) |
Related: tdf#83128 support translation of plural forms
Change-Id: Id3d41099a895ca5423be2ac3d497851bc65eaff7
Reviewed-on: https://gerrit.libreoffice.org/61426
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'unotools/source/i18n')
-rw-r--r-- | unotools/source/i18n/resmgr.cxx | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/unotools/source/i18n/resmgr.cxx b/unotools/source/i18n/resmgr.cxx index f93aaa00b226..8d4fcb5eac33 100644 --- a/unotools/source/i18n/resmgr.cxx +++ b/unotools/source/i18n/resmgr.cxx @@ -206,6 +206,7 @@ namespace Translate { sContext = OString(pContextAndId, pId - pContextAndId); ++pId; + assert(!strchr(pId, '\004') && "should be using nget, not get"); } //if it's a key id locale, generate it here @@ -220,6 +221,31 @@ namespace Translate return ExpandVariables(createFromUtf8(ret.data(), ret.size())); } + OUString nget(const char* pContextAndIds, int n, const std::locale &loc) + { + OString sContextIdId(pContextAndIds); + std::vector<OString> aContextIdId; + sal_Int32 nIndex = 0; + do + { + aContextIdId.push_back(sContextIdId.getToken(0, '\004', nIndex)); + } + while (nIndex >= 0); + assert(aContextIdId.size() == 3 && "should be using get, not nget"); + + //if it's a key id locale, generate it here + if (std::use_facet<boost::locale::info>(loc).language() == "qtz") + { + OString sKeyId(genKeyId(aContextIdId[0] + "|" + aContextIdId[1])); + int nForm = n == 0 ? 1 : 2; + return OUString::fromUtf8(sKeyId) + OUStringLiteral1(0x2016) + createFromUtf8(aContextIdId[nForm].getStr(), aContextIdId[nForm].getLength()); + } + + //otherwise translate it + const std::string ret = boost::locale::npgettext(aContextIdId[0].getStr(), aContextIdId[1].getStr(), aContextIdId[2].getStr(), n, loc); + return ExpandVariables(createFromUtf8(ret.data(), ret.size())); + } + static ResHookProc pImplResHookProc = nullptr; OUString ExpandVariables(const OUString& rString) |