From 60f17d8eb3964bbb0f90dccf79138e96c852621b Mon Sep 17 00:00:00 2001 From: btaillon <54454747+btaillon@users.noreply.github.com> Date: Mon, 6 Dec 2021 10:24:59 -0500 Subject: [PATCH] JSUI-3321 Removed generic localization from dynamic facet values (#1812) https://coveord.atlassian.net/browse/JSUI-3321 --- src/ui/Facet/FacetUtils.ts | 10 +++++----- src/ui/Misc/FileTypes.ts | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ui/Facet/FacetUtils.ts b/src/ui/Facet/FacetUtils.ts index fdb774345d..c158befbc9 100644 --- a/src/ui/Facet/FacetUtils.ts +++ b/src/ui/Facet/FacetUtils.ts @@ -15,7 +15,7 @@ export class FacetUtils { } static getDisplayValueFromValueCaption(value: string, field: string, valueCaption: Record) { - const returnValue = this.tryToGetTranslatedCaption(field, value); + const returnValue = this.tryToGetTranslatedCaption(field, value, false); return valueCaption[value] || returnValue; } @@ -93,17 +93,17 @@ export class FacetUtils { } } - static tryToGetTranslatedCaption(field: string, value: string) { + static tryToGetTranslatedCaption(field: string, value: string, fallbackOnLocalization = true) { let found: string; if (QueryUtils.isStratusAgnosticField(field.toLowerCase(), '@filetype')) { - found = FileTypes.getFileType(value).caption; + found = FileTypes.getFileType(value, fallbackOnLocalization).caption; } else if (QueryUtils.isStratusAgnosticField(field.toLowerCase(), '@objecttype')) { - found = FileTypes.getObjectType(value).caption; + found = FileTypes.getObjectType(value, fallbackOnLocalization).caption; } else if (FacetUtils.isMonthFieldValue(field, value)) { const month = parseInt(value, 10); found = DateUtils.monthToString(month - 1); - } else { + } else if (fallbackOnLocalization) { found = l(value); } return found != undefined && Utils.isNonEmptyString(found) ? found : value; diff --git a/src/ui/Misc/FileTypes.ts b/src/ui/Misc/FileTypes.ts index e9516f426a..ae350f9617 100644 --- a/src/ui/Misc/FileTypes.ts +++ b/src/ui/Misc/FileTypes.ts @@ -32,7 +32,7 @@ export class FileTypes { } } - static getObjectType(objecttype: string): IFileTypeInfo { + static getObjectType(objecttype: string, fallbackOnLocalization = true): IFileTypeInfo { // We must use lowercase filetypes because that's how the CSS classes // are generated (they are case sensitive, alas). const loweredCaseObjecttype = objecttype.toLowerCase(); @@ -43,13 +43,13 @@ export class FileTypes { // Some strings are sent as `objecttype_[...]` to specify a dictionary to use. If there's no match, try using // the main dictionary by using the original value. if (localizedString.toLowerCase() == variableValue.toLowerCase()) { - localizedString = l(objecttype); + localizedString = fallbackOnLocalization ? l(objecttype) : objecttype; } return this.safelyBuildFileTypeInfo('objecttype', loweredCaseObjecttype, localizedString); } - static getFileType(filetype: string): IFileTypeInfo { + static getFileType(filetype: string, fallbackOnLocalization = true): IFileTypeInfo { // We must use lowercase filetypes because that's how the CSS classes // are generated (they are case sensitive, alas). let loweredCaseFiletype = filetype.toLowerCase(); @@ -66,7 +66,7 @@ export class FileTypes { if (localizedString.toLowerCase() == variableValue.toLowerCase()) { // Some strings are sent as `filetype_[...]` to specify a dictionary to use. If there's no match, try using // The main dictionary by using the original value. - localizedString = l(filetype); + localizedString = fallbackOnLocalization ? l(filetype) : filetype; } return this.safelyBuildFileTypeInfo('filetype', loweredCaseFiletype, localizedString);