Skip to content

Commit aa4033c

Browse files
authored
fix(srt): handle undefined/null text in malformed SRT files (#1990)
* fix(cli/srt): filter out undefined/null subtitle entries during push and pull operations * fix(cli/srt): add warning for skipping undefined/null subtitle entries during push * refactor(srt): remove misleading warnings for filtered undefined entries Warnings were misleading since entries get filled from sourceData in final merge. Final output is correct, so silent filtering is appropriate.
1 parent 83204dd commit aa4033c

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

.changeset/fix-srt-undefined.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"lingo.dev": patch
3+
---
4+
5+
fix(srt): filter undefined/null subtitle entries during push

packages/cli/src/cli/loaders/srt.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,7 @@ export default function createSrtLoader(): ILoader<
2424

2525
async push(locale, payload) {
2626
const output = Object.entries(payload)
27-
.filter(([key, text]) => {
28-
if (text === undefined || text === null) {
29-
console.warn(
30-
`⚠️ [SRT] Skipping subtitle entry ${key} - text is ${text === undefined ? "undefined" : "null"}`,
31-
);
32-
return false;
33-
}
34-
return true;
35-
})
27+
.filter(([, text]) => text !== undefined && text !== null)
3628
.map(([key, text]) => {
3729
const [id, timeRange] = key.split("#");
3830
const [startTime, endTime] = timeRange.split("-");

0 commit comments

Comments
 (0)