feat: localize page scripts and grade analytics labels
This commit is contained in:
1 parent
440e05a99e
commit
2bf4dc1d26
11 files changed
+256
-178
No files matched your search
@@ -11,6 +11,7 @@ using Jiaowu.Api.Infrastructure.Persistence;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Jiaowu.Api.Controllers;
|
||||
|
||||
@@ -599,7 +600,7 @@ public sealed class GradeAnalyticsController(
|
||||
AppCacheProfile.Analytics,
|
||||
[AppCacheTags.CourseGradeStatistics],
|
||||
cancellationToken);
|
||||
return Ok(report);
|
||||
return Ok(LocalizeBenchmarks(report));
|
||||
}
|
||||
|
||||
[HttpGet("teaching-classes/{gradeSheetId:guid}/report.docx")]
|
||||
@@ -874,6 +875,28 @@ public sealed class GradeAnalyticsController(
|
||||
return rows.ToArray();
|
||||
}
|
||||
|
||||
private static TeachingClassAnalysisReport LocalizeBenchmarks(TeachingClassAnalysisReport report)
|
||||
{
|
||||
if (!CultureInfo.CurrentUICulture.TwoLetterISOLanguageName.Equals("en", StringComparison.OrdinalIgnoreCase))
|
||||
return report;
|
||||
|
||||
return report with
|
||||
{
|
||||
ScopeBenchmarks = report.ScopeBenchmarks.Select(item => item with
|
||||
{
|
||||
Scope = item.Scope switch
|
||||
{
|
||||
"行政班" => "Class",
|
||||
"专业" => "Major",
|
||||
"学院" => "College",
|
||||
"全校" => "University",
|
||||
_ => item.Scope
|
||||
},
|
||||
Name = item.Scope == "全校" && item.Name == "全校同课程" ? "University course" : item.Name
|
||||
}).ToArray()
|
||||
};
|
||||
}
|
||||
|
||||
private static void AddBenchmark(
|
||||
ICollection<ScopeBenchmark> target,
|
||||
IEnumerable<CourseGradeStatistic> source,
|
||||
|
||||
Reference in new issue
Block a user