From 1efa1b1120e2fdd9e9f2e061546ea29ad53aecf1 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Tue, 21 May 2019 13:44:03 +0200 Subject: [PATCH] fix language keyword --- process/Keyword_lib/process.js | 45 +++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/process/Keyword_lib/process.js b/process/Keyword_lib/process.js index b741984d9a..95d93c4caf 100644 --- a/process/Keyword_lib/process.js +++ b/process/Keyword_lib/process.js @@ -265,4 +265,47 @@ KeywordAttribute.prototype.getValue = function(pKeyId) .buildSql("select " + this.dbField + " from AB_KEYWORD_ENTRY join AB_KEYWORD_ATTRIBUTERELATION on AB_KEYWORD_ENTRY.AB_KEYWORD_ENTRYID = AB_KEYWORD_ATTRIBUTERELATION.AB_KEYWORD_ENTRY_ID"); return db.cell(sql); -} \ No newline at end of file +} + +/** + * provides methods for interactions with the sepcial-keywords "LANGUAGE" + * + * @class + */ +function LanguageKeywordUtils(){} + +/** +* resolves Languagecode into the latin name +* +* @param {String} pDbFieldName name fo the database field where the ISO3-value is stored +* @param {String} [pLocale=current client language] specifies the locale for translating the title; can be false if nothing shalle be translated +* +* @return {String} a SQL-expression (case-when-statement) +*/ +LanguageKeywordUtils.getResolvedTitleSqlPart = function(pDbFieldName, pLocale) +{ + var data = LanguageData.getData(); + var resSql = SqlUtils.getResolvingCaseWhen(data, pDbFieldName, pLocale); + return db.translateStatement(resSql); +}; + +/** + * returns a specific name (translated) - this is normally the view-value of a language + * + * @param {String} key id value of the language where the view-value shall be searched + * @param {String} [locale=locale depending on current client/servercontext] Language-value for translations + * + * @return {String} representation of the translated name + * + */ +LanguageKeywordUtils.getViewValue = function(key, locale) +{ + if (!key) + return ""; + + var languageMap = LanguageData.getIso3Map(locale); + var title = languageMap[key]; + if (title == undefined) + return ""; + return title; +}; \ No newline at end of file -- GitLab