feat: localize statistics and personnel records
This commit is contained in:
1 parent
986de2fc40
commit
1a1ecfb912
6 files changed
+180
-147
No files matched your search
@@ -24,15 +24,15 @@ const hardcoded = completedViews.filter((name) => {
|
||||
if (name === 'BaseDataView.vue') source = source.replace("degreeType: '学士'", '').replace("roomType: '普通教室'", '')
|
||||
return /\p{Script=Han}/u.test(source)
|
||||
})
|
||||
// Teaching monitoring still recognizes Chinese reason strings from the API;
|
||||
// its template itself should contain only translated interface copy.
|
||||
const monitoringSource = readFileSync(new URL('../src/views/TeachingMonitoringView.vue', import.meta.url), 'utf8')
|
||||
if (/\p{Script=Han}/u.test(monitoringSource.split('<template>')[1]?.split('</template>\n\n<style')[0] ?? '')) {
|
||||
hardcoded.push('TeachingMonitoringView.vue')
|
||||
}
|
||||
const planningSource = readFileSync(new URL('../src/views/AcademicPlanningView.vue', import.meta.url), 'utf8')
|
||||
if (/\p{Script=Han}/u.test(planningSource.split('<template>')[1]?.split('</template>\n\n<style')[0] ?? '')) {
|
||||
hardcoded.push('AcademicPlanningView.vue')
|
||||
// These pages retain Chinese API values or editable business defaults in script.
|
||||
// Guard their templates separately, ignoring non-rendered comments.
|
||||
for (const name of ['TeachingMonitoringView.vue', 'AcademicPlanningView.vue', 'PersonnelView.vue', 'StatisticsView.vue']) {
|
||||
const source = readFileSync(new URL(`../src/views/${name}`, import.meta.url), 'utf8')
|
||||
const start = source.indexOf('<template>')
|
||||
const end = source.lastIndexOf('</template>')
|
||||
if (start < 0 || end < start) throw new Error(`Missing template in ${name}`)
|
||||
const template = source.slice(start, end).replace(/<!--[\s\S]*?-->/g, '')
|
||||
if (/\p{Script=Han}/u.test(template)) hardcoded.push(name)
|
||||
}
|
||||
const viewsDirectory = new URL('../src/views/', import.meta.url)
|
||||
const fixedLocaleViews = readdirSync(viewsDirectory).filter((name) => name.endsWith('.vue') &&
|
||||
|
||||
Reference in new issue
Block a user