summaryrefslogtreecommitdiff
path: root/unotools/source/i18n
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-08-02 16:06:05 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-03 12:18:15 +0200
commit5afdcad4c0e7850b18996c549892b9360cd8973f (patch)
tree53bd3997d044fdf869ae4643855eef722682983e /unotools/source/i18n
parent39d364958447cd33a6e30dc9d2904ad94fd40aba (diff)
Pass context and resource string down to boost::locale separately
because this is often on a hot path, and we can avoid the splitting and joining of strings like this. Change-Id: I2a24a123a64b762fd0741c45eaca3ad4bdd5580d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119884 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'unotools/source/i18n')
-rw-r--r--unotools/source/i18n/resmgr.cxx29
1 files changed, 29 insertions, 0 deletions
diff --git a/unotools/source/i18n/resmgr.cxx b/unotools/source/i18n/resmgr.cxx
index 9d3aec3a607c..7095316859f7 100644
--- a/unotools/source/i18n/resmgr.cxx
+++ b/unotools/source/i18n/resmgr.cxx
@@ -313,6 +313,29 @@ namespace Translate
return result;
}
+ OUString nget(TranslateNId aContextSingularPlural, int n, const std::locale &loc)
+ {
+ //if it's a key id locale, generate it here
+ if (std::use_facet<boost::locale::info>(loc).language() == "qtz")
+ {
+ OString sKeyId(genKeyId(OString::Concat(aContextSingularPlural.mpContext) + "|" + aContextSingularPlural.mpSingular));
+ const char* pForm = n == 0 ? aContextSingularPlural.mpSingular : aContextSingularPlural.mpPlural;
+ return OUString::fromUtf8(sKeyId) + u"\u2016" + createFromUtf8(pForm, strlen(pForm));
+ }
+
+ //otherwise translate it
+ const std::string ret = boost::locale::npgettext(aContextSingularPlural.mpContext, aContextSingularPlural.mpSingular, aContextSingularPlural.mpPlural, n, loc);
+ OUString result(ExpandVariables(createFromUtf8(ret.data(), ret.size())));
+
+ if (comphelper::LibreOfficeKit::isActive())
+ {
+ if (std::use_facet<boost::locale::info>(loc).country() == "CH" &&
+ std::use_facet<boost::locale::info>(loc).language() == "de")
+ result = result.replaceAll(OUString::fromUtf8("\xC3\x9F"), "ss");
+ }
+ return result;
+ }
+
static ResHookProc pImplResHookProc = nullptr;
OUString ExpandVariables(const OUString& rString)
@@ -338,5 +361,11 @@ bool TranslateId::operator==(const TranslateId& other) const
return strcmp(mpContext, other.mpContext) == 0 && strcmp(mpId,other.mpId) == 0;
}
+bool TranslateNId::operator==(const TranslateNId& other) const
+{
+ return strcmp(mpContext, other.mpContext) == 0
+ && strcmp(mpSingular, other.mpSingular) == 0
+ && strcmp(mpPlural, other.mpPlural) == 0;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */