Skip to content

Commit 80ffabe

Browse files
authored
Fix time display in review step (#1137)
Fix #1136 See commit messages.
2 parents fa09899 + 9163644 commit 80ffabe

File tree

7 files changed

+6
-40
lines changed

7 files changed

+6
-40
lines changed

src/i18n/index.ts

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -32,36 +32,8 @@ void i18n
3232
fallbackLng: "en",
3333

3434
interpolation: {
35+
// React already escapes. Disabled here to avoid double escapes.
3536
escapeValue: false,
36-
format: (value, format, lng) => {
37-
if (format === "duration-seconds") {
38-
if (value == null) {
39-
return "-:--:--";
40-
}
41-
42-
const seconds = value % 60;
43-
value /= 60;
44-
const minutes = Math.floor(value % 60);
45-
value /= 60;
46-
const hours = Math.floor(value % 60);
47-
48-
const secondsString = seconds.toLocaleString(lng, {
49-
minimumFractionDigits: 1,
50-
maximumFractionDigits: 1,
51-
});
52-
const result = [
53-
`${(minutes < 10 ? "0" : "")} + ${minutes}`,
54-
`${(seconds < 10 ? "0" : "")} + ${secondsString}`,
55-
];
56-
if (hours > 0) {
57-
result.unshift(hours.toString());
58-
}
59-
60-
return result.join(":");
61-
} else {
62-
return value;
63-
}
64-
},
6537
},
6638

6739
detection: {

src/i18n/locales/en.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
"set-start": "Set current time as start",
8585
"set-end": "Set current time as end",
8686
"part-will-be-removed": "This part will be removed",
87-
"player-progress": "{{currentTime}} / {{duration}}",
8887
"play": "Play",
8988
"pause": "Pause",
9089
"jump-to-cut-point": "Jump to cut point"

src/i18n/locales/es.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"set-start": "Establecer el instante actual como inicio",
6060
"set-end": "Establecer el instante actual como fin",
6161
"part-will-be-removed": "Esta parte será eliminada",
62-
"player-progress": "{{currentTime, duration-seconds}} / {{duration, duration-seconds}}",
6362
"play": "Reproducir",
6463
"pause": "Pausar"
6564
},

src/i18n/locales/fr.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"set-start": "Définir l’heure actuelle comme début",
6868
"set-end": "Définir l’heure actuelle comme fin",
6969
"part-will-be-removed": "Cette section sera retirée",
70-
"player-progress": "{{currentTime, duration-seconds}} / {{duration, duration-seconds}}",
7170
"play": "Jouer",
7271
"pause": "Pause"
7372
},

src/i18n/locales/nl.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@
5959
"set-start": "Stel de actuele tijd in als starttijd",
6060
"set-end": "Stel de actuele tijd in als eindtijd",
6161
"part-will-be-removed": "Dit deel wordt verwijderd.",
62-
"player-progress": "{{currentTime, duration-seconds}} / {{duration, duration-seconds}}",
6362
"play": "Afspelen",
6463
"pause": "Pauze"
6564
},

src/i18n/locales/zh.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"set-start": "将当前时间设置为开始时间",
6161
"set-end": "将当前时间设置为结束",
6262
"part-will-be-removed": "此部分将被删除",
63-
"player-progress": "{{当前时间, 持续时间-秒}} / {{期间, 持续时间-秒}}",
6463
"play": "播放",
6564
"pause": "暂停"
6665
},
@@ -96,7 +95,7 @@
9695
"seconds": "",
9796
"minutes": "",
9897
"hours": "小时",
99-
"left": "剩余{{时间}}"
98+
"left": "剩余{{time}}"
10099
}
101100
}
102101
}

src/steps/review/control-box.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type SharedProps = {
1919
};
2020

2121
export const ControlBox: React.FC<SharedProps> = ({ previewController, currentTime }) => {
22-
const { t, i18n } = useTranslation();
22+
const { i18n } = useTranslation();
2323
const duration = previewController.current?.duration;
2424
const { isHighContrast } = useColorScheme();
2525

@@ -35,10 +35,9 @@ export const ControlBox: React.FC<SharedProps> = ({ previewController, currentTi
3535
}}>
3636
<Controls {...{ previewController, currentTime }} />
3737
<div css={{ textAlign: "center", color: COLORS.neutral70 }}>
38-
{t("steps.review.player-progress", {
39-
currentTime: formatTime(currentTime, duration, i18n.language),
40-
duration: formatTime(duration, duration, i18n.language),
41-
})}
38+
{formatTime(currentTime, duration, i18n.language)}
39+
/
40+
{formatTime(duration, duration, i18n.language)}
4241
</div>
4342
<Scrubber {...{ previewController, currentTime }} />
4443
</div>

0 commit comments

Comments
 (0)