Skip to content

Commit

Permalink
Support translations
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Wo <[email protected]>
  • Loading branch information
brainwo committed Aug 14, 2024
1 parent 74cb480 commit 1901f26
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/kara.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Kara? parse(String raw) {
String? currentLyric;
Duration? currentStart;
Duration? currentEnd;
Map<String, String> currentTranslation = {};

List<KaraLine> lines = [];
List<KaraTime> time = [];
Expand Down Expand Up @@ -210,11 +211,13 @@ Kara? parse(String raw) {
lyric: currentLyric,
start: currentStart,
end: currentEnd,
translations: currentTranslation.isEmpty ? null : currentTranslation,
time: time,
));
currentLyric = null;
currentStart = null;
currentEnd = null;
currentTranslation = {};
time = [];
}

Expand All @@ -233,9 +236,13 @@ Kara? parse(String raw) {
singers?[parsedSingerIndex] = true;
return singers;
});
continue;
}
if (currentLyric != null) {
// TODO: translations
final translation = line.split(" ");
currentTranslation.update(
translation.first, (_) => translation.skip(1).join(' '),
ifAbsent: () => translation.skip(1).join(" "));
continue;
}
currentLyric = line;
Expand Down

0 comments on commit 1901f26

Please sign in to comment.