Merge pull request #2072 from famedly/krille/add-voice-message-localization

feat: Add localization for voice message type
This commit is contained in:
Krille-chan 2025-05-09 12:35:44 +02:00 committed by GitHub
commit 19b187f106
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 0 deletions

View File

@ -42,6 +42,15 @@ abstract class EventLocalizations {
event.senderFromMemoryOrFallback.calcDisplayname(i18n: i18n),
);
case MessageTypes.Audio:
if (event.content.tryGetMap('org.matrix.msc3245.voice') != null) {
final durationInt = event.content
.tryGetMap<String, Object?>('info')
?.tryGet<int>('duration');
return i18n.voiceMessage(
event.senderFromMemoryOrFallback.calcDisplayname(i18n: i18n),
durationInt == null ? null : Duration(milliseconds: durationInt),
);
}
return i18n.sentAnAudio(
event.senderFromMemoryOrFallback.calcDisplayname(i18n: i18n),
);

View File

@ -310,4 +310,12 @@ class MatrixDefaultLocalizations extends MatrixLocalizations {
@override
String startedKeyVerification(String senderName) =>
'$senderName started key verification';
@override
String voiceMessage(String senderName, Duration? duration) {
final durationString = duration == null
? ''
: '${duration.inMinutes.toString().padLeft(2, '0')}:${(duration.inSeconds % 60).toString().padLeft(2, '0')} ';
return '$senderName: ${durationString}Voice message';
}
}

View File

@ -150,6 +150,8 @@ abstract class MatrixLocalizations {
String sentAnAudio(String senderName);
String voiceMessage(String senderName, Duration? duration);
String sentAVideo(String senderName);
String sentReaction(String senderName, String reactionKey);