A Portuguese user reported "Skip Intro" rendering in English on Android TV.
The locale files were not the problem - all 22 were structurally complete.
skip_marker_button.dart simply never imported strings.g.dart and assigned
'Skip Intro' / 'Skip Credits' / 'Next Episode' as plain literals. An audit of
lib/ found ~120 more sites in the same state, in four shapes that need
different fixes:
A literal in a file that never imported the i18n layer is the easy one -
skip_marker_button, performance_stats, track_label_builder and codec_utils all
render text with no `t` in the file at all. TrackLabelBuilder._compose now takes
a fallbackLabel builder instead of an English fallbackPrefix, so the caller
supplies t.audioTracks.track / t.videoControls.subtitleTrack and every unnamed
audio and subtitle row in the track menus is localized.
English reaching the user through an exception message is the widest one, and
it needs care: MediaServerException.message feeds both toString() - logs and
Sentry grouping - and verbatim UI display. Localizing it in place would make
bug-report logs follow the user's locale and split one Sentry issue into 22.
The MediaServer and Seerr families instead gain a nullable `display` alongside
the English `message`, and the six screens that print these errors read
`display ?? message`. PlaybackException keeps the opposite rule, because it
already carries a PlaybackFailureReason for logic and classifyPlaybackFailure
already builds it from t.messages: its stragglers are localized at the throw
site. That also removes the literal "Exception: " prefix Live TV users saw on
a tune failure, since PlaybackException.toString() returns the bare message.
Localized parts hand-concatenated with bare English are the shape no search for
Text('...') can find: '${t.common.pause} auto-scroll' on the home carousel,
'${day} at ${time}' on the Live TV schedule row, and an actor-screen count that
hand-rolled its plural as `n == 1 ? 'title' : 'titles'` - wrong for ru and pl
regardless of translation, now a real Slang plural.
Finally a literal assigned to provider state that a widget renders later:
DownloadProgress.errorMessage, and the four background_downloader notification
bodies, which sit inside a plugin config call where no widget-shaped search
reaches them.
Two things surfaced while converting. track_chapter_controls compared a track
label against 'Audio Track N' to swap in a localized version; once the builder
localized its own fallback that branch became unreachable, so it and the
orphaned _joinTrackLabel are gone. And discovery_view's PeerError fallback arm
looks like a leak but is not - its producers already localize, and a test says
so - so it stays as it is.
All 21 non-base locales are translated, including the 21 keys left empty by
earlier commits that were falling back to English. No locale has an empty value.
scripts/check_hardcoded_strings.py guards the three shapes a structural check
can see, and runs in ci_checks.sh after translation hygiene. Its first draft
passed its own tests while missing this very bug, because 'Skip Intro' is bound
to a local rather than handed to Text(); the name-bound rule that closes that
gap is restricted to phrase-shaped literals, or it cannot tell copy from the
identifiers this codebase binds constantly ('cast_row', 'auto', 'liveTv'). It
cannot see English inside a throw or assigned to a provider field - neither is
distinguishable from a log message without dataflow analysis - and the docstring
says so. label: and actionLabel: are deliberately unscanned: here they name a
diagnostic operation, and a check that is chronically red is a check that gets
switched off.
One commit rather than one per area: the keys, the 22 locale files and the
generated output are a single unit, and any partial split fails the repo's own
unused-key scan on the way through.
close #1856
144 lines
4.0 KiB
Dart
144 lines
4.0 KiB
Dart
import '../i18n/strings.g.dart';
|
|
|
|
/// Utility class for codec-related operations.
|
|
///
|
|
/// Provides centralized codec name mappings, file extension lookups,
|
|
/// and display name formatting.
|
|
class CodecUtils {
|
|
CodecUtils._();
|
|
|
|
static String getSubtitleExtension(String? codec) {
|
|
if (codec == null) return 'srt';
|
|
|
|
switch (codec.toLowerCase()) {
|
|
case 'subrip':
|
|
case 'srt':
|
|
return 'srt';
|
|
case 'ass':
|
|
case 'ssa':
|
|
return 'ass';
|
|
case 'webvtt':
|
|
case 'vtt':
|
|
return 'vtt';
|
|
case 'mov_text':
|
|
return 'srt';
|
|
case 'pgs':
|
|
case 'pgssub':
|
|
case 'hdmv_pgs_subtitle':
|
|
return 'sup';
|
|
case 'dvd_subtitle':
|
|
case 'dvdsub':
|
|
case 'vobsub':
|
|
case 'dvb_sub':
|
|
case 'dvb_subtitle':
|
|
return 'sub';
|
|
default:
|
|
return 'srt';
|
|
}
|
|
}
|
|
|
|
static bool isTextSubtitleCodec(String? codec) {
|
|
if (codec == null) return false;
|
|
return switch (codec.toLowerCase()) {
|
|
'srt' || 'subrip' || 'ass' || 'ssa' || 'webvtt' || 'vtt' || 'mov_text' => true,
|
|
_ => false,
|
|
};
|
|
}
|
|
|
|
/// Image-based (bitmap) subtitle codecs. Plex burns these into the video
|
|
/// when the selected output transport cannot carry a bitmap subtitle
|
|
/// rendition.
|
|
static bool isImageSubtitleCodec(String? codec) {
|
|
if (codec == null) return false;
|
|
return switch (codec.toLowerCase()) {
|
|
'pgs' ||
|
|
'pgssub' ||
|
|
'hdmv_pgs_subtitle' ||
|
|
'dvd_subtitle' ||
|
|
'dvdsub' ||
|
|
'vobsub' ||
|
|
'dvb_sub' ||
|
|
// Jellyfin's own spelling, which is what the transcode profile asks it to burn.
|
|
'dvbsub' ||
|
|
'dvb_subtitle' => true,
|
|
_ => false,
|
|
};
|
|
}
|
|
|
|
/// Subtitle codecs Plex can deliver in a transcode. Text codecs can become
|
|
/// segmented HLS WebVTT; image codecs can be burned into the video.
|
|
static bool isTranscodableSubtitleCodec(String? codec) {
|
|
return isTextSubtitleCodec(codec) || isImageSubtitleCodec(codec);
|
|
}
|
|
|
|
/// Formats a subtitle codec name to a user-friendly display format.
|
|
///
|
|
/// Converts internal codec names like 'SUBRIP' to friendly names like 'SRT'.
|
|
static String formatSubtitleCodec(String codec) {
|
|
final upper = codec.toUpperCase();
|
|
return switch (upper) {
|
|
'SUBRIP' => 'SRT',
|
|
'DVD_SUBTITLE' => 'DVD',
|
|
'WEBVTT' => 'VTT',
|
|
'HDMV_PGS_SUBTITLE' => 'PGS',
|
|
'MOV_TEXT' => 'MOV',
|
|
_ => upper,
|
|
};
|
|
}
|
|
|
|
/// Formats a video codec name to a user-friendly display format.
|
|
///
|
|
/// Converts internal codec names like 'hevc' to friendly names like 'HEVC'.
|
|
static String formatVideoCodec(String codec) {
|
|
final lower = codec.toLowerCase();
|
|
return switch (lower) {
|
|
'h264' || 'avc1' || 'avc' => 'H.264',
|
|
'hevc' || 'h265' || 'hev1' => 'HEVC',
|
|
'av1' => 'AV1',
|
|
'vp8' => 'VP8',
|
|
'vp9' => 'VP9',
|
|
'mpeg2video' || 'mpeg2' => 'MPEG-2',
|
|
'mpeg4' => 'MPEG-4',
|
|
'vc1' => 'VC-1',
|
|
_ => codec.toUpperCase(),
|
|
};
|
|
}
|
|
|
|
/// Formats an audio channel count as a friendly layout name (2 → 'Stereo',
|
|
/// 6 → '5.1'). Returns null when [channels] is null or not positive.
|
|
static String? formatAudioChannels(int? channels) {
|
|
if (channels == null || channels <= 0) return null;
|
|
return switch (channels) {
|
|
1 => t.fileInfo.channelsMono,
|
|
2 => t.videoSettings.audioOutputStereo,
|
|
3 => '3.0',
|
|
4 => '4.0',
|
|
5 => '4.1',
|
|
6 => '5.1',
|
|
7 => '6.1',
|
|
8 => '7.1',
|
|
_ => '${channels}ch',
|
|
};
|
|
}
|
|
|
|
/// Formats an audio codec name to a user-friendly display format.
|
|
static String formatAudioCodec(String codec) {
|
|
final lower = codec.toLowerCase();
|
|
return switch (lower) {
|
|
'aac' => 'AAC',
|
|
'ac3' => 'AC3',
|
|
'eac3' || 'ec3' => 'E-AC3',
|
|
'truehd' => 'TrueHD',
|
|
'dts' => 'DTS',
|
|
'dca' => 'DTS',
|
|
'dtshd' || 'dts-hd' => 'DTS-HD',
|
|
'flac' => 'FLAC',
|
|
'mp3' || 'mp3float' => 'MP3',
|
|
'opus' => 'Opus',
|
|
'vorbis' => 'Vorbis',
|
|
'pcm_s16le' || 'pcm_s24le' || 'pcm' => 'PCM',
|
|
_ => codec.toUpperCase(),
|
|
};
|
|
}
|
|
}
|