Non-English users saw English text in a dozen places and blank labels in sixteen more. The English came from sites that produce their copy away from the widget that renders it, which is what the structural hardcoded-string check cannot see: picture-in-picture refused with a raw literal instead of the pipErrors.notSupported key that already existed; the two Jellyfin/Emby auth throws missing display: rendered their developer message on the add-server form; ServerParsingException.toString() fed its English into the localized "Failed to load servers" wrapper; Watch Together interpolated the whole PeerError, so a failed create read "Failed to create session: PeerError(PeerErrorType.timeout): Timed out creating session" and join printed its prefix twice; the hub and playlist continuation footers rendered exception.toString(); shader rows showed an English title over an already translated subtitle; the player queue fell back to the raw Dart enum name; a Plex home user with no title showed "Unknown"; a failed player start showed "Exception: Failed to initialize player"; and the tvOS top-shelf header was hardcoded in an extension that has no Flutter engine. The blanks came from three recent features that added English keys without translations. clean_translations.py filled all 21 siblings with empty strings, so the Android TV resolution switch, every Jellyfin/Emby recording-rule field, the demuxer row, the Companion Remote address caption and the Seerr blocklist pill rendered nothing at all. Two fixes are structural rather than key swaps. ContinuationStatusSliver now takes an errorContext and calls a new non-logging localizedLoadErrorText, so no future throw can leak through it. lib/mpv stays free of user-facing copy: it raises a PlayerInitializationException sentinel and a PlayerError.playerInitFailed cause tag that the player screen resolves to localized text. The tvOS section title travels in the shelf payload, additively, so an older cache still renders.
33 lines
1.2 KiB
Dart
33 lines
1.2 KiB
Dart
import '../exceptions/media_server_exceptions.dart';
|
|
import '../i18n/strings.g.dart';
|
|
import 'app_logger.dart';
|
|
|
|
/// Logs a load failure once and returns a localized, user-safe message.
|
|
///
|
|
/// Do not call from `build`: it logs on every invocation. Use
|
|
/// [localizedLoadErrorText] there instead.
|
|
String localizedLoadErrorMessage(Object error, StackTrace stackTrace, {required String context}) {
|
|
appLogger.e('Error loading $context', error: error, stackTrace: stackTrace);
|
|
return localizedLoadErrorText(error, context: context);
|
|
}
|
|
|
|
/// Maps a load failure to a localized, user-safe message without logging.
|
|
///
|
|
/// The returned text never includes exception or server response content.
|
|
String localizedLoadErrorText(Object error, {required String context}) {
|
|
if (error is MediaServerHttpException) {
|
|
switch (error.type) {
|
|
case MediaServerHttpErrorType.connectionTimeout:
|
|
case MediaServerHttpErrorType.receiveTimeout:
|
|
return t.errors.connectionTimeout(context: context);
|
|
case MediaServerHttpErrorType.connectionError:
|
|
return t.errors.connectionFailed;
|
|
case MediaServerHttpErrorType.cancelled:
|
|
case MediaServerHttpErrorType.unknown:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return t.errors.unableToLoad(context: context);
|
|
}
|