From ea51c16d2947df44827f0e38a25d00bc4e0e9403 Mon Sep 17 00:00:00 2001 From: biss Date: Fri, 30 Oct 2026 21:35:24 +0800 Subject: [PATCH] feat: localize dashboard experiences --- .../Controllers/DashboardController.cs | 115 ++++++++++-------- .../Localization/SharedResource.en-US.resx | 73 +++++++++++ .../Localization/SharedResource.resx | 73 +++++++++++ tests/Jiaowu.Api.Tests/AppCulturesTests.cs | 14 +++ .../DashboardControllerTests.cs | 32 ++++- .../components/AcademicCalendarReminder.vue | 11 +- web/src/i18n/messages/en-US.ts | 18 +++ web/src/i18n/messages/zh-CN.ts | 18 +++ web/src/views/AcademicOverviewView.vue | 56 +++++---- web/src/views/TeacherDashboardView.vue | 20 +-- 10 files changed, 337 insertions(+), 93 deletions(-) diff --git a/src/Jiaowu.Api/Controllers/DashboardController.cs b/src/Jiaowu.Api/Controllers/DashboardController.cs index 01b4c3d..017f46c 100644 --- a/src/Jiaowu.Api/Controllers/DashboardController.cs +++ b/src/Jiaowu.Api/Controllers/DashboardController.cs @@ -1,10 +1,12 @@ using Jiaowu.Api.Domain.Academic; using Jiaowu.Api.Domain.Identity; using Jiaowu.Api.Infrastructure.Auth; +using Jiaowu.Api.Infrastructure.Localization; using Jiaowu.Api.Infrastructure.Persistence; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Localization; namespace Jiaowu.Api.Controllers; @@ -13,8 +15,11 @@ namespace Jiaowu.Api.Controllers; [Route("api/dashboard")] public sealed class DashboardController( AppDbContext db, - ICurrentUserDataScope currentUserDataScope) : ControllerBase + ICurrentUserDataScope currentUserDataScope, + IStringLocalizer localizer) : ControllerBase { + private string L(string key, params object[] arguments) => localizer[key, arguments].Value; + [HttpGet] public async Task> Get( CancellationToken cancellationToken) @@ -163,8 +168,10 @@ public sealed class DashboardController( DashboardPending? pending, CancellationToken cancellationToken) { - var name = string.IsNullOrWhiteSpace(scope.DisplayName) ? "" : $"{scope.DisplayName},"; var greeting = GetTimeGreeting(); + var greetingTitle = string.IsNullOrWhiteSpace(scope.DisplayName) + ? greeting + : L("Dashboard.Greeting.Title", scope.DisplayName, greeting); var isManager = scope.IsInRole(SystemRoles.SuperAdmin) || scope.IsInRole(SystemRoles.AcademicAdmin) || scope.IsInRole(SystemRoles.CollegeAdmin) || @@ -178,7 +185,7 @@ public sealed class DashboardController( .Select(x => (Guid?)x.Id) .FirstOrDefaultAsync(cancellationToken); if (!studentId.HasValue) - return new DashboardGreeting("Student", $"{name}{greeting}", "绑定学籍后,将为你生成课程与成绩学习概览。", "学习节奏", "关联学生档案后,可从课程安排、成绩和考试中生成学习状态摘要。", []); + return new DashboardGreeting("Student", greetingTitle, L("Dashboard.Student.Unbound.Subtitle"), L("Dashboard.Student.Label"), L("Dashboard.Student.Unbound.Narrative"), []); var student = await db.Students.AsNoTracking() .Where(x => x.Id == studentId.Value) @@ -226,22 +233,22 @@ public sealed class DashboardController( cancellationToken); var subtitle = failed > 0 - ? $"已发布成绩中有 {failed} 门课程需要重点关注,建议优先查看课程反馈。" + ? L("Dashboard.Student.Subtitle.Failed", failed) : courseCount > 0 - ? $"本学期已有 {courseCount} 门课程、{courseCredits:0.#} 学分进入你的学习安排。" - : "本学期暂未发现为你安排或确认选课的课程,可先查看培养方案和选课安排。"; + ? L("Dashboard.Student.Subtitle.Active", courseCount, courseCredits) + : L("Dashboard.Student.Subtitle.Empty"); var narrative = courseCount == 0 - ? "你的当前学习安排尚未形成:系统还没有找到行政班已安排课程或已确认选课。" + ? L("Dashboard.Student.Narrative.Empty") : failed > 0 - ? $"本学期已形成 {courseCount} 门课程安排,其中 {classAssignedCount} 个教学班来自行政班安排;已发布成绩中有 {failed} 门需要重点关注。" + ? L("Dashboard.Student.Narrative.Failed", courseCount, classAssignedCount, failed) : gradeCount > 0 - ? $"本学期有 {courseCount} 门课程进入学习安排,已发布 {gradeCount} 门成绩,当前没有不及格记录。" - : $"本学期有 {courseCount} 门课程进入学习安排,包含 {classAssignedCount} 个行政班教学班和 {selfSelectedCount} 个自主选课教学班,成绩发布后会在这里更新。"; - return new DashboardGreeting("Student", $"{name}{greeting}", subtitle, "学习节奏", narrative, + ? L("Dashboard.Student.Narrative.Published", courseCount, gradeCount) + : L("Dashboard.Student.Narrative.Pending", courseCount, classAssignedCount, selfSelectedCount); + return new DashboardGreeting("Student", greetingTitle, subtitle, L("Dashboard.Student.Label"), narrative, [ - new DashboardGreetingInsight("本学期课程", $"{courseCount} 门", $"共 {courseCredits:0.#} 学分", "calm"), - new DashboardGreetingInsight("已发布成绩", $"{gradeCount} 门", average.HasValue ? $"平均分 {average.Value:0.0}" : "等待成绩发布", "calm"), - new DashboardGreetingInsight("重点关注", $"{failed} 门", failed > 0 ? "建议尽早安排复习与答疑" : "当前无不及格记录", failed > 0 ? "attention" : "positive") + new DashboardGreetingInsight(L("Dashboard.Student.Insight.Courses"), L("Dashboard.Unit.Courses", courseCount), L("Dashboard.Unit.Credits", courseCredits), "calm"), + new DashboardGreetingInsight(L("Dashboard.Student.Insight.Published"), L("Dashboard.Unit.Courses", gradeCount), average.HasValue ? L("Dashboard.Student.Average", average.Value) : L("Dashboard.Student.AwaitingGrades"), "calm"), + new DashboardGreetingInsight(L("Dashboard.Student.Insight.Attention"), L("Dashboard.Unit.Courses", failed), failed > 0 ? L("Dashboard.Student.Attention.Required") : L("Dashboard.Student.Attention.None"), failed > 0 ? "attention" : "positive") ]); } @@ -252,7 +259,7 @@ public sealed class DashboardController( .Select(x => (Guid?)x.Id) .FirstOrDefaultAsync(cancellationToken); if (!teacherId.HasValue) - return new DashboardGreeting("Teacher", $"{name}{greeting}", "绑定教师档案后,将为你生成本学期教学负荷概览。", "教学节奏", "关联教师档案后,可从教学班、授课学时和成绩进度生成今日工作摘要。", []); + return new DashboardGreeting("Teacher", greetingTitle, L("Dashboard.Teacher.Unbound.Subtitle"), L("Dashboard.Teacher.Label"), L("Dashboard.Teacher.Unbound.Narrative"), []); var tasks = db.TeachingTasks.AsNoTracking().Where(x => currentTermId.HasValue && x.AcademicTermId == currentTermId.Value && @@ -268,18 +275,18 @@ public sealed class DashboardController( x.Status == GradeSheetStatus.Returned, cancellationToken); var submittedGrades = await gradeSheets.CountAsync(x => x.Status == GradeSheetStatus.Submitted, cancellationToken); var subtitle = pendingGrades > 0 - ? $"有 {pendingGrades} 张成绩登记册尚待提交,完成后可进入审核流程。" + ? L("Dashboard.Teacher.Subtitle.Pending", pendingGrades) : teachingClasses > 0 - ? $"本学期承担 {teachingClasses} 个教学班,预计授课 {estimatedHours} 学时。" - : "本学期暂未分配教学班,请留意教学任务安排。"; + ? L("Dashboard.Teacher.Subtitle.Active", teachingClasses, estimatedHours) + : L("Dashboard.Teacher.Subtitle.Empty"); var narrative = pendingGrades > 0 - ? $"你本学期承担 {teachingClasses} 个教学班,预计授课 {estimatedHours} 学时;有 {pendingGrades} 张成绩登记册等待提交。" - : $"你本学期承担 {teachingClasses} 个教学班,预计授课 {estimatedHours} 学时,目前没有待提交的成绩登记册。"; - return new DashboardGreeting("Teacher", $"{name}{greeting}", subtitle, "教学节奏", narrative, + ? L("Dashboard.Teacher.Narrative.Pending", teachingClasses, estimatedHours, pendingGrades) + : L("Dashboard.Teacher.Narrative.Clear", teachingClasses, estimatedHours); + return new DashboardGreeting("Teacher", greetingTitle, subtitle, L("Dashboard.Teacher.Label"), narrative, [ - new DashboardGreetingInsight("教学班", $"{teachingClasses} 个", $"预计 {estimatedHours} 学时", "calm"), - new DashboardGreetingInsight("待提交成绩", $"{pendingGrades} 张", pendingGrades > 0 ? "请在截止日前完成登记" : "当前无需提交", pendingGrades > 0 ? "attention" : "positive"), - new DashboardGreetingInsight("审核中成绩", $"{submittedGrades} 张", submittedGrades > 0 ? "等待审核结果" : "暂无审核中登记册", "calm") + new DashboardGreetingInsight(L("Dashboard.Teacher.Insight.Classes"), L("Dashboard.Unit.Classes", teachingClasses), L("Dashboard.Unit.Hours", estimatedHours), "calm"), + new DashboardGreetingInsight(L("Dashboard.Teacher.Insight.Pending"), L("Dashboard.Unit.Sheets", pendingGrades), pendingGrades > 0 ? L("Dashboard.Teacher.Pending.Required") : L("Dashboard.Teacher.Pending.None"), pendingGrades > 0 ? "attention" : "positive"), + new DashboardGreetingInsight(L("Dashboard.Teacher.Insight.Review"), L("Dashboard.Unit.Sheets", submittedGrades), submittedGrades > 0 ? L("Dashboard.Teacher.Review.Pending") : L("Dashboard.Teacher.Review.None"), "calm") ]); } @@ -289,25 +296,25 @@ public sealed class DashboardController( var taskCount = counts?.TeachingTasks ?? 0; var scheduledCount = counts?.ScheduledTeachingTasks ?? 0; var subtitleForManager = actionable > 0 - ? $"当前有 {actionable} 项待办需要跟进,优先处理时效性审核事项。" + ? L("Dashboard.Manager.Subtitle.Pending", actionable) : taskCount > 0 - ? $"本学期 {taskCount} 个教学班正在运行,当前没有积压待办。" - : "当前学期运行数据已就绪,可从教学任务开始推进。"; + ? L("Dashboard.Manager.Subtitle.Active", taskCount) + : L("Dashboard.Manager.Subtitle.Empty"); var managerNarrative = actionable > 0 - ? $"当前教学运行覆盖 {taskCount} 个教学班,其中 {scheduledCount} 个已进入课表;{actionable} 项待办正等待处理。" - : $"当前教学运行覆盖 {taskCount} 个教学班,其中 {scheduledCount} 个已进入课表,暂未发现需要你处理的积压事项。"; - return new DashboardGreeting("Manager", $"{name}{greeting}", subtitleForManager, "运行态势", managerNarrative, + ? L("Dashboard.Manager.Narrative.Pending", taskCount, scheduledCount, actionable) + : L("Dashboard.Manager.Narrative.Clear", taskCount, scheduledCount); + return new DashboardGreeting("Manager", greetingTitle, subtitleForManager, L("Dashboard.Manager.Label"), managerNarrative, [ - new DashboardGreetingInsight("当前待办", $"{actionable} 项", actionable > 0 ? "优先处理可操作事项" : "暂无积压", actionable > 0 ? "attention" : "positive"), - new DashboardGreetingInsight("本学期教学班", $"{taskCount} 个", "教学运行规模", "calm"), - new DashboardGreetingInsight("已进入课表", $"{scheduledCount} 个", taskCount > 0 ? $"覆盖 {Math.Round(scheduledCount * 100d / taskCount)}% 教学班" : "等待教学任务发布", "calm") + new DashboardGreetingInsight(L("Dashboard.Manager.Insight.Pending"), L("Dashboard.Unit.Items", actionable), actionable > 0 ? L("Dashboard.Manager.Pending.Required") : L("Dashboard.Manager.Pending.None"), actionable > 0 ? "attention" : "positive"), + new DashboardGreetingInsight(L("Dashboard.Manager.Insight.Classes"), L("Dashboard.Unit.Classes", taskCount), L("Dashboard.Manager.Scale"), "calm"), + new DashboardGreetingInsight(L("Dashboard.Manager.Insight.Scheduled"), L("Dashboard.Unit.Classes", scheduledCount), taskCount > 0 ? L("Dashboard.Manager.Coverage", Math.Round(scheduledCount * 100d / taskCount)) : L("Dashboard.Manager.AwaitingTasks"), "calm") ]); } - private static string GetTimeGreeting() + private string GetTimeGreeting() { var hour = DateTime.UtcNow.AddHours(8).Hour; - return hour < 11 ? "早上好" : hour < 14 ? "中午好" : hour < 18 ? "下午好" : "晚上好"; + return hour < 11 ? L("Dashboard.Greeting.Morning") : hour < 14 ? L("Dashboard.Greeting.Noon") : hour < 18 ? L("Dashboard.Greeting.Afternoon") : L("Dashboard.Greeting.Evening"); } private async Task LoadPendingAsync( @@ -401,45 +408,45 @@ public sealed class DashboardController( generalApprovals); } - private static DashboardAudience BuildAudience( + private DashboardAudience BuildAudience( CurrentUserScope scope, string? collegeName) { if (scope.IsInRole(SystemRoles.SuperAdmin)) return new DashboardAudience( "System", - "全域教务工作台", - "全校", - "统筹基础数据、教学运行与系统治理"); + L("Dashboard.Audience.System.Title"), + L("Dashboard.Audience.AllSchool"), + L("Dashboard.Audience.System.Description")); if (scope.IsInRole(SystemRoles.AcademicAdmin)) return new DashboardAudience( "School", - "校级教务工作台", - "全校", - "聚焦跨学院教学运行与校级审核"); + L("Dashboard.Audience.School.Title"), + L("Dashboard.Audience.AllSchool"), + L("Dashboard.Audience.School.Description")); if (scope.IsInRole(SystemRoles.CollegeAdmin)) return new DashboardAudience( "College", - "学院教务工作台", - collegeName ?? "本学院", - "聚焦本学院教学准备、过程审核与成绩归档"); + L("Dashboard.Audience.College.Title"), + collegeName ?? L("Dashboard.Audience.ThisCollege"), + L("Dashboard.Audience.College.Description")); if (scope.IsInRole(SystemRoles.Leader)) return new DashboardAudience( "Leadership", - "教学运行观察台", - "全校", - "查看全校教学运行与质量数据"); + L("Dashboard.Audience.Leadership.Title"), + L("Dashboard.Audience.AllSchool"), + L("Dashboard.Audience.Leadership.Description")); if (scope.IsInRole(SystemRoles.Counselor)) return new DashboardAudience( "Counselor", - "班级工作台", - collegeName ?? "所辖班级", - "处理学生过程管理与学业支持"); + L("Dashboard.Audience.Counselor.Title"), + collegeName ?? L("Dashboard.Audience.ManagedClasses"), + L("Dashboard.Audience.Counselor.Description")); return new DashboardAudience( "Teaching", - "教学工作台", - collegeName ?? "个人教学", - "查看课程运行并进入日常教学工作"); + L("Dashboard.Audience.Teaching.Title"), + collegeName ?? L("Dashboard.Audience.PersonalTeaching"), + L("Dashboard.Audience.Teaching.Description")); } } diff --git a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx index 0f84696..d85c841 100644 --- a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx +++ b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.en-US.resx @@ -8,4 +8,77 @@ The code may already exist, or other business data may reference this record. The server encountered an error Try again later and contact the system administrator if the problem continues. + {1}, {0} + Good morning + Good afternoon + Good afternoon + Good evening + {0} courses + {0:0.#} credits total + {0} classes + {0} estimated hours + {0} sheets + {0} items + Study progress + Link your student record to generate a course and grade overview. + After linking your student record, course schedules, grades, and exams will form a learning-status summary. + {0} published courses need attention. Review the course feedback first. + {0} courses totaling {1:0.#} credits are in your plan this term. + No assigned or confirmed courses were found this term. Check your curriculum and course-selection schedule. + Your current study plan has not formed yet: no class-assigned or confirmed selected courses were found. + You have {0} courses this term, including {1} classes assigned through your administrative class; {2} published courses need attention. + You have {0} courses this term and {1} published grades, with no failing records. + You have {0} courses this term, including {1} class-assigned and {2} self-selected classes. This summary will update when grades are published. + Courses this term + Published grades + Needs attention + Average {0:0.0} + Waiting for published grades + Plan review and support early + No failing records + Teaching progress + Link your teacher record to generate this term's workload overview. + After linking your teacher record, classes, teaching hours, and grade progress will form a daily work summary. + {0} grade sheets are waiting for submission before review. + You are teaching {0} classes this term, with an estimated {1} hours. + No classes are assigned this term. Watch for teaching-task updates. + You are teaching {0} classes for an estimated {1} hours this term; {2} grade sheets are waiting for submission. + You are teaching {0} classes for an estimated {1} hours this term, with no grade sheets waiting for submission. + Teaching classes + Grades to submit + Grades under review + Complete them before the deadline + No submission needed + Waiting for review + No grade sheets under review + Operational status + {0} items need attention. Prioritize time-sensitive reviews. + {0} classes are running this term, with no outstanding work. + The current term is ready. Start with teaching tasks. + Operations cover {0} classes, {1} of which are scheduled; {2} items are waiting for action. + Operations cover {0} classes, {1} of which are scheduled, with no outstanding items requiring your attention. + Pending work + Classes this term + On the timetable + Prioritize actionable items + No backlog + Teaching-operation scale + {0}% of classes covered + Waiting for published teaching tasks + School-wide + This college + Assigned classes + My teaching + Institution academic workspace + Coordinate reference data, teaching operations, and system governance + School academic workspace + Focus on cross-college teaching operations and school-level reviews + College academic workspace + Focus on teaching preparation, process reviews, and grade archiving in this college + Teaching operations overview + View school-wide teaching operations and quality data + Class support workspace + Support student processes and academic progress + Teaching workspace + Review course operations and enter daily teaching work diff --git a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx index caa1c76..366d394 100644 --- a/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx +++ b/src/Jiaowu.Api/Resources/Infrastructure/Localization/SharedResource.resx @@ -8,4 +8,77 @@ 编码可能已存在,或该数据正在被其他业务引用。 服务器处理请求时发生错误 请稍后重试,并联系系统管理员查看日志。 + {0},{1} + 早上好 + 中午好 + 下午好 + 晚上好 + {0} 门 + 共 {0:0.#} 学分 + {0} 个 + 预计 {0} 学时 + {0} 张 + {0} 项 + 学习节奏 + 绑定学籍后,将为你生成课程与成绩学习概览。 + 关联学生档案后,可从课程安排、成绩和考试中生成学习状态摘要。 + 已发布成绩中有 {0} 门课程需要重点关注,建议优先查看课程反馈。 + 本学期已有 {0} 门课程、{1:0.#} 学分进入你的学习安排。 + 本学期暂未发现为你安排或确认选课的课程,可先查看培养方案和选课安排。 + 你的当前学习安排尚未形成:系统还没有找到行政班已安排课程或已确认选课。 + 本学期已形成 {0} 门课程安排,其中 {1} 个教学班来自行政班安排;已发布成绩中有 {2} 门需要重点关注。 + 本学期有 {0} 门课程进入学习安排,已发布 {1} 门成绩,当前没有不及格记录。 + 本学期有 {0} 门课程进入学习安排,包含 {1} 个行政班教学班和 {2} 个自主选课教学班,成绩发布后会在这里更新。 + 本学期课程 + 已发布成绩 + 重点关注 + 平均分 {0:0.0} + 等待成绩发布 + 建议尽早安排复习与答疑 + 当前无不及格记录 + 教学节奏 + 绑定教师档案后,将为你生成本学期教学负荷概览。 + 关联教师档案后,可从教学班、授课学时和成绩进度生成今日工作摘要。 + 有 {0} 张成绩登记册尚待提交,完成后可进入审核流程。 + 本学期承担 {0} 个教学班,预计授课 {1} 学时。 + 本学期暂未分配教学班,请留意教学任务安排。 + 你本学期承担 {0} 个教学班,预计授课 {1} 学时;有 {2} 张成绩登记册等待提交。 + 你本学期承担 {0} 个教学班,预计授课 {1} 学时,目前没有待提交的成绩登记册。 + 教学班 + 待提交成绩 + 审核中成绩 + 请在截止日前完成登记 + 当前无需提交 + 等待审核结果 + 暂无审核中登记册 + 运行态势 + 当前有 {0} 项待办需要跟进,优先处理时效性审核事项。 + 本学期 {0} 个教学班正在运行,当前没有积压待办。 + 当前学期运行数据已就绪,可从教学任务开始推进。 + 当前教学运行覆盖 {0} 个教学班,其中 {1} 个已进入课表;{2} 项待办正等待处理。 + 当前教学运行覆盖 {0} 个教学班,其中 {1} 个已进入课表,暂未发现需要你处理的积压事项。 + 当前待办 + 本学期教学班 + 已进入课表 + 优先处理可操作事项 + 暂无积压 + 教学运行规模 + 覆盖 {0}% 教学班 + 等待教学任务发布 + 全校 + 本学院 + 所辖班级 + 个人教学 + 全域教务工作台 + 统筹基础数据、教学运行与系统治理 + 校级教务工作台 + 聚焦跨学院教学运行与校级审核 + 学院教务工作台 + 聚焦本学院教学准备、过程审核与成绩归档 + 教学运行观察台 + 查看全校教学运行与质量数据 + 班级工作台 + 处理学生过程管理与学业支持 + 教学工作台 + 查看课程运行并进入日常教学工作 diff --git a/tests/Jiaowu.Api.Tests/AppCulturesTests.cs b/tests/Jiaowu.Api.Tests/AppCulturesTests.cs index 62ce861..670293c 100644 --- a/tests/Jiaowu.Api.Tests/AppCulturesTests.cs +++ b/tests/Jiaowu.Api.Tests/AppCulturesTests.cs @@ -31,4 +31,18 @@ public sealed class AppCulturesTests Assert.Equal("The server encountered an error", title); } + + [Fact] + public void SharedResource_ContainsEnglishDashboardMessages() + { + var resources = new ResourceManager( + "Jiaowu.Api.Resources.Infrastructure.Localization.SharedResource", + typeof(SharedResource).Assembly); + + var message = resources.GetString( + "Dashboard.Teacher.Subtitle.Active", + CultureInfo.GetCultureInfo(AppCultures.English)); + + Assert.Equal("You are teaching {0} classes this term, with an estimated {1} hours.", message); + } } diff --git a/tests/Jiaowu.Api.Tests/DashboardControllerTests.cs b/tests/Jiaowu.Api.Tests/DashboardControllerTests.cs index 206ec9b..c1f1b27 100644 --- a/tests/Jiaowu.Api.Tests/DashboardControllerTests.cs +++ b/tests/Jiaowu.Api.Tests/DashboardControllerTests.cs @@ -2,10 +2,14 @@ using Jiaowu.Api.Controllers; using Jiaowu.Api.Domain.Academic; using Jiaowu.Api.Domain.Identity; using Jiaowu.Api.Infrastructure.Auth; +using Jiaowu.Api.Infrastructure.Localization; using Jiaowu.Api.Infrastructure.Persistence; using Microsoft.AspNetCore.Mvc; using Microsoft.Data.Sqlite; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Localization; +using System.Globalization; +using System.Resources; namespace Jiaowu.Api.Tests; @@ -20,7 +24,8 @@ public sealed class DashboardControllerTests new TestDataScope( database.FirstCollegeId, DataScope.College, - SystemRoles.CollegeAdmin)); + SystemRoles.CollegeAdmin), + new TestStringLocalizer()); var result = await controller.Get(CancellationToken.None); @@ -44,7 +49,8 @@ public sealed class DashboardControllerTests new TestDataScope( null, DataScope.All, - SystemRoles.AcademicAdmin)); + SystemRoles.AcademicAdmin), + new TestStringLocalizer()); var result = await controller.Get(CancellationToken.None); @@ -258,4 +264,26 @@ public sealed class DashboardControllerTests dataScope, new HashSet { role }); } + + private sealed class TestStringLocalizer : IStringLocalizer + { + private static readonly ResourceManager Resources = new( + "Jiaowu.Api.Resources.Infrastructure.Localization.SharedResource", + typeof(SharedResource).Assembly); + + public LocalizedString this[string name] => Create(name, []); + + public LocalizedString this[string name, params object[] arguments] => Create(name, arguments); + + public IEnumerable GetAllStrings(bool includeParentCultures) => []; + + private static LocalizedString Create(string name, object[] arguments) + { + var template = Resources.GetString(name, CultureInfo.CurrentUICulture) ?? name; + var value = arguments.Length == 0 + ? template + : string.Format(CultureInfo.CurrentCulture, template, arguments); + return new LocalizedString(name, value, resourceNotFound: template == name); + } + } } diff --git a/web/src/components/AcademicCalendarReminder.vue b/web/src/components/AcademicCalendarReminder.vue index c4f2d4d..676b1a6 100644 --- a/web/src/components/AcademicCalendarReminder.vue +++ b/web/src/components/AcademicCalendarReminder.vue @@ -1,23 +1,28 @@ diff --git a/web/src/i18n/messages/en-US.ts b/web/src/i18n/messages/en-US.ts index 22a87cd..d3a85e8 100644 --- a/web/src/i18n/messages/en-US.ts +++ b/web/src/i18n/messages/en-US.ts @@ -34,6 +34,24 @@ export default { readyTitle: 'Version {version} is ready', releaseNotes: '{notes} Select this notification to apply it now.', readyMessage: 'The update will be applied when the app moves to the background or starts next time. Select this notification to apply it now.', applyMessage: 'The app will reload to apply the downloaded version. Save any unsaved work first.', applyTitle: 'Apply update', applyNow: 'Apply now', }, launch: { skip: 'Tap to skip' }, + common: { reload: 'Reload', refresh: 'Refresh', listSeparator: ', ' }, + dashboard: { + calendar: { label: 'Schedule reminder', title: 'Upcoming key dates', today: 'Today', inDays: 'In {days} days', viewAll: 'View calendar' }, + teacher: { + loadFailed: 'Teaching dashboard could not load', loadFailedHint: 'Check the service connection and reload.', workspace: 'Teaching workspace', + gradeProgress: 'Grade entry progress', gradeManagement: 'Grade management', noPendingGrades: 'No grades are waiting for submission', noPendingGradesHint: 'Grade sheets will appear here in priority order.', + termClasses: 'Classes this term', teachingTasks: 'Teaching tasks', classProgress: '{students} students · {completed} completed', noGradeSheet: 'No grade sheet has been created', noClasses: 'No classes assigned this term', noClassesHint: 'Published teaching tasks will be summarized here automatically.', + status: { Draft: 'Not entered', Returned: 'Returned', Submitted: 'Under review', Approved: 'Approved', Published: 'Published' }, + }, + }, + academicOverview: { + title: 'Academic performance overview', description: 'Summarizes GPA, credit-weighted average, and average score for all officially published courses, with rankings in your class, major, and college.', + refreshing: 'New grades have been published. Statistics will update on the administrator-defined schedule; select Refresh when processing is complete.', note: 'This page covers all terms. View Academic Grades for the current term. Rankings include only students with a valid value for the metric, and ties share the same rank.', + courseCount: '{count} courses included', publishedOnly: 'Only published grade sheets are included; incomplete or unpublished grades do not affect these statistics.', empty: 'No published grades are available for analysis', rankPending: 'Ranking not available yet ({count} students)', scoreAxis: 'Score', + columns: { metric: 'Metric', score: 'My result', classRank: 'Class rank', majorRank: 'Major rank', collegeRank: 'College rank' }, + metric: { gpaHint: 'Weighted by course credits', weighted: 'Credit-weighted average', weightedHint: 'Final course scores weighted by credits', average: 'Average score', averageHint: 'Arithmetic mean of published final scores' }, + trendTitle: 'Academic performance by term', trendHint: 'GPA uses the left axis (0–4); scores use the right axis (0–100).', trendEmpty: 'No published grades are available for a trend chart', + }, api: { 'data.constraint_conflict': 'A data constraint conflict occurred.', 'server.unhandled_error': 'The server encountered an error while processing the request.', diff --git a/web/src/i18n/messages/zh-CN.ts b/web/src/i18n/messages/zh-CN.ts index 7242d63..5ebb552 100644 --- a/web/src/i18n/messages/zh-CN.ts +++ b/web/src/i18n/messages/zh-CN.ts @@ -34,6 +34,24 @@ export default { readyTitle: '新版本 {version} 已就绪', releaseNotes: '{notes} 点击此提示可立即启用。', readyMessage: '切换到后台或下次启动应用时将自动启用更新;点击此提示可立即启用。', applyMessage: '将重新加载应用以启用已下载的新版本。未保存的内容请先提交。', applyTitle: '启用更新', applyNow: '立即启用', }, launch: { skip: '轻触跳过' }, + common: { reload: '重新加载', refresh: '刷新', listSeparator: '、' }, + dashboard: { + calendar: { label: '日程提醒', title: '近期关键日程', today: '今天', inDays: '{days} 天后', viewAll: '查看校历' }, + teacher: { + loadFailed: '教学驾驶舱加载失败', loadFailedHint: '请检查服务连接后重新加载。', workspace: '教学工作台', + gradeProgress: '成绩登记进度', gradeManagement: '成绩管理', noPendingGrades: '当前没有待提交成绩', noPendingGradesHint: '成绩登记册会在这里按优先级显示。', + termClasses: '本学期教学班', teachingTasks: '教学任务', classProgress: '{students} 人 · 已完成 {completed} 人', noGradeSheet: '尚未建立成绩登记册', noClasses: '本学期暂未分配教学班', noClassesHint: '教学任务发布后会自动汇总到这里。', + status: { Draft: '待登记', Returned: '已退回', Submitted: '审核中', Approved: '已审核', Published: '已发布' }, + }, + }, + academicOverview: { + title: '学业成绩总览', description: '汇总所有已正式发布课程的 GPA、加权平均成绩与平均成绩,并显示当前行政班、专业和学院的排名。', + refreshing: '成绩已发布,学业统计将在管理员设置的定时刷新后更新;完成后点击“刷新”即可查看。', note: '本页面按全部学期统计;“本学期成绩”请在学业成绩中查询。排名仅比较至少具备该项有效成绩的学生,并列学生使用相同名次。', + courseCount: '已纳入统计 {count} 门课程', publishedOnly: '仅纳入已发布成绩单;未完成或未发布成绩不会影响统计。', empty: '暂无可统计的已发布成绩', rankPending: '暂未形成排名({count} 人)', scoreAxis: '成绩', + columns: { metric: '统计指标', score: '我的成绩', classRank: '班级排名', majorRank: '专业排名', collegeRank: '学院排名' }, + metric: { gpaHint: '绩点按课程学分加权', weighted: '加权平均成绩', weightedHint: '课程总评按课程学分加权', average: '平均成绩', averageHint: '已发布课程总评的算术平均' }, + trendTitle: '各学期学业成绩变化', trendHint: 'GPA 使用左轴(0–4),两项成绩使用右轴(0–100)。', trendEmpty: '暂无可绘制趋势的已发布成绩', + }, api: { 'data.constraint_conflict': '数据约束冲突。', 'server.unhandled_error': '服务器处理请求时发生错误。', diff --git a/web/src/views/AcademicOverviewView.vue b/web/src/views/AcademicOverviewView.vue index d5ca9a5..3b15415 100644 --- a/web/src/views/AcademicOverviewView.vue +++ b/web/src/views/AcademicOverviewView.vue @@ -1,5 +1,6 @@