diff --git a/functionalTests/designer/localization_dynamic.ts b/functionalTests/designer/localization_dynamic.ts new file mode 100644 index 0000000000..a246483052 --- /dev/null +++ b/functionalTests/designer/localization_dynamic.ts @@ -0,0 +1,17 @@ +import { url, setJSON, setSurveyProp } from "../helper"; +import { ClientFunction, Selector } from "testcafe"; +const title = "Localization UI"; +const customLogicTabName = "Miner Logik"; + +fixture(title) + .page(url) + .beforeEach(async (t) => { + await t.maximizeWindow(); + }); + +test("Change Creator.locale property", async (t) => { + await setJSON({ elements: [{ type: "checkbox", name: "question1" }] }); + await t.click(Selector("[data-name='question1']")); + await setSurveyProp("locale", "de"); + await t.expect(Selector(".svc-survey-element-toolbar-item__title--with-icon").withText("Auswahl").exists).ok(); +}); \ No newline at end of file diff --git a/packages/survey-creator-core/src/components/action-container-view-model.ts b/packages/survey-creator-core/src/components/action-container-view-model.ts index 34a9609987..95394303cb 100644 --- a/packages/survey-creator-core/src/components/action-container-view-model.ts +++ b/packages/survey-creator-core/src/components/action-container-view-model.ts @@ -305,7 +305,11 @@ export class SurveyElementAdornerBase e this.createActionContainers(); this.attachToUI(surveyElement); } - + private creatorOnLocaleChanged: (sender: Base, options: any) => void = (_, options) => { + if(this.surveyElement) { + this.updateActionsContainer(this.surveyElement); + } + }; public static GetAdorner(surveyElement: SurveyElement): V { return surveyElement.getPropertyValue(SurveyElementAdornerBase.AdornerValueName) as V; } @@ -364,6 +368,7 @@ export class SurveyElementAdornerBase e } if (this.surveyElement != surveyElement) { this.setSurveyElement(surveyElement); + this.creator.onLocaleChanded.add(this.creatorOnLocaleChanged); this.creator.sidebar.onPropertyChanged.add(this.sidebarFlyoutModeChangedFunc); this.creator.expandCollapseManager.add(this); } @@ -377,6 +382,7 @@ export class SurveyElementAdornerBase e this.rootElement = undefined; this.detachOnlyMyElement(); this.surveyElement = undefined; + this.creator.onLocaleChanded.remove(this.creatorOnLocaleChanged); this.creator.sidebar.onPropertyChanged.remove(this.sidebarFlyoutModeChangedFunc); this.creator.expandCollapseManager.remove(this); } diff --git a/packages/survey-creator-core/src/creator-base.ts b/packages/survey-creator-core/src/creator-base.ts index 97a67bd7c4..ec567d6afb 100644 --- a/packages/survey-creator-core/src/creator-base.ts +++ b/packages/survey-creator-core/src/creator-base.ts @@ -1330,7 +1330,9 @@ export class SurveyCreatorModel extends Base editorLocalization.currentLocale = value; this.setPropertyValue("locale", value); this.updateLocalizedStrings(); + this.onLocaleChanded.fire(this, { locale: value }); } + public onLocaleChanded: EventBase = this.addCreatorEvent(); public updateLocalizedStrings(): void { this.toolbox.updateTitles(); this.refreshPlugin();