From 6e8aa1afd8a07a97d89e95bbbe07935a646b5133 Mon Sep 17 00:00:00 2001 From: Grigas <35135765+grigasp@users.noreply.github.com> Date: Wed, 7 Feb 2024 18:03:05 +0200 Subject: [PATCH] Remove localization. Let consumers supply the two strings we need. (#404) * Remove localization. Let consumers supply the two strings we need. * change --- .changeset/beige-suns-explode.md | 2 + .../api/presentation-core-interop.api.md | 5 -- .../api/presentation-core-interop.exports.csv | 1 - .../src/core-interop/Localization.ts | 16 ----- .../src/presentation-core-interop.ts | 1 - .../src/test/Localization.test.ts | 24 -------- .../hierarchy-builder/HierarchyValidation.ts | 3 +- .../hierarchy-builder/Localization.test.ts | 30 ---------- .../src/hierarchy-builder/Utils.ts | 5 +- .../grouping/PropertiesGrouping.test.ts | 25 ++++---- packages/hierarchy-builder/.npmignore | 2 - .../api/presentation-hierarchy-builder.api.md | 16 +++-- ...presentation-hierarchy-builder.exports.csv | 4 +- packages/hierarchy-builder/package.json | 5 +- .../en/PresentationHierarchyBuilder.json | 6 -- .../hierarchy-builder/HierarchyProvider.ts | 25 +++++++- .../src/hierarchy-builder/Localization.ts | 38 ------------ .../internal/operators/Grouping.ts | 9 ++- .../operators/grouping/PropertiesGrouping.ts | 17 ++++-- .../src/presentation-hierarchy-builder.ts | 1 - .../src/test/Localization.test.ts | 23 -------- packages/hierarchy-builder/src/test/Utils.ts | 6 ++ .../test/internal/operators/Grouping.test.ts | 17 +++--- .../grouping/PropertiesGrouping.test.ts | 59 +++++++++---------- 24 files changed, 117 insertions(+), 223 deletions(-) create mode 100644 .changeset/beige-suns-explode.md delete mode 100644 packages/core-interop/src/core-interop/Localization.ts delete mode 100644 packages/core-interop/src/test/Localization.test.ts delete mode 100644 packages/full-stack-tests/src/hierarchy-builder/Localization.test.ts delete mode 100644 packages/hierarchy-builder/public/locales/en/PresentationHierarchyBuilder.json delete mode 100644 packages/hierarchy-builder/src/hierarchy-builder/Localization.ts delete mode 100644 packages/hierarchy-builder/src/test/Localization.test.ts diff --git a/.changeset/beige-suns-explode.md b/.changeset/beige-suns-explode.md new file mode 100644 index 000000000..a845151cc --- /dev/null +++ b/.changeset/beige-suns-explode.md @@ -0,0 +1,2 @@ +--- +--- diff --git a/packages/core-interop/api/presentation-core-interop.api.md b/packages/core-interop/api/presentation-core-interop.api.md index ea1cb6a60..658e9411c 100644 --- a/packages/core-interop/api/presentation-core-interop.api.md +++ b/packages/core-interop/api/presentation-core-interop.api.md @@ -15,8 +15,6 @@ import { IMetadataProvider } from '@itwin/presentation-hierarchy-builder'; import { InstancesNodeKey } from '@itwin/presentation-hierarchy-builder'; import { IPrimitiveValueFormatter } from '@itwin/presentation-hierarchy-builder'; import { KeySet } from '@itwin/presentation-common'; -import { Localization } from '@itwin/core-common'; -import { LocalizationFunction } from '@itwin/presentation-hierarchy-builder'; import { QueryBinder } from '@itwin/core-common'; import { QueryOptions } from '@itwin/core-common'; import { RulesetVariable } from '@itwin/presentation-common'; @@ -45,9 +43,6 @@ export interface CreateHierarchyLevelDescriptorProps; - // @beta export function createLogger(): ILogger; diff --git a/packages/core-interop/api/presentation-core-interop.exports.csv b/packages/core-interop/api/presentation-core-interop.exports.csv index 7e717d574..294cb0993 100644 --- a/packages/core-interop/api/presentation-core-interop.exports.csv +++ b/packages/core-interop/api/presentation-core-interop.exports.csv @@ -3,7 +3,6 @@ Release Tag;API Item beta;createECSqlQueryExecutor(imodel: ICoreECSqlReaderFactory): IECSqlQueryExecutor beta;createHierarchyLevelDescriptor beta;CreateHierarchyLevelDescriptorProps -beta;createLocalizationFunction(localization: Localization): Promise beta;createLogger(): ILogger beta;createMetadataProvider(schemaContext: SchemaContext): IMetadataProvider beta;createValueFormatter(schemaContext: SchemaContext, unitSystem?: UnitSystemKey, baseFormatter?: IPrimitiveValueFormatter): IPrimitiveValueFormatter diff --git a/packages/core-interop/src/core-interop/Localization.ts b/packages/core-interop/src/core-interop/Localization.ts deleted file mode 100644 index 5d7e80ab5..000000000 --- a/packages/core-interop/src/core-interop/Localization.ts +++ /dev/null @@ -1,16 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Bentley Systems, Incorporated. All rights reserved. - * See LICENSE.md in the project root for license terms and full copyright notice. - *--------------------------------------------------------------------------------------------*/ - -import { Localization } from "@itwin/core-common"; -import { LOCALIZATION_NAMESPACE, LocalizationFunction } from "@itwin/presentation-hierarchy-builder"; - -/** - * Create a `LocalizationFunction` that uses [Localization]($core-common) API to register the namespace and create a localized string. - * @beta - */ -export async function createLocalizationFunction(localization: Localization): Promise { - await localization.registerNamespace(LOCALIZATION_NAMESPACE); - return (input) => localization.getLocalizedString(input); -} diff --git a/packages/core-interop/src/presentation-core-interop.ts b/packages/core-interop/src/presentation-core-interop.ts index febdf5d4f..e5d97a19f 100644 --- a/packages/core-interop/src/presentation-core-interop.ts +++ b/packages/core-interop/src/presentation-core-interop.ts @@ -5,7 +5,6 @@ export * from "./core-interop/Formatting"; export * from "./core-interop/HierarchyLevelDescriptor"; -export * from "./core-interop/Localization"; export * from "./core-interop/Logging"; export * from "./core-interop/Metadata"; export * from "./core-interop/QueryExecutor"; diff --git a/packages/core-interop/src/test/Localization.test.ts b/packages/core-interop/src/test/Localization.test.ts deleted file mode 100644 index 08a161bfe..000000000 --- a/packages/core-interop/src/test/Localization.test.ts +++ /dev/null @@ -1,24 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Bentley Systems, Incorporated. All rights reserved. - * See LICENSE.md in the project root for license terms and full copyright notice. - *--------------------------------------------------------------------------------------------*/ - -import { expect } from "chai"; -import sinon from "sinon"; -import { Localization } from "@itwin/core-common"; -import { LOCALIZATION_NAMESPACE } from "@itwin/presentation-hierarchy-builder"; -import { createLocalizationFunction } from "../core-interop/Localization"; - -describe("createTranslator", () => { - it("creates a localization function using provided core `Localization` object", async () => { - const registerNamespaceSpy = sinon.spy(); - const localization = { - getLocalizedString: (input: string) => `${input}_localized`, - registerNamespace: registerNamespaceSpy, - } as unknown as Localization; - const translator = await createLocalizationFunction(localization); - expect(registerNamespaceSpy).to.be.calledWith(LOCALIZATION_NAMESPACE); - const result = translator("Test"); - expect(result).to.be.eq("Test_localized"); - }); -}); diff --git a/packages/full-stack-tests/src/hierarchy-builder/HierarchyValidation.ts b/packages/full-stack-tests/src/hierarchy-builder/HierarchyValidation.ts index c703aebc2..bf5e2d76c 100644 --- a/packages/full-stack-tests/src/hierarchy-builder/HierarchyValidation.ts +++ b/packages/full-stack-tests/src/hierarchy-builder/HierarchyValidation.ts @@ -175,6 +175,7 @@ export namespace NodeValidators { } export function createForPropertyOtherValuesGroupingNode(props: { + label?: string; autoExpand?: boolean; children?: TChildren; }) { @@ -188,7 +189,7 @@ export namespace NodeValidators { } validateBaseNodeAttributes(node, { - label: "Òthér", + label: props.label, autoExpand: props.autoExpand, children: props.children, }); diff --git a/packages/full-stack-tests/src/hierarchy-builder/Localization.test.ts b/packages/full-stack-tests/src/hierarchy-builder/Localization.test.ts deleted file mode 100644 index 31f777272..000000000 --- a/packages/full-stack-tests/src/hierarchy-builder/Localization.test.ts +++ /dev/null @@ -1,30 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Bentley Systems, Incorporated. All rights reserved. - * See LICENSE.md in the project root for license terms and full copyright notice. - *--------------------------------------------------------------------------------------------*/ - -import { expect } from "chai"; -import { IModelApp } from "@itwin/core-frontend"; -import { createLocalizationFunction } from "@itwin/presentation-core-interop"; -import { setLocalizationFunction } from "@itwin/presentation-hierarchy-builder"; -import { translate } from "@itwin/presentation-hierarchy-builder/lib/cjs/hierarchy-builder/Localization"; -import { initialize, terminate } from "../IntegrationTests"; - -describe("Stateless hierarchy builder", () => { - describe("Localization", () => { - beforeEach(async () => { - await initialize(); - }); - - afterEach(async () => { - await terminate(); - }); - - it("translates strings using `IModelApp.localization`", async function () { - const localizationFunction = await createLocalizationFunction(IModelApp.localization); - setLocalizationFunction(localizationFunction); - const result = translate("grouping.other-label"); - expect(result).to.be.eq("Òthér"); - }); - }); -}); diff --git a/packages/full-stack-tests/src/hierarchy-builder/Utils.ts b/packages/full-stack-tests/src/hierarchy-builder/Utils.ts index 501c4152b..fa19d0051 100644 --- a/packages/full-stack-tests/src/hierarchy-builder/Utils.ts +++ b/packages/full-stack-tests/src/hierarchy-builder/Utils.ts @@ -12,6 +12,7 @@ import { createLimitingECSqlQueryExecutor, HierarchyNodeIdentifiersPath, HierarchyProvider, + HierarchyProviderLocalizedStrings, IHierarchyLevelDefinitionsFactory, IPrimitiveValueFormatter, parseFullClassName, @@ -53,14 +54,16 @@ export function createProvider(props: { imodel: IModelConnection | IModelDb | ECDb; hierarchy: IHierarchyLevelDefinitionsFactory; formatterFactory?: (schemas: SchemaContext) => IPrimitiveValueFormatter; + localizedStrings?: HierarchyProviderLocalizedStrings; filteredNodePaths?: HierarchyNodeIdentifiersPath[]; }) { - const { imodel, hierarchy, formatterFactory, filteredNodePaths } = props; + const { imodel, hierarchy, formatterFactory, localizedStrings, filteredNodePaths } = props; return new HierarchyProvider({ metadataProvider: createMetadataProvider(imodel), hierarchyDefinition: hierarchy, queryExecutor: createLimitingECSqlQueryExecutor(createECSqlQueryExecutor(imodel), 123), formatter: formatterFactory ? formatterFactory(createSchemaContext(imodel)) : undefined, + localizedStrings, filtering: filteredNodePaths ? { paths: filteredNodePaths } : undefined, }); } diff --git a/packages/full-stack-tests/src/hierarchy-builder/grouping/PropertiesGrouping.test.ts b/packages/full-stack-tests/src/hierarchy-builder/grouping/PropertiesGrouping.test.ts index 3e78bccbe..62d6ea920 100644 --- a/packages/full-stack-tests/src/hierarchy-builder/grouping/PropertiesGrouping.test.ts +++ b/packages/full-stack-tests/src/hierarchy-builder/grouping/PropertiesGrouping.test.ts @@ -5,14 +5,8 @@ import { Subject } from "@itwin/core-backend"; import { IModel } from "@itwin/core-common"; -import { IModelApp, IModelConnection } from "@itwin/core-frontend"; -import { createLocalizationFunction } from "@itwin/presentation-core-interop"; -import { - ECSqlSelectClausePropertiesGroupingParams, - IHierarchyLevelDefinitionsFactory, - NodeSelectQueryFactory, - setLocalizationFunction, -} from "@itwin/presentation-hierarchy-builder"; +import { IModelConnection } from "@itwin/core-frontend"; +import { ECSqlSelectClausePropertiesGroupingParams, IHierarchyLevelDefinitionsFactory, NodeSelectQueryFactory } from "@itwin/presentation-hierarchy-builder"; import { buildIModel, importSchema, insertSubject, withECDb } from "../../IModelUtils"; import { initialize, terminate } from "../../IntegrationTests"; import { NodeValidators, validateHierarchy } from "../HierarchyValidation"; @@ -284,16 +278,18 @@ describe("Stateless hierarchy builder", () => { propertyGroups: [{ propertyName: "Description", propertyClassAlias: "this" }], }; - const localizationFunction = await createLocalizationFunction(IModelApp.localization); - setLocalizationFunction(localizationFunction); await validateHierarchy({ - provider: createProvider({ imodel, hierarchy: createHierarchyWithSpecifiedGrouping(imodel, groupingParams) }), + provider: createProvider({ + imodel, + hierarchy: createHierarchyWithSpecifiedGrouping(imodel, groupingParams), + localizedStrings: { other: "", unspecified: "NOT SPECIFIED" }, + }), expect: [ NodeValidators.createForPropertyValueGroupingNode({ propertyClassName: "BisCore.Subject", propertyName: "Description", formattedPropertyValue: "", - label: "Ñót spêçìfíêd", + label: "NOT SPECIFIED", children: [ NodeValidators.createForInstanceNode({ instanceKeys: [keys.childSubject1], @@ -414,13 +410,12 @@ describe("Stateless hierarchy builder", () => { return []; }, }; - const provider = createProvider({ imodel, hierarchy }); - const localizationFunction = await createLocalizationFunction(IModelApp.localization); - setLocalizationFunction(localizationFunction); + const provider = createProvider({ imodel, hierarchy, localizedStrings: { other: "OTHER", unspecified: "" } }); await validateHierarchy({ provider, expect: [ NodeValidators.createForPropertyOtherValuesGroupingNode({ + label: "OTHER", children: [NodeValidators.createForInstanceNode({ instanceKeys: [x1] }), NodeValidators.createForInstanceNode({ instanceKeys: [x2] })], }), ], diff --git a/packages/hierarchy-builder/.npmignore b/packages/hierarchy-builder/.npmignore index 06f3449b0..feeee352a 100644 --- a/packages/hierarchy-builder/.npmignore +++ b/packages/hierarchy-builder/.npmignore @@ -7,8 +7,6 @@ !lib/**/*.d.ts.map !lib/**/*.js !lib/**/*.js.map -!lib/**/public/**/* # then ignore some stuff again lib/**/test/** -lib/**/public/locales/en-PSEUDO/** diff --git a/packages/hierarchy-builder/api/presentation-hierarchy-builder.api.md b/packages/hierarchy-builder/api/presentation-hierarchy-builder.api.md index 0301c17c4..864545320 100644 --- a/packages/hierarchy-builder/api/presentation-hierarchy-builder.api.md +++ b/packages/hierarchy-builder/api/presentation-hierarchy-builder.api.md @@ -730,6 +730,12 @@ export class HierarchyProvider { setFormatter(formatter: IPrimitiveValueFormatter | undefined): void; } +// @beta +export interface HierarchyProviderLocalizedStrings { + other: string; + unspecified: string; +} + // @beta export interface HierarchyProviderProps { filtering?: { @@ -737,6 +743,7 @@ export interface HierarchyProviderProps { }; formatter?: IPrimitiveValueFormatter; hierarchyDefinition: IHierarchyLevelDefinitionsFactory; + localizedStrings?: HierarchyProviderLocalizedStrings; metadataProvider: IMetadataProvider; queryConcurrency?: number; queryExecutor: ILimitingECSqlQueryExecutor; @@ -846,12 +853,6 @@ export interface LabelGroupingNodeKey extends BaseGroupingNodeKey { type: "label-grouping"; } -// @beta -export const LOCALIZATION_NAMESPACE = "PresentationHierarchyBuilder"; - -// @beta -export type LocalizationFunction = (input: string) => string; - // @beta (undocumented) export type LogFunction = (category: string, message: string) => void; @@ -1087,9 +1088,6 @@ export class RowsLimitExceededError extends Error { readonly limit: number; } -// @beta -export function setLocalizationFunction(localizationFunction?: LocalizationFunction): void; - // @beta export function setLogger(logger: ILogger | undefined): void; diff --git a/packages/hierarchy-builder/api/presentation-hierarchy-builder.exports.csv b/packages/hierarchy-builder/api/presentation-hierarchy-builder.exports.csv index 5893a4287..947f33efa 100644 --- a/packages/hierarchy-builder/api/presentation-hierarchy-builder.exports.csv +++ b/packages/hierarchy-builder/api/presentation-hierarchy-builder.exports.csv @@ -97,6 +97,7 @@ beta;HierarchyNodePropertyValueRange beta;HierarchyNodesDefinition = CustomHierarchyNodeDefinition | InstanceNodesQueryDefinition beta;HierarchyNodesDefinition beta;HierarchyProvider +beta;HierarchyProviderLocalizedStrings beta;HierarchyProviderProps beta;Id64String = string beta;IECSqlQueryExecutor @@ -116,8 +117,6 @@ beta;InstancesNodeChildHierarchyLevelDefinition beta;InstancesNodeKey beta;IPrimitiveValueFormatter = (value: TypedPrimitiveValue) => Promise beta;LabelGroupingNodeKey -beta;LOCALIZATION_NAMESPACE = "PresentationHierarchyBuilder" -beta;LocalizationFunction = (input: string) => string beta;LogFunction = (category: string, message: string) => void beta;NodeSelectClauseColumnNames beta;NodeSelectClauseProps @@ -155,7 +154,6 @@ beta;RelatedInstanceDescription beta;RelationshipPath beta;RelationshipPathStep beta;RowsLimitExceededError -beta;setLocalizationFunction(localizationFunction?: LocalizationFunction): void beta;setLogger(logger: ILogger | undefined): void beta;StandardHierarchyNodeKey = InstancesNodeKey | GroupingNodeKey beta;TypedPrimitiveValue \ No newline at end of file diff --git a/packages/hierarchy-builder/package.json b/packages/hierarchy-builder/package.json index bdcc89bb0..d5101451c 100644 --- a/packages/hierarchy-builder/package.json +++ b/packages/hierarchy-builder/package.json @@ -23,11 +23,10 @@ "module": "lib/esm/presentation-hierarchy-builder.js", "types": "lib/cjs/presentation-hierarchy-builder.d.ts", "scripts": { - "build": "npm run -s copy:locale && npm run -s build:cjs && npm run -s build:esm", + "build": "npm run -s build:cjs && npm run -s build:esm", "build:cjs": "tsc -p tsconfig.cjs.json", "build:esm": "tsc -p tsconfig.esm.json", - "build:watch": "npm run -s copy:locale && npm run -s build:cjs -- -w", - "copy:locale": "cpx \"./public/**/*\" ./lib/public", + "build:watch": "npm run -s build:cjs -- -w", "clean": "rimraf lib", "cover": "nyc npm -s test", "lint": "eslint ./src/**/*.ts", diff --git a/packages/hierarchy-builder/public/locales/en/PresentationHierarchyBuilder.json b/packages/hierarchy-builder/public/locales/en/PresentationHierarchyBuilder.json deleted file mode 100644 index b2acd54e6..000000000 --- a/packages/hierarchy-builder/public/locales/en/PresentationHierarchyBuilder.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "grouping": { - "other-label": "Other", - "unspecified-label": "Not specified" - } -} diff --git a/packages/hierarchy-builder/src/hierarchy-builder/HierarchyProvider.ts b/packages/hierarchy-builder/src/hierarchy-builder/HierarchyProvider.ts index cc6f1d535..7872c928e 100644 --- a/packages/hierarchy-builder/src/hierarchy-builder/HierarchyProvider.ts +++ b/packages/hierarchy-builder/src/hierarchy-builder/HierarchyProvider.ts @@ -62,6 +62,24 @@ const DEFAULT_QUERY_CONCURRENCY = 10; */ export type ParentHierarchyNode = Omit; +/** + * Defines the strings used by hierarchy provider. + * @beta + */ +export interface HierarchyProviderLocalizedStrings { + /** + * A string for "Unspecified". Used for labels of property grouping nodes + * that group by an empty value. + */ + unspecified: string; + + /** + * A string for "Other". Used for label of a range property grouping node that + * groups values which don't fit into any other range. + */ + other: string; +} + /** * Props for [[HierarchyProvider]]. * @beta @@ -86,6 +104,9 @@ export interface HierarchyProviderProps { */ formatter?: IPrimitiveValueFormatter; + /** A set of localized strings to use. Defaults to English strings. */ + localizedStrings?: HierarchyProviderLocalizedStrings; + /** Props for filtering the hierarchy. */ filtering?: { /** A list of node identifiers from root to target node. */ @@ -120,6 +141,7 @@ export class HierarchyProvider { private _metadataProvider: IMetadataProvider; private _queryReader: TreeQueryResultsReader; private _valuesFormatter: IPrimitiveValueFormatter; + private _localizedStrings: HierarchyProviderLocalizedStrings; private _queryScheduler: SubscriptionScheduler; private _nodesCache: ChildNodesCache; @@ -153,6 +175,7 @@ export class HierarchyProvider { this._queryReader = new TreeQueryResultsReader({ parser: props.hierarchyDefinition.parseNode }); } this._valuesFormatter = props?.formatter ?? createDefaultValueFormatter(); + this._localizedStrings = props?.localizedStrings ?? { other: "Other", unspecified: "Not specified" }; this._queryScheduler = new SubscriptionScheduler(props.queryConcurrency ?? DEFAULT_QUERY_CONCURRENCY); this._nodesCache = new ChildNodesCache(); this.queryExecutor = props.queryExecutor; @@ -228,7 +251,7 @@ export class HierarchyProvider { ): Observable { return preprocessedNodesObservable.pipe( sortNodesByLabelOperator, - createGroupingOperator(this._metadataProvider, this._valuesFormatter, (gn) => this.onGroupingNodeCreated(gn, props)), + createGroupingOperator(this._metadataProvider, this._valuesFormatter, this._localizedStrings, (gn) => this.onGroupingNodeCreated(gn, props)), ); } diff --git a/packages/hierarchy-builder/src/hierarchy-builder/Localization.ts b/packages/hierarchy-builder/src/hierarchy-builder/Localization.ts deleted file mode 100644 index 5038a5efd..000000000 --- a/packages/hierarchy-builder/src/hierarchy-builder/Localization.ts +++ /dev/null @@ -1,38 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Bentley Systems, Incorporated. All rights reserved. - * See LICENSE.md in the project root for license terms and full copyright notice. - *--------------------------------------------------------------------------------------------*/ - -/** A localization function implementation returns the same input. */ -const NOOP_LOCALIZATION_FUNCTION = (input: string) => input; - -// eslint-disable-next-line @typescript-eslint/naming-convention -let g_localizationFunction = NOOP_LOCALIZATION_FUNCTION; - -/** - * An type for a localization function used by this package. - * @beta - */ -export type LocalizationFunction = (input: string) => string; - -/** - * A namespace that is used for localization. - * @beta - */ -export const LOCALIZATION_NAMESPACE = "PresentationHierarchyBuilder"; - -/** - * Set localization function to use by this package. By default the package uses a no-op localization function. - * @beta - */ -export function setLocalizationFunction(localizationFunction?: LocalizationFunction) { - g_localizationFunction = localizationFunction || NOOP_LOCALIZATION_FUNCTION; -} - -/** - * Use localization function that is set in this package. - * @internal - */ -export function translate(input: string) { - return g_localizationFunction(`${LOCALIZATION_NAMESPACE}:${input}`); -} diff --git a/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts b/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts index dcf3a2487..ad7c4ae0c 100644 --- a/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts +++ b/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/Grouping.ts @@ -14,7 +14,7 @@ import { createBaseClassGroupingHandlers } from "./grouping/BaseClassGrouping"; import { createClassGroups } from "./grouping/ClassGrouping"; import { applyGroupHidingParams } from "./grouping/GroupHiding"; import { createLabelGroups } from "./grouping/LabelGrouping"; -import { createPropertiesGroupingHandlers } from "./grouping/PropertiesGrouping"; +import { createPropertiesGroupingHandlers, PropertiesGroupingLocalizedStrings } from "./grouping/PropertiesGrouping"; const OPERATOR_NAME = "Grouping"; /** @internal */ @@ -24,6 +24,7 @@ export const LOGGING_NAMESPACE = createOperatorLoggingNamespace(OPERATOR_NAME); export function createGroupingOperator( metadata: IMetadataProvider, valueFormatter: IPrimitiveValueFormatter, + localizedStrings: PropertiesGroupingLocalizedStrings, onGroupingNodeCreated?: (groupingNode: ProcessedGroupingHierarchyNode) => void, groupingHandlers?: GroupingHandler[], ) { @@ -31,7 +32,9 @@ export function createGroupingOperator( return nodes.pipe( toArray(), concatMap((resolvedNodes) => { - const groupingHandlersObs = groupingHandlers ? of(groupingHandlers) : from(createGroupingHandlers(metadata, resolvedNodes, valueFormatter)); + const groupingHandlersObs = groupingHandlers + ? of(groupingHandlers) + : from(createGroupingHandlers(metadata, resolvedNodes, valueFormatter, localizedStrings)); return groupingHandlersObs.pipe( concatMap(async (createdGroupingHandlers) => { const { instanceNodes, restNodes } = partitionInstanceNodes(resolvedNodes); @@ -122,6 +125,7 @@ export async function createGroupingHandlers( metadata: IMetadataProvider, nodes: ProcessedHierarchyNode[], valueFormatter: IPrimitiveValueFormatter, + localizedStrings: PropertiesGroupingLocalizedStrings, ): Promise { const groupingHandlers: GroupingHandler[] = new Array(); groupingHandlers.push( @@ -136,6 +140,7 @@ export async function createGroupingHandlers( metadata, nodes.filter((n): n is ProcessedInstanceHierarchyNode => HierarchyNode.isInstancesNode(n)), valueFormatter, + localizedStrings, )), ); groupingHandlers.push(async (allNodes) => createLabelGroups(allNodes)); diff --git a/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/PropertiesGrouping.ts b/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/PropertiesGrouping.ts index 020942851..57e683af3 100644 --- a/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/PropertiesGrouping.ts +++ b/packages/hierarchy-builder/src/hierarchy-builder/internal/operators/grouping/PropertiesGrouping.ts @@ -12,7 +12,6 @@ import { ProcessedInstanceHierarchyNode, PropertyGroupingNodeKey, } from "../../../HierarchyNode"; -import { translate } from "../../../Localization"; import { OmitOverUnion } from "../../../Utils"; import { IPrimitiveValueFormatter } from "../../../values/Formatting"; import { TypedPrimitiveValue } from "../../../values/Values"; @@ -30,6 +29,12 @@ interface PropertyGroupingInformation { grouped: Map; } +/** @internal */ +export interface PropertiesGroupingLocalizedStrings { + other: string; + unspecified: string; +} + /** @internal */ export interface PropertyGroupInfo { ecClass: ECClass; @@ -46,6 +51,7 @@ export async function createPropertyGroups( nodes: ProcessedInstanceHierarchyNode[], handlerGroupingParams: PropertyGroupInfo, valueFormatter: IPrimitiveValueFormatter, + localizedStrings: PropertiesGroupingLocalizedStrings, ): Promise { const groupings: PropertyGroupingInformation = { ungrouped: [], grouped: new Map() }; for (const node of nodes) { @@ -77,7 +83,7 @@ export async function createPropertyGroups( groupings.grouped, `${currentProperty.propertyName}:Unspecified`, { - label: translate("grouping.unspecified-label"), + label: localizedStrings.unspecified, propertyGroupingNodeKey: { type: "property-grouping:value", ...partialPropertyNodeKeyToAdd, @@ -134,7 +140,7 @@ export async function createPropertyGroups( groupings.grouped, "Other", { - label: translate("grouping.other-label"), + label: localizedStrings.other, propertyGroupingNodeKey: { type: "property-grouping:other", }, @@ -332,7 +338,10 @@ export async function createPropertiesGroupingHandlers( metadata: IMetadataProvider, nodes: ProcessedInstanceHierarchyNode[], valueFormatter: IPrimitiveValueFormatter, + localizedStrings: PropertiesGroupingLocalizedStrings, ): Promise { const propertiesGroupInfo = await getUniquePropertiesGroupInfo(metadata, nodes); - return propertiesGroupInfo.map((propertyInfo) => async (allNodes) => createPropertyGroups(metadata, allNodes, propertyInfo, valueFormatter)); + return propertiesGroupInfo.map( + (propertyInfo) => async (allNodes) => createPropertyGroups(metadata, allNodes, propertyInfo, valueFormatter, localizedStrings), + ); } diff --git a/packages/hierarchy-builder/src/presentation-hierarchy-builder.ts b/packages/hierarchy-builder/src/presentation-hierarchy-builder.ts index b4f76ebaf..4d7ec8515 100644 --- a/packages/hierarchy-builder/src/presentation-hierarchy-builder.ts +++ b/packages/hierarchy-builder/src/presentation-hierarchy-builder.ts @@ -22,7 +22,6 @@ export * from "./hierarchy-builder/HierarchyDefinition"; export * from "./hierarchy-builder/HierarchyErrors"; export * from "./hierarchy-builder/HierarchyNode"; export * from "./hierarchy-builder/HierarchyProvider"; -export { LOCALIZATION_NAMESPACE, LocalizationFunction, setLocalizationFunction } from "./hierarchy-builder/Localization"; export * from "./hierarchy-builder/Logging"; export * from "./hierarchy-builder/Metadata"; export * from "./hierarchy-builder/Utils"; diff --git a/packages/hierarchy-builder/src/test/Localization.test.ts b/packages/hierarchy-builder/src/test/Localization.test.ts deleted file mode 100644 index 4b12e82af..000000000 --- a/packages/hierarchy-builder/src/test/Localization.test.ts +++ /dev/null @@ -1,23 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Bentley Systems, Incorporated. All rights reserved. - * See LICENSE.md in the project root for license terms and full copyright notice. - *--------------------------------------------------------------------------------------------*/ - -import { expect } from "chai"; -import { LOCALIZATION_NAMESPACE, setLocalizationFunction, translate } from "../hierarchy-builder/Localization"; - -describe("translate", () => { - it("returns same input with namespace appended when localizationFunction isn't set", () => { - expect(translate("Test")).to.eq(`${LOCALIZATION_NAMESPACE}:Test`); - }); - - it("returns same input with namespace appended when localizationFunction is set to undefined", () => { - setLocalizationFunction(); - expect(translate("Test")).to.eq(`${LOCALIZATION_NAMESPACE}:Test`); - }); - - it("returns input modified by custom localizationFunction with namespace appended when localizationFunction is set", () => { - setLocalizationFunction((input) => `${input}_translated`); - expect(translate("Test")).to.eq(`${LOCALIZATION_NAMESPACE}:Test_translated`); - }); -}); diff --git a/packages/hierarchy-builder/src/test/Utils.ts b/packages/hierarchy-builder/src/test/Utils.ts index 75ea6ed93..759974a79 100644 --- a/packages/hierarchy-builder/src/test/Utils.ts +++ b/packages/hierarchy-builder/src/test/Utils.ts @@ -14,6 +14,7 @@ import { ProcessedGroupingHierarchyNode, ProcessedInstanceHierarchyNode, } from "../hierarchy-builder/HierarchyNode"; +import { HierarchyProviderLocalizedStrings } from "../hierarchy-builder/HierarchyProvider"; import * as common from "../hierarchy-builder/internal/Common"; import { parseFullClassName } from "../hierarchy-builder/Metadata"; import { ECSqlQueryReader } from "../hierarchy-builder/queries/ECSqlCore"; @@ -255,3 +256,8 @@ export function createFakeQueryReader(rows: object[]): ECSqlQueryReader { } })(); } + +export const testLocalizedStrings: HierarchyProviderLocalizedStrings = { + other: "_Other_", + unspecified: "_Unspecified_", +}; diff --git a/packages/hierarchy-builder/src/test/internal/operators/Grouping.test.ts b/packages/hierarchy-builder/src/test/internal/operators/Grouping.test.ts index 90428596f..9dcd46f5b 100644 --- a/packages/hierarchy-builder/src/test/internal/operators/Grouping.test.ts +++ b/packages/hierarchy-builder/src/test/internal/operators/Grouping.test.ts @@ -22,7 +22,7 @@ import * as groupHiding from "../../../hierarchy-builder/internal/operators/grou import * as labelGrouping from "../../../hierarchy-builder/internal/operators/grouping/LabelGrouping"; import * as propertiesGrouping from "../../../hierarchy-builder/internal/operators/grouping/PropertiesGrouping"; import { createDefaultValueFormatter, IPrimitiveValueFormatter } from "../../../hierarchy-builder/values/Formatting"; -import { createTestProcessedGroupingNode, createTestProcessedInstanceNode, getObservableResult, setupLogging } from "../../Utils"; +import { createTestProcessedGroupingNode, createTestProcessedInstanceNode, getObservableResult, setupLogging, testLocalizedStrings } from "../../Utils"; describe("Grouping", () => { const metadataProvider = {} as unknown as IMetadataProvider; @@ -59,7 +59,7 @@ describe("Grouping", () => { const result = await getObservableResult( from(nodes).pipe( - createGroupingOperator(metadataProvider, formatter, undefined, [ + createGroupingOperator(metadataProvider, formatter, testLocalizedStrings, undefined, [ async (allNodes) => ({ grouped: [], ungrouped: allNodes, groupingType: "label" }), async (allNodes) => ({ grouped: [], ungrouped: allNodes, groupingType: "class" }), ]), @@ -132,7 +132,10 @@ describe("Grouping", () => { const result = await getObservableResult( from(classGroupingInput).pipe( - createGroupingOperator(metadataProvider, formatter, undefined, [async () => classGroupingResult, async (input) => createLabelGroupingResult(input)]), + createGroupingOperator(metadataProvider, formatter, testLocalizedStrings, undefined, [ + async () => classGroupingResult, + async (input) => createLabelGroupingResult(input), + ]), ), ); expect(assignAutoExpandStub.callCount).to.eq(3); @@ -211,7 +214,7 @@ describe("Grouping", () => { }); const result = await getObservableResult( from([groupedNode, ungroupedNode]).pipe( - createGroupingOperator(metadataProvider, formatter, undefined, [ + createGroupingOperator(metadataProvider, formatter, testLocalizedStrings, undefined, [ async () => ({ groupingType: "class", grouped: [classGroupingNode], @@ -252,7 +255,7 @@ describe("Grouping", () => { const onGroupingNodeCreated = sinon.spy(); const result = await getObservableResult( from([groupedNode]).pipe( - createGroupingOperator(metadataProvider, formatter, onGroupingNodeCreated, [ + createGroupingOperator(metadataProvider, formatter, testLocalizedStrings, onGroupingNodeCreated, [ async () => ({ groupingType: "class", grouped: [classGroupingNode], @@ -321,11 +324,11 @@ describe("Grouping", () => { }), ]; - const result = await createGroupingHandlers(metadataProvider, nodes, formatter); + const result = await createGroupingHandlers(metadataProvider, nodes, formatter, testLocalizedStrings); expect(createBaseClassGroupingHandlersStub.callCount).to.eq(1); expect(createBaseClassGroupingHandlersStub.firstCall).to.be.calledWith(metadataProvider, nodes); expect(createPropertiesGroupingHandlersStub.callCount).to.eq(1); - expect(createPropertiesGroupingHandlersStub.firstCall).to.be.calledWith(metadataProvider, nodes, formatter); + expect(createPropertiesGroupingHandlersStub.firstCall).to.be.calledWith(metadataProvider, nodes, formatter, testLocalizedStrings); expect(result.length).to.eq(4); expect(baseClassHandlerStub.callCount).to.eq(0); await result[0]([]); diff --git a/packages/hierarchy-builder/src/test/internal/operators/grouping/PropertiesGrouping.test.ts b/packages/hierarchy-builder/src/test/internal/operators/grouping/PropertiesGrouping.test.ts index b21ca89ae..1fce5b0d7 100644 --- a/packages/hierarchy-builder/src/test/internal/operators/grouping/PropertiesGrouping.test.ts +++ b/packages/hierarchy-builder/src/test/internal/operators/grouping/PropertiesGrouping.test.ts @@ -9,9 +9,8 @@ import { omit } from "@itwin/core-bentley"; import { ECClass, ECProperty, IMetadataProvider } from "../../../../hierarchy-builder/ECMetadata"; import { GroupingNodeKey, HierarchyNodePropertyGroup, PropertyOtherValuesGroupingNodeKey } from "../../../../hierarchy-builder/HierarchyNode"; import * as propertiesGrouping from "../../../../hierarchy-builder/internal/operators/grouping/PropertiesGrouping"; -import { LOCALIZATION_NAMESPACE } from "../../../../hierarchy-builder/Localization"; import { createDefaultValueFormatter, IPrimitiveValueFormatter } from "../../../../hierarchy-builder/values/Formatting"; -import { ClassStubs, createClassStubs, createTestProcessedGroupingNode, createTestProcessedInstanceNode } from "../../../Utils"; +import { ClassStubs, createClassStubs, createTestProcessedGroupingNode, createTestProcessedInstanceNode, testLocalizedStrings } from "../../../Utils"; describe("PropertiesGrouping", () => { const metadataProvider = {} as unknown as IMetadataProvider; @@ -423,7 +422,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -450,7 +449,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [{ propertiesClassName: "TestSchema.Class", propertyGroup: { propertyName: "PropertyName2" } }], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -477,7 +476,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "Other" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -504,7 +503,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName", ranges: [{ fromValue: 1, toValue: 5 }] }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -537,7 +536,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -572,7 +571,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [{ propertiesClassName: "TestSchema.Class", propertyGroup: { propertyName: "Other" } }], propertyGroup: { propertyName: "PropertyName2" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -592,7 +591,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -626,7 +625,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -659,7 +658,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName" }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -700,11 +699,11 @@ describe("PropertiesGrouping", () => { formattedPropertyValue: "", groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ - label: `${LOCALIZATION_NAMESPACE}:grouping.unspecified-label`, + label: testLocalizedStrings.unspecified, key: expectedGroupingNodeKey, children: nodes.map((n) => ({ ...n, parentKeys: [...n.parentKeys, omit(expectedGroupingNodeKey, ["groupedInstanceKeys"])] })), }), @@ -746,7 +745,7 @@ describe("PropertiesGrouping", () => { formattedPropertyValue: "PropertyValue", groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -803,7 +802,7 @@ describe("PropertiesGrouping", () => { formattedPropertyValue: "PropertyValue", groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -867,7 +866,7 @@ describe("PropertiesGrouping", () => { formattedPropertyValue: "PropertyValue2", groupedInstanceKeys: nodes[1].key.instanceKeys, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -929,7 +928,7 @@ describe("PropertiesGrouping", () => { formattedPropertyValue: "PropertyValue", groupedInstanceKeys: nodes[0].key.instanceKeys, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -970,7 +969,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName", ranges: [{ fromValue: 1, toValue: 5 }] }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -1008,11 +1007,11 @@ describe("PropertiesGrouping", () => { type: "property-grouping:other", groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ - label: `${LOCALIZATION_NAMESPACE}:grouping.other-label`, + label: testLocalizedStrings.other, key: expectedGroupingNodeKey, children: nodes.map((n) => ({ ...n, @@ -1050,7 +1049,7 @@ describe("PropertiesGrouping", () => { previousPropertiesGroupingInfo: [], propertyGroup: { propertyName: "PropertyName", ranges: [{ fromValue: 1, toValue: 5 }] }, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [], ungrouped: nodes, @@ -1088,11 +1087,11 @@ describe("PropertiesGrouping", () => { type: "property-grouping:other", groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ - label: `${LOCALIZATION_NAMESPACE}:grouping.other-label`, + label: testLocalizedStrings.other, key: expectedGroupingNodeKey, children: nodes.map((n) => ({ ...n, @@ -1138,7 +1137,7 @@ describe("PropertiesGrouping", () => { toValue: 5, groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1185,7 +1184,7 @@ describe("PropertiesGrouping", () => { toValue: 5.5, groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1243,7 +1242,7 @@ describe("PropertiesGrouping", () => { toValue: 5, groupedInstanceKeys: nodes[0].key.instanceKeys, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1301,7 +1300,7 @@ describe("PropertiesGrouping", () => { toValue: 5, groupedInstanceKeys: nodes.flatMap((n) => n.key.instanceKeys), }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1363,7 +1362,7 @@ describe("PropertiesGrouping", () => { toValue: 4, groupedInstanceKeys: nodes[0].key.instanceKeys, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1453,7 +1452,7 @@ describe("PropertiesGrouping", () => { toValue: 4, groupedInstanceKeys: nodes[1].key.instanceKeys, }; - expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter)).to.deep.eq({ + expect(await propertiesGrouping.createPropertyGroups(metadataProvider, nodes, propertyInfo, formatter, testLocalizedStrings)).to.deep.eq({ groupingType: "property", grouped: [ createTestProcessedGroupingNode({ @@ -1498,7 +1497,7 @@ describe("PropertiesGrouping", () => { className: "Class", }); - const result = await propertiesGrouping.createPropertiesGroupingHandlers(metadataProvider, nodes, formatter); + const result = await propertiesGrouping.createPropertiesGroupingHandlers(metadataProvider, nodes, formatter, testLocalizedStrings); expect(result.length).to.eq(1); const handlerResult = await result[0](nodes); expect(handlerResult.groupingType).to.eq("property");