fix: translate settlement runway chart labels
This commit is contained in:
+27
@@ -342,6 +342,33 @@ export function runTests() {
|
|||||||
assert(!highlighted.dashed, `${city} settlement runway should be solid`);
|
assert(!highlighted.dashed, `${city} settlement runway should be solid`);
|
||||||
const auxiliary = seriesByKey(chart.series, "runway_99_00") as any;
|
const auxiliary = seriesByKey(chart.series, "runway_99_00") as any;
|
||||||
assert(auxiliary?.dashed === true, `${city} auxiliary runway should be dashed`);
|
assert(auxiliary?.dashed === true, `${city} auxiliary runway should be dashed`);
|
||||||
|
|
||||||
|
const englishChart = __buildTemperatureChartDataForTest(
|
||||||
|
{
|
||||||
|
city,
|
||||||
|
local_date: "2026-05-25",
|
||||||
|
local_time: "10:00",
|
||||||
|
tz_offset_seconds: 8 * 60 * 60,
|
||||||
|
runway_plate_history: {
|
||||||
|
[settlementRwy]: [
|
||||||
|
{ time: "00:05", temp: 25.1 },
|
||||||
|
{ time: "00:35", temp: 25.3 },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
} as any,
|
||||||
|
{ localTime: "10:00", times: ["00:00", "00:30"], temps: [25, 26] } as any,
|
||||||
|
"1D",
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
const englishSettlement = seriesByKey(englishChart.series, runwayKey(settlementRwy)) as any;
|
||||||
|
assert(
|
||||||
|
englishSettlement?.label.includes("Settlement Runway"),
|
||||||
|
`${city} English settlement runway label should be translated`,
|
||||||
|
);
|
||||||
|
assert(
|
||||||
|
!englishSettlement?.label.includes("结算跑道"),
|
||||||
|
`${city} English settlement runway label should not leak Chinese`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
const shenzhen = __buildTemperatureChartDataForTest(
|
const shenzhen = __buildTemperatureChartDataForTest(
|
||||||
|
|||||||
@@ -77,6 +77,11 @@ function runwaySeriesKey(rwy: string) {
|
|||||||
.join("_")}`;
|
.join("_")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function runwaySeriesLabel(rwy: string, isSettlement: boolean, isEn: boolean) {
|
||||||
|
if (!isSettlement) return rwy;
|
||||||
|
return `${rwy} ${isEn ? "Settlement Runway" : "结算跑道"}`;
|
||||||
|
}
|
||||||
|
|
||||||
function isTemperatureSeriesVisibleByDefault(city: string, seriesKey: string) {
|
function isTemperatureSeriesVisibleByDefault(city: string, seriesKey: string) {
|
||||||
if (seriesKey.startsWith("model_curve_")) {
|
if (seriesKey.startsWith("model_curve_")) {
|
||||||
return normalizeCityKey(city) === "paris" && seriesKey === "model_curve_AROME HD";
|
return normalizeCityKey(city) === "paris" && seriesKey === "model_curve_AROME HD";
|
||||||
@@ -1153,6 +1158,7 @@ function buildRunwayHistorySeries(
|
|||||||
tzOffset: number,
|
tzOffset: number,
|
||||||
localDateStr: string,
|
localDateStr: string,
|
||||||
minPoints = 2,
|
minPoints = 2,
|
||||||
|
isEn = false,
|
||||||
): RunwayHistorySeries[] {
|
): RunwayHistorySeries[] {
|
||||||
const directHistory =
|
const directHistory =
|
||||||
hourly?.runwayPlateHistory ??
|
hourly?.runwayPlateHistory ??
|
||||||
@@ -1175,7 +1181,7 @@ function buildRunwayHistorySeries(
|
|||||||
const isSettlement = isSettlementRunway(row, normalizedRwy);
|
const isSettlement = isSettlementRunway(row, normalizedRwy);
|
||||||
return {
|
return {
|
||||||
key: runwaySeriesKey(normalizedRwy),
|
key: runwaySeriesKey(normalizedRwy),
|
||||||
label: `${normalizedRwy}${isSettlement ? (row ? " 结算跑道" : " Settlement") : ""}`,
|
label: runwaySeriesLabel(normalizedRwy, isSettlement, isEn),
|
||||||
rwy: normalizedRwy,
|
rwy: normalizedRwy,
|
||||||
isSettlement,
|
isSettlement,
|
||||||
color: isSettlement ? "#009688" : RUNWAY_LINE_COLORS[index % RUNWAY_LINE_COLORS.length],
|
color: isSettlement ? "#009688" : RUNWAY_LINE_COLORS[index % RUNWAY_LINE_COLORS.length],
|
||||||
@@ -1249,7 +1255,7 @@ function buildRunwayHistorySeries(
|
|||||||
if (values.length < minPoints) return null;
|
if (values.length < minPoints) return null;
|
||||||
return {
|
return {
|
||||||
key: runwaySeriesKey(rwy),
|
key: runwaySeriesKey(rwy),
|
||||||
label: `${rwy}${isSettlement ? " 结算跑道" : ""}`,
|
label: runwaySeriesLabel(rwy, isSettlement, isEn),
|
||||||
rwy,
|
rwy,
|
||||||
isSettlement,
|
isSettlement,
|
||||||
color: isSettlement ? "#009688" : RUNWAY_LINE_COLORS[index % RUNWAY_LINE_COLORS.length],
|
color: isSettlement ? "#009688" : RUNWAY_LINE_COLORS[index % RUNWAY_LINE_COLORS.length],
|
||||||
@@ -1575,7 +1581,7 @@ function buildFullDayChartData(
|
|||||||
localDayBounds,
|
localDayBounds,
|
||||||
);
|
);
|
||||||
const runwayHistorySeries = filterRunwayHistoryToLocalDay(
|
const runwayHistorySeries = filterRunwayHistoryToLocalDay(
|
||||||
buildRunwayHistorySeries(row, hourly, tzOffset, localDateStr),
|
buildRunwayHistorySeries(row, hourly, tzOffset, localDateStr, 2, isEn),
|
||||||
localDayBounds,
|
localDayBounds,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user