Skip to content

Commit

Permalink
Components doesn't include into used locales strings from internal qu…
Browse files Browse the repository at this point in the history
…estions fix #7510
  • Loading branch information
andrewtelnov committed Dec 15, 2023
1 parent 54a21e5 commit 78b7b79
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ export class Base {
// this.propertyValueChanged(name, oldValue, value);
}
}
public addUsedLocales(locales: Array<string>) {
public addUsedLocales(locales: Array<string>): void {
if (!!this.localizableStrings) {
for (let key in this.localizableStrings) {
let item = this.getLocalizableString(key);
Expand Down
6 changes: 6 additions & 0 deletions src/question_custom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,12 @@ export abstract class QuestionCustomModelBase extends Question
this.getElement().localeChanged();
}
}
public addUsedLocales(locales: Array<string>): void {
super.addUsedLocales(locales);
if(!!this.getElement()) {
this.getElement().addUsedLocales(locales);
}
}
protected createWrapper(): void { }
protected onPropertyValueChanged(name: string, oldValue: any, newValue: any): void {
super.onPropertyValueChanged(name, oldValue, newValue);
Expand Down
29 changes: 29 additions & 0 deletions tests/question_customtests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,35 @@ QUnit.test("Composite: change locale, Bug#2730", function (assert) {
survey.locale = "";
ComponentCollection.Instance.clear();
});
QUnit.test("getUsedLocale, Bug#7510", function (assert) {
ComponentCollection.Instance.add({
name: "comp1",
questionJSON: {
type: "text",
title: { en: "Title en", de: "Title de" }
}
});
ComponentCollection.Instance.add({
name: "comp2",
elementsJSON: [
{
type: "text",
name: "q1",
title: { en: "Title en", fr: "Title fr" }
},
{
type: "text",
name: "q2",
title: { en: "Title en", it: "Title it" }
},
]
});
const survey = new SurveyModel({
elements: [{ type: "comp1", name: "q1" }, { type: "comp2", name: "q2" }],
});
assert.deepEqual(survey.getUsedLocales(), ["en", "de", "fr", "it"], "Pick-up locales from components");
ComponentCollection.Instance.clear();
});
QUnit.test("getDisplayValue from component JSON function", function (assert) {
var json = {
name: "fullname",
Expand Down

0 comments on commit 78b7b79

Please sign in to comment.