Skip to content

Commit

Permalink
Pre-processing translation strings stop working in v1.9.106/107 fix #…
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov authored Sep 16, 2023
1 parent 9ab7c41 commit 964e63d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/survey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ export class SurveyModel extends SurveyElementCore
private variablesHash: HashTable<any> = {};
private editingObjValue: Base;

private textPreProcessor: TextPreProcessor;

private timerModelValue: SurveyTimerModel;

private navigationBarValue: ActionContainer;
Expand Down Expand Up @@ -827,10 +825,6 @@ export class SurveyModel extends SurveyElementCore
this.createLocalizableString("editText", this, false, true);
this.createLocalizableString("questionTitleTemplate", this, true);

this.textPreProcessor = new TextPreProcessor();
this.textPreProcessor.onProcess = (textValue: TextPreProcessorValue) => {
this.getProcessedTextValue(textValue);
};
this.timerModelValue = new SurveyTimerModel(this);
this.timerModelValue.onTimer = (page: PageModel): void => {
this.doTimer(page);
Expand Down Expand Up @@ -6596,6 +6590,16 @@ export class SurveyModel extends SurveyElementCore
res.hasAllValuesOnLastRun = this.textPreProcessor.hasAllValuesOnLastRun;
return res;
}
private textPreProcessorValue: TextPreProcessor;
private get textPreProcessor(): TextPreProcessor {
if(!this.textPreProcessorValue) {
this.textPreProcessorValue = new TextPreProcessor();
this.textPreProcessorValue.onProcess = (textValue: TextPreProcessorValue) => {
this.getProcessedTextValue(textValue);
};
}
return this.textPreProcessorValue;
}
private processTextCore(
text: string,
returnDisplayValue: boolean,
Expand Down
14 changes: 14 additions & 0 deletions tests/surveytests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17872,3 +17872,17 @@ QUnit.test("Test propertyValue() function", function (assert) {
q2: [{ q2_q1_exp: "Q2_Q1" }],
q3: [{ col1_exp: "Column 1" }] }, "propertyValue works correctly");
});
QUnit.test("Error on pre-processing localizable string Bug#6967", function (assert) {
const prevVal = surveyLocalization.locales.en.completeText;
surveyLocalization.locales.en.completeText = "{q1}";
const survey = new SurveyModel({
elements: [
{
type: "text",
name: "q1"
}]
});
survey.data = { q1: 2 };
assert.equal(survey.locCompleteText.renderedHtml, "2", "Preprocess correctly");
surveyLocalization.locales.en.completeText = prevVal;
});

0 comments on commit 964e63d

Please sign in to comment.