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
182 lines
5.6 KiB
Dart
182 lines
5.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../media/ids.dart';
|
|
import 'package:material_symbols_icons/symbols.dart';
|
|
import '../media/library_query.dart';
|
|
import '../media/media_backend.dart';
|
|
import '../media/media_item.dart';
|
|
import '../media/media_kind.dart';
|
|
import '../media/media_server_client.dart';
|
|
import '../mixins/paginated_item_loader.dart';
|
|
import '../mixins/standard_paginated_view.dart';
|
|
import '../utils/app_logger.dart';
|
|
import '../utils/media_server_http_client.dart';
|
|
import '../utils/provider_extensions.dart';
|
|
import '../widgets/desktop_app_bar.dart';
|
|
import '../widgets/optimized_media_image.dart';
|
|
import '../utils/media_image_helper.dart';
|
|
import '../i18n/strings.g.dart';
|
|
import 'base_media_list_detail_screen.dart';
|
|
import 'focusable_detail_screen_mixin.dart';
|
|
import '../mixins/grid_focus_node_mixin.dart';
|
|
import '../focus/focusable_action_bar.dart';
|
|
|
|
/// Screen to browse all media featuring a specific actor.
|
|
class ActorMediaScreen extends StatefulWidget {
|
|
final String actorName;
|
|
final String personId;
|
|
final String? actorThumb;
|
|
final String? characterName;
|
|
final String serverId;
|
|
final String? serverName;
|
|
final MediaBackend backend;
|
|
|
|
const ActorMediaScreen({
|
|
super.key,
|
|
required this.actorName,
|
|
required this.personId,
|
|
this.actorThumb,
|
|
this.characterName,
|
|
required this.serverId,
|
|
this.serverName,
|
|
required this.backend,
|
|
});
|
|
|
|
@override
|
|
State<ActorMediaScreen> createState() => _ActorMediaScreenState();
|
|
}
|
|
|
|
class _ActorMediaScreenState extends BaseMediaListDetailScreen<ActorMediaScreen>
|
|
with
|
|
GridFocusNodeMixin<ActorMediaScreen>,
|
|
FocusableDetailScreenMixin<ActorMediaScreen>,
|
|
PaginatedItemLoader<MediaItem, ActorMediaScreen>,
|
|
PaginatedItemUpdatable<ActorMediaScreen>,
|
|
StandardPaginatedView<MediaItem, ActorMediaScreen> {
|
|
static const int _pageSize = 200;
|
|
|
|
@override
|
|
MediaItem get mediaItem => MediaItem(
|
|
id: '',
|
|
backend: widget.backend,
|
|
kind: MediaKind.unknown,
|
|
serverId: widget.serverId,
|
|
serverName: widget.serverName,
|
|
);
|
|
|
|
@override
|
|
String get title => widget.actorName;
|
|
|
|
@override
|
|
String get emptyMessage => t.discover.noContentAvailable;
|
|
|
|
@override
|
|
bool get hasItems => totalSize > 0;
|
|
|
|
@override
|
|
void dispose() {
|
|
disposePagination();
|
|
disposeFocusResources();
|
|
super.dispose();
|
|
}
|
|
|
|
MediaServerClient get _mediaClient => context.getMediaClientForServer(ServerId(widget.serverId));
|
|
|
|
@override
|
|
Future<LibraryPage<MediaItem>> fetchPage(int start, int size, AbortController? abort) {
|
|
return _mediaClient.fetchPersonMediaPage(widget.personId, start: start, size: size, abort: abort);
|
|
}
|
|
|
|
@override
|
|
Future<void> loadItems() {
|
|
return loadStandardPaginatedItems(
|
|
pageSize: _pageSize,
|
|
errorMessageFor: (error, stackTrace) {
|
|
appLogger.e('Failed to load actor media', error: error, stackTrace: stackTrace);
|
|
return t.messages.errorLoading(error: error.toString());
|
|
},
|
|
onLoaded: (loadedCount, totalCount) {
|
|
appLogger.d('Loaded $loadedCount of $totalCount items for actor: ${widget.actorName}');
|
|
autoFocusFirstItemAfterLoad();
|
|
},
|
|
);
|
|
}
|
|
|
|
@override
|
|
List<FocusableAction> getAppBarActions() {
|
|
return [];
|
|
}
|
|
|
|
Widget _buildActorHeader() {
|
|
final theme = Theme.of(context);
|
|
return SliverToBoxAdapter(
|
|
child: Padding(
|
|
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
|
child: Row(
|
|
children: [
|
|
ClipRRect(
|
|
borderRadius: BorderRadius.circular(40),
|
|
child: OptimizedMediaImage(
|
|
client: _mediaClient,
|
|
imagePath: widget.actorThumb,
|
|
width: 80,
|
|
height: 80,
|
|
fit: BoxFit.cover,
|
|
imageType: ImageType.avatar,
|
|
fallbackIcon: Symbols.person_rounded,
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: .start,
|
|
children: [
|
|
Text(
|
|
widget.actorName,
|
|
style: theme.textTheme.headlineSmall?.copyWith(fontWeight: .bold),
|
|
maxLines: 2,
|
|
overflow: .ellipsis,
|
|
),
|
|
if (widget.characterName != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
widget.characterName!,
|
|
style: theme.textTheme.bodyMedium?.copyWith(color: theme.colorScheme.onSurfaceVariant),
|
|
maxLines: 1,
|
|
overflow: .ellipsis,
|
|
),
|
|
],
|
|
if (totalSize > 0) ...[
|
|
const SizedBox(height: 4),
|
|
Text(
|
|
t.discover.titleCount(n: totalSize),
|
|
style: theme.textTheme.bodySmall?.copyWith(color: theme.colorScheme.onSurfaceVariant),
|
|
),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return buildDetailScaffold(
|
|
slivers: [
|
|
CustomAppBar(title: Text(widget.actorName), pinned: true, actions: buildFocusableAppBarActions()),
|
|
_buildActorHeader(),
|
|
...buildStateSlivers(),
|
|
if (hasItems)
|
|
buildSparseFocusableGrid(
|
|
totalItems: totalSize,
|
|
itemAt: (index) => loadedItems[index],
|
|
onRefresh: updateItem,
|
|
onSkeletonVisible: (index) => ensureIndexLoaded(index, pageSize: _pageSize),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|