From 94a50d967421c7e99817d2d5cb4336fc77cd51bf Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Thu, 6 Feb 2020 08:37:24 +0100 Subject: [PATCH] Context_utils: added getTranslatedTitle-function --- process/Context_lib/process.js | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/process/Context_lib/process.js b/process/Context_lib/process.js index 1b910f2e34..f70649273f 100644 --- a/process/Context_lib/process.js +++ b/process/Context_lib/process.js @@ -35,14 +35,29 @@ ContextUtils.getCurrentContextId = function() * Returns the title of the context * * @param {String} pContextId id of the context - * @param {boolean} [pTranslate=false] if the title should be translated + * @param {boolean} [pAutoTranslate=false] pass "true" if the title should be translated with the current locale * * @return {String} title of the context */ -ContextUtils.getTitle = function(pContextId, pTranslate) +ContextUtils.getTitle = function(pContextId, pAutoTranslate) { - var title = project.getDataModel(project.DATAMODEL_KIND_CONTEXT, pContextId)[1]; - return pTranslate ? translate.text(title) : title; + var dataModel = project.getDataModel(project.DATAMODEL_KIND_CONTEXT, pContextId); + var title = dataModel[1]; + return pAutoTranslate ? translate.text(title) : title; +} + +/** + * Returns the translated title of the context + * + * @param {String} pContextId id of the context + * @param {String} [pLocale=null] the locale for the translation, e.g. "de_DE" + * + * @return {String} title of the context, translated to the given (or default) locale + */ +ContextUtils.getTranslatedTitle = function(pContextId, pLocale) +{ + var title = ContextUtils.getTitle(pContextId, false); + return pLocale ? translate.text(title, pLocale) : translate.text(title); } /** -- GitLab