feat: complete catalog and exam localization and localize display dates
This commit is contained in:
1 parent
ed1f861708
commit
93b3916b11
27 files changed
+324
-266
No files matched your search
@@ -1,5 +1,7 @@
|
||||
import enUS from '../src/i18n/messages/en-US.ts'
|
||||
import zhCN from '../src/i18n/messages/zh-CN.ts'
|
||||
import { readFileSync, readdirSync } from 'node:fs'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
function flatten(value, prefix = '') {
|
||||
return Object.entries(value).flatMap(([key, child]) => {
|
||||
@@ -13,9 +15,35 @@ const candidate = new Set(flatten(enUS))
|
||||
const missing = [...reference].filter((key) => !candidate.has(key))
|
||||
const extra = [...candidate].filter((key) => !reference.has(key))
|
||||
|
||||
if (missing.length || extra.length) {
|
||||
// Fully migrated pages must not silently reintroduce hardcoded Chinese UI copy.
|
||||
const completedViews = ['CoursesView.vue', 'OtherExamsView.vue', 'BaseDataView.vue']
|
||||
const hardcoded = completedViews.filter((name) => {
|
||||
const file = fileURLToPath(new URL(`../src/views/${name}`, import.meta.url))
|
||||
let source = readFileSync(file, 'utf8')
|
||||
// These are editable persisted business defaults, not display labels.
|
||||
if (name === 'BaseDataView.vue') source = source.replace("degreeType: '学士'", '').replace("roomType: '普通教室'", '')
|
||||
return /\p{Script=Han}/u.test(source)
|
||||
})
|
||||
const viewsDirectory = new URL('../src/views/', import.meta.url)
|
||||
const fixedLocaleViews = readdirSync(viewsDirectory).filter((name) => name.endsWith('.vue') &&
|
||||
/(?:toLocale(?:Date|Time)?String|DateTimeFormat|NumberFormat|Collator)\(['"]zh-CN['"]/.test(readFileSync(new URL(name, viewsDirectory), 'utf8')))
|
||||
|
||||
function values(value, prefix = '') {
|
||||
return Object.entries(value).flatMap(([key, child]) => {
|
||||
const path = prefix ? `${prefix}.${key}` : key
|
||||
return child && typeof child === 'object' ? values(child, path) : [[path, child]]
|
||||
})
|
||||
}
|
||||
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) {
|
||||
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')}`)
|
||||
process.exitCode = 1
|
||||
} else {
|
||||
console.log(`i18n catalogs match (${reference.size} keys).`)
|
||||
|
||||
@@ -30,6 +30,10 @@ function detectLocale(): AppLocale {
|
||||
|
||||
export const currentLocale = ref<AppLocale>(detectLocale())
|
||||
|
||||
export function getDisplayLocale(): AppLocale {
|
||||
return currentLocale.value
|
||||
}
|
||||
|
||||
export const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: currentLocale.value,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
export default {
|
||||
baseData: {"campus":"Campus","campusHint":"Physical university campuses","college":"College","collegeHint":"Teaching organizations","major":"Major","majorHint":"Majors and awarded degrees","class":"Administrative class","classHint":"Classes organized by enrollment year","term":"Term","termHint":"Teaching timeline","building":"Teaching building","buildingHint":"Teaching buildings on campus","classroom":"Classroom","classroomHint":"Teaching spaces available for scheduling","category":"Course category","categoryHint":"Teaching field of a course","organization":"Organizations","organizationDescription":"Maintain the hierarchy of campuses, colleges, majors, and administrative classes.","academicTerms":"Academic years and terms","termDescription":"Maintain academic years, term boundaries, and the current working term.","facilities":"Teaching facilities","facilitiesDescription":"Maintain classrooms available for scheduling by campus and building.","categoryDescription":"Maintain teaching fields including foundational studies, arts, ethics, innovation, and entrepreneurship. Course nature and category are independent.","generalRoom":"General classroom","laboratory":"Laboratory","training":"Training room","computerLab":"Computer lab","languageLab":"Language lab","sports":"Sports venue","arts":"Arts venue","unset":"Not set","bachelor":"Bachelor","confirmImport":"Confirm import","import":"Import","cancel":"Cancel","requiredFields":"Enter the code and name.","saved":"Changes saved","deleteTitle":"Confirm deletion","delete":"Delete","deleted":"Deleted","switchTerm":"Switch current term","switchCurrent":"Set as current","tabsAria":"Base data categories","allArchive":"All archive statuses","unarchived":"Not archived","archived":"Archived","search":"Search code, name, or parent organization","enrollmentYear":"Enrollment year","allCampuses":"All campuses","allBuildings":"All teaching buildings","venueNature":"Venue nature","minimumCapacity":"Minimum capacity","disabled":"Disabled","excelImport":"Import Excel","export":"Export results","switchHint":"Switching the current term changes only the default working term. Archive manually; makeup exams and grade corrections remain available after archiving.","selectTerms":"Select terms","archiveMany":"Archive selected","restoreMany":"Restore selected","current":"Current","historical":"Historical term","setCurrent":"Set as current","unarchive":"Unarchive","archive":"Archive","archiveHistory":"Archive history","viewHistory":"View history","code":"Code","name":"Name","parentCampus":"Campus","parentCollege":"College","degreeType":"Degree type","parentMajor":"Major","counselor":"Counselor","unassigned":"Unassigned","academicYear":"Academic year","operationalStatus":"Operational status","floor":"Floor","enabled":"Enabled","empty":"No data yet. Use the button at the top right to add an item.","edit":"Edit","add":"Add","unique":"Unique identifier","address":"Address","shortName":"College short name","schoolingYears":"Program duration in years","counselorAccount":"Counselor account","season":"Term season","autumn":"Autumn term","spring":"Spring term","summer":"Summer term","setCurrentTerm":"Set as current term","unarchiveFirst":"Unarchive the term first.","parentBuilding":"Teaching building","locatedFloor":"Floor","roomType":"Classroom type","teachingVenueNature":"Teaching venue nature","equipment":"Equipment","sort":"Sort order","templateFile":"{title}-import template.xlsx","exported":"{title} exported","importConfirm":"Preview passed: {created} new records, {updated} updates, {total} records in total. Import now?","imported":"Import complete: {created} added, {updated} updated","created":"{title} added","deleteConfirm":"Delete “{name}”? Data referenced by business records cannot be deleted.","switchConfirm":"Set “{name}” as the current term? Other terms will display as historical but will not be archived, and grades and makeup exams will remain editable.","switched":"Current term switched to “{name}”","addTitle":"Add {title}","editTitle":"Edit {title}","total":"{count} records","floorNumber":"Floor {floor}","listSeparator":", "},
|
||||
courses: {"generalRequired":"General education required","majorRequired":"Major required","majorElective":"Major elective","generalElective":"General education elective","practice":"Practical course","examination":"Examination","assessment":"Assessment","percentage":"Percentage","passFail":"Pass / Fail","letterGrade":"ABCDE letter grades","collegeFallback":"Assigned college","allScope":"University-wide courses · All course natures","templateFile":"Course catalog import template.xlsx","exportFile":"Course catalog.xlsx","confirmImport":"Confirm import","import":"Import","cancel":"Cancel","requiredFields":"Enter the course code, name, offering college, and category.","hoursInvalid":"Lecture hours plus practical hours cannot exceed total hours.","updated":"Course updated","created":"Course added to the catalog","deleteTitle":"Delete course","delete":"Delete","deleted":"Course deleted","title":"Course catalog","description":"General education courses are coordinated university-wide. Major and practical courses are maintained by the offering college and shared with curricula and teaching tasks.","export":"Export results","newCourse":"Add course","visible":"Currently visible","coursesUnit":"courses","scope":"Maintenance scope","collegeScopeHint":"General education courses can be viewed and referenced","schoolScopeHint":"Coordinates standards across colleges","searchPlaceholder":"Search course code, Chinese or English name","ownCollege":"Assigned offering college","allColleges":"All offering colleges","allCategories":"All course categories","allNatures":"All course natures","allArchives":"All archive statuses","unarchived":"Not archived","archived":"Archived","disabled":"Disabled","excelImport":"Import Excel","archiveMany":"Archive selected","restoreMany":"Restore selected","archiveStatus":"Archive status","code":"Course code","college":"Offering college","category":"Course category","uncategorized":"Uncategorized","nature":"Nature","creditHours":"Credits / Hours","hoursComposition":"Hour breakdown","assessmentLabel":"Assessment","evaluation":"Grading method","prerequisites":"Prerequisites","enabled":"Enabled","restore":"Restore","archive":"Archive","archiveHistory":"Archive history","schoolOnly":"University-level maintenance","empty":"No courses match the filters","edit":"Edit","add":"Add","uniqueCode":"Unique across the university","englishName":"English name","courseNature":"Course nature","twoDimensions":"Two dimensions","categoryHint":"Category identifies the teaching field; nature determines how the course is managed within curricula.","totalHours":"Total hours","assessmentMethod":"Assessment method","lectureHours":"Lecture hours","practiceHours":"Practical hours","gradeMethod":"Grading method","gpaHint":"For ABCDE grades, A–D pass and E fails. GPA points are A=4, B=3, C=2, D=1, E=0. Pass/fail courses are excluded from GPA.","selectPrerequisites":"Select courses that must be passed before taking this course","prerequisitesHint":"Student planning checks whether these courses have already been passed or scheduled in an earlier simulated term.","courseDescription":"Course description","sortOrder":"Sort order","save":"Save course","collegeScope":"{college} · Major and practical courses","importConfirm":"Preview passed: {created} new courses, {updated} updates, {total} courses in total. Import now?","imported":"Import complete: {created} added, {updated} updated, {total} courses processed.","deleteConfirm":"Delete course “{name}”? Courses referenced by curricula cannot be deleted.","exportHint":"Excel export uses the current filters · {total} courses","selectedCount":"{count} selected on this page","creditsAndHours":"{credits} credits · {hours} hours","hoursBreakdown":"Lecture {lecture} / Practical {practice}","total":"{count} courses","page":"Batch {page}","editTitle":"Edit course","addTitle":"Add course"},
|
||||
otherExams: {"exported":"All grades matching the current filters have been exported","saved":"Grades on this page saved. Attempt counts are calculated automatically.","published":"Grades published","created":"Exam batch created","templateFile":"Other exam grades-import template.xlsx","imported":"Grades imported. Existing records absent from the import file were retained.","passMetric":"Pass / Fail","levelMetric":"Level","scoreMetric":"Numeric score","pass":"Pass","fail":"Fail","kicker":"Exam grades","title":"Other exam grades","studentDescription":"View your certificates, proficiency tests, and external exams organized by exam, with your best results highlighted.","managerDescription":"Group exams by code and maintain grades by session. Student attempt counts are calculated automatically.","newSession":"New exam session","summary":"Grade summary","myBest":"My best results","comparisonHint":"Results with the same exam code are compared automatically","best":"Best result","emptyPublished":"No other exam grades have been published","historyKicker":"History","historyTitle":"Grade history","historyHint":"Every published result is retained","attemptNumber":"Attempt number","sessions":"Exam sessions","openHint":"Select a session to enter grades","batchSearch":"Exam code, name, or organizer","allMetrics":"All assessment methods","entered":"Entered","draft":"Draft","noOrganizer":"Organizer not specified","editorHint":"Grades load one page at a time. Saving and importing add or update records by student number; other existing records are retained. Leave the student number field to look up the name, college, and class. Attempt counts are calculated automatically.","lookupPending":"Awaiting lookup","automatic":"Automatic","emptyEditor":"No grade records yet. Add a row or import a spreadsheet.","createTitle":"Create other exam session","codeHint":"For example CET4 or IELTS. Always use the same code for the same exam.","nameHint":"For example College English Test Band 4","levelOrder":"Level order","levelOrderHint":"Enter levels from best to worst, for example A+,A,B,C,D","create":"Create session","publishTitle":"Publish other exam grades","publishHint":"Publishing makes this batch visible to students. You can edit and republish corrections.","exportFile":"{name}-Other exam grades.xlsx","studentNotFound":"Student number {number} was not found","publishFailed":"Publish failed: {error}","publicationCount":"Published {count} times","maxScoreSuffix":" · Maximum score {score}","grade":"Enrolled {year}","page":"Batch {page}","total":"{count} records","publishConfirm":"Publish grades for “{name}”?"},
|
||||
businessLabels: {"refresh":"Refresh","search":"Search","filter":"Filter","reset":"Reset","cancel":"Cancel","save":"Save","submit":"Submit","confirm":"Confirm","delete":"Delete","edit":"Edit","add":"Add","remove":"Remove","export":"Export","import":"Import","publish":"Publish","close":"Close","details":"Details","actions":"Actions","status":"Status","name":"Name","studentNumber":"Student number","studentName":"Student name","teacher":"Teacher","teacherName":"Teacher name","college":"College","major":"Major","class":"Class","administrativeClass":"Administrative class","grade":"Enrollment year","term":"Term","course":"Course","courseName":"Course name","courseCode":"Course code","courseType":"Course type","credits":"Credits","hours":"Hours","score":"Score","notes":"Notes","description":"Description","reason":"Reason","phone":"Phone","email":"Email","date":"Date","startDate":"Start date","endDate":"End date","startTime":"Start time","endTime":"End time","allStatus":"All statuses","allColleges":"All colleges","allMajors":"All majors","allClasses":"All administrative classes","allGrades":"All enrollment years","allTerms":"All terms","allCourses":"All courses","allTypes":"All types","keyword":"Keyword","studentSearch":"Student number or name","previous":"Previous batch","next":"Next batch","draft":"Draft","published":"Published","pending":"Pending review","approved":"Approved","rejected":"Rejected","approve":"Approve","reject":"Reject","review":"Review","reviewComment":"Review comment","reviewTime":"Review time","createdAt":"Created at","publishedAt":"Published at","enabled":"Enable","disabled":"Disable","yes":"Yes","no":"No","optional":"Optional","required":"Required","downloadTemplate":"Download template","importTemplate":"Download import template","batchImport":"Bulk import","exportFiltered":"Export filtered results","exportAll":"Export all","saveChanges":"Save changes","saveRecords":"Save records","noData":"No data","classroom":"Classroom","classroomName":"Classroom name","building":"Teaching building","capacity":"Capacity","exam":"Exam","examName":"Exam name","examCode":"Exam code","examDate":"Exam date","examResult":"Exam result","result":"Result","level":"Level","pass":"Pass","fail":"Fail","passFail":"Pass / Fail","scoreMetric":"Numeric score","levelMetric":"Level","passMetric":"Pass / Fail","organizer":"Organizer","maxScore":"Maximum score","metric":"Assessment method","attempts":"Attempts","newRow":"Add row","confirmPublish":"Confirm publish","username":"Username","password":"Password","role":"Role","gender":"Gender","department":"Department","title":"Professional title","employeeNumber":"Employee number","enrollmentYear":"Enrollment year","batchName":"Batch name","recalculate":"Recalculate","manualReview":"Manual review","reviewConclusion":"Review conclusion","reviewNotes":"Review comment","allConclusions":"All conclusions","deleteBatch":"Delete batch","publishResults":"Publish results","attendance":"Attendance","present":"Present","absent":"Absent","late":"Late","leave":"Leave","week":"Week","location":"Location","count":"People","total":"Total","type":"Type","number":"Number","enabledStatus":"Enabled","disabledStatus":"Disabled","selectCourse":"Select a course","selectTerm":"Select a term","selectCollege":"Select a college","selectMajor":"Select a major","selectClass":"Select a class","selectTeacher":"Select a teacher","selectResult":"Select a result","selectLevel":"Select a level","inputStudentNumber":"Enter student number","inputScore":"Enter score"},
|
||||
locale: {
|
||||
label: 'Language',
|
||||
|
||||
Loaded 3 of 27 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user