Skip to content

Commit

Permalink
Check that all properties are in English localization #6401
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Jan 20, 2025
1 parent ffae02c commit 2142035
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion packages/survey-creator-core/tests/localization.tests.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { editorLocalization, defaultStrings } from "../src/editorLocalization";
import { CreatorTester } from "./creator-tester";
import { Action } from "survey-core";
import { Action, Serializer } from "survey-core";
export * from "../src/localization/italian";
export * from "../src/localization/french";
import { enStrings } from "../src/localization/english";

test("Get nested property", () => {
expect(editorLocalization.getString("qt.text")).toEqual("Single-Line Input");
Expand Down Expand Up @@ -316,3 +317,44 @@ test("Support preset locale strings", () => {

editorLocalization.defaultLocale = "";
});
test("All properties should be in English translation", () => {
const classes = ["survey", "page", "panel", "matrixdropdown", "calculatedvalue", "choicesByUrl", "multipletextitem"];
const addClasses = (baseClassName: string): void => {
classes.push(baseClassName);
Serializer.getChildrenClasses(baseClassName, true).forEach((qType) => {
if (["linkvalue", "color"].indexOf(qType.name) < 0) {
classes.push(qType.name);
}
});
};
addClasses("question");
addClasses("expressionitem");
addClasses("itemvalue");
addClasses("trigger");
addClasses("surveyvalidator");
addClasses("masksettings");
const errors = new Array<any>();
const englishStrings = enStrings;
const checkPropertyDisplayName = (className: string, propertyName: string): void => {
if(!!englishStrings.p[propertyName]) return;
if(!!englishStrings.pe[propertyName]) return;
let cl: any = Serializer.findClass(className);
if(cl.parentName) {
if(!!cl.parentName && Serializer.findProperty(cl.parentName, propertyName)) return;
}
while(!!cl) {
const tClass = englishStrings.pe[cl.name];
if(tClass && !!tClass[propertyName]) return;
cl = !!cl.parentName ? Serializer.findClass(cl.parentName) : undefined;
}
errors.push({ className: className, propertyName: propertyName });
};
classes.forEach((className) => {
Serializer.getProperties(className).forEach((prop) => {
if(prop.visible !== false) {
checkPropertyDisplayName(className, prop.name);
}
});
});
expect(errors).toHaveLength(0);
});

0 comments on commit 2142035

Please sign in to comment.