Fix unresolved i18n placeholder keys

This commit is contained in:
biss committed 2026-11-14 14:53:16 +08:00
1 parent b7eeb75294
commit 9fa1ea4d65
4 files changed
+24 -19

No files matched your search

+6 -1
View File
@@ -36,8 +36,12 @@ for (const name of ['TeachingMonitoringView.vue', 'AcademicPlanningView.vue', 'P
}
const viewsDirectory = new URL('../src/views/', import.meta.url)
const missingBatchReferences = []
const numericPlaceholderReferences = []
for (const name of readdirSync(viewsDirectory).filter((file) => file.endsWith('.vue'))) {
const source = readFileSync(new URL(name, viewsDirectory), 'utf8')
for (const match of source.matchAll(/(?:^|[.\"'])k\d+(?=[.\"']|$)/gm)) {
numericPlaceholderReferences.push(`${name}: ${match[0].trim()}`)
}
for (const match of source.matchAll(/t\(['"]((?:batchBusiness|workflowBatch|timetableTemplate|teacherAttendanceTemplate|gradesTemplate|examsTemplate|curriculumTemplate|fitnessTemplate|selectionTemplate|teachingTaskTemplate|assessmentTemplate|dormTemplate|dormTemplateCounts|experimentsTemplate|experimentsDynamic|schedulesTemplate|schedulesDynamic|physicalFitnessScript|teacherAttendanceScript|timetableScript|dormScript|gradeAnalyticsScript|examsScript|experimentGradesScript|curriculumScript|teachingTasksScript|courseSelectionScript|experimentsScript|gradesScript|schedulesScript|assessmentScript)\.[^'"]+)['"]/g)) {
if (!reference.has(match[1])) missingBatchReferences.push(`${name}: ${match[1]}`)
}
@@ -55,13 +59,14 @@ const english = new Map(values(enUS))
const placeholders = (value) => [...new Set([...String(value).matchAll(/\{(\w+)\}/g)].map((match) => match[1]))].sort().join(',')
const mismatched = values(zhCN).filter(([key, value]) => candidate.has(key) && placeholders(value) !== placeholders(english.get(key))).map(([key]) => key)
if (missing.length || extra.length || hardcoded.length || mismatched.length || fixedLocaleViews.length || missingBatchReferences.length) {
if (missing.length || extra.length || hardcoded.length || mismatched.length || fixedLocaleViews.length || missingBatchReferences.length || numericPlaceholderReferences.length) {
if (missing.length) console.error(`en-US missing keys:\n${missing.join('\n')}`)
if (extra.length) console.error(`en-US extra keys:\n${extra.join('\n')}`)
if (hardcoded.length) console.error(`Hardcoded Chinese in completed views:\n${hardcoded.join('\n')}`)
if (mismatched.length) console.error(`Interpolation parameters differ:\n${mismatched.join('\n')}`)
if (fixedLocaleViews.length) console.error(`Fixed Chinese display formats:\n${fixedLocaleViews.join('\n')}`)
if (missingBatchReferences.length) console.error(`Missing batch translations:\n${missingBatchReferences.join('\n')}`)
if (numericPlaceholderReferences.length) console.error(`Numeric placeholder i18n references:\n${numericPlaceholderReferences.join('\n')}`)
process.exitCode = 1
} else {
console.log(`i18n catalogs match (${reference.size} keys).`)
+11 -11
View File
@@ -621,13 +621,13 @@ function approvalEndpoint(type: string) {
function approvalLabel(item: any) {
const types: Record<string, string> = {
CourseExemption: "k69",
DeferredExam: "k70",
GradeModification: "k71",
CourseSubstitution: "k72",
StudentStatusChange: "k73",
GradeSheet: "k74",
AttendanceAppeal: "k75",
CourseExemption: "courseExemption",
DeferredExam: "deferredExam",
GradeModification: "gradeChange",
CourseSubstitution: "courseSubstitution",
StudentStatusChange: "studentStatusChange",
GradeSheet: "gradeReview",
AttendanceAppeal: "attendanceAppeal",
};
if (item.type === "TeacherCourseApplication")
return t("approvalCenterExtra.teacherCourse");
@@ -648,10 +648,10 @@ function approvalLabel(item: any) {
if (extra[item.type]) return t(`approvalCenterExtra.${extra[item.type]}`);
if (item.type === "CourseAdjustment") {
const adjustments: Record<string, string> = {
调课: "k0",
停课: "k1",
补课: "k2",
代课: "k3",
调课: "reschedule",
停课: "cancelClass",
补课: "makeupClass",
代课: "substituteTeacher",
};
return adjustments[item.label]
? t(`adjustmentBatch.${adjustments[item.label]}`)
+5 -5
View File
@@ -721,7 +721,7 @@ async function automatic() {
saving.value = true;
assignments.value = [];
allocationJobId.value = undefined;
allocationJobStatus.value = "dormScript.k37";
allocationJobStatus.value = "dormScript.jobQueued";
await safe(async () => {
const { data } = await http.post(
"/dormitory-services/allocations/preview",
@@ -745,13 +745,13 @@ async function automatic() {
});
allocationJobStatus.value =
status === 1
? "dormScript.k37"
? "dormScript.jobQueued"
: status === 2
? "dormScript.k38"
? "dormScript.calculatingInBackground"
: status === 3
? "dormScript.k39"
? "dormScript.previewGenerated"
: status === 5
? "dormScript.k40"
? "dormScript.calculationFailed"
: "";
if (status === 3) {
assignments.value = job.assignments ?? [];
Loaded 3 of 4 files, more files were not shown because too many files have changed in this diff. Show more