fix(i18n): normalize translations and fallbacks
This commit is contained in:
@@ -4,6 +4,8 @@ import 'package:provider/provider.dart';
|
||||
import 'package:shimmer/shimmer.dart';
|
||||
|
||||
import '../estado/estado_radio.dart';
|
||||
import '../l10n/display_names.dart';
|
||||
import '../l10n/gen/app_localizations.dart';
|
||||
import '../modelos/emisora.dart';
|
||||
import '../tema/pluriwave_theme.dart';
|
||||
import 'pluri_glass_surface.dart';
|
||||
@@ -37,12 +39,14 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
final esFav = await estado.toggleFavorito(widget.emisora);
|
||||
if (mounted) setState(() => _toggling = false);
|
||||
if (mounted) {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final stationName = localizedStationName(l10n, widget.emisora.nombre);
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
esFav
|
||||
? '${widget.emisora.nombre} añadida a favoritos'
|
||||
: '${widget.emisora.nombre} eliminada de favoritos',
|
||||
? l10n.favoritesAddedMessage(stationName)
|
||||
: l10n.favoritesRemovedMessage(stationName),
|
||||
),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
@@ -53,9 +57,11 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final t = context.pluriTokens;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final stationName = localizedStationName(l10n, widget.emisora.nombre);
|
||||
return Semantics(
|
||||
button: widget.onTap != null,
|
||||
label: 'Emisora ${widget.emisora.nombre}',
|
||||
label: l10n.stationSemanticLabel(stationName),
|
||||
child: PluriGlassSurface(
|
||||
padding: EdgeInsets.zero,
|
||||
borderRadius: BorderRadius.circular(
|
||||
@@ -74,6 +80,10 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
|
||||
Widget _buildCompleta() {
|
||||
final t = context.pluriTokens;
|
||||
final stationName = localizedStationName(
|
||||
AppLocalizations.of(context),
|
||||
widget.emisora.nombre,
|
||||
);
|
||||
return Stack(
|
||||
children: [
|
||||
Column(
|
||||
@@ -116,7 +126,7 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.emisora.nombre,
|
||||
stationName,
|
||||
style: Theme.of(context).textTheme.titleSmall?.copyWith(
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
@@ -153,6 +163,10 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
|
||||
Widget _buildCompacta() {
|
||||
final t = context.pluriTokens;
|
||||
final stationName = localizedStationName(
|
||||
AppLocalizations.of(context),
|
||||
widget.emisora.nombre,
|
||||
);
|
||||
final subtitulo = [
|
||||
widget.emisora.pais,
|
||||
widget.emisora.idioma,
|
||||
@@ -192,7 +206,7 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
widget.emisora.nombre,
|
||||
stationName,
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.titleSmall?.copyWith(fontWeight: FontWeight.w700),
|
||||
@@ -223,6 +237,7 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
|
||||
Widget _botonFavorito({required bool mini}) {
|
||||
final t = context.pluriTokens;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
final esFavorito = context.select<EstadoRadio, bool>(
|
||||
(estado) =>
|
||||
estado.listaFavoritos.any((e) => e.uuid == widget.emisora.uuid),
|
||||
@@ -248,13 +263,16 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
: PluriIconVariant.outline,
|
||||
size: 20,
|
||||
semanticLabel:
|
||||
esFavorito ? 'Quitar de favoritos' : 'Añadir a favoritos',
|
||||
esFavorito
|
||||
? l10n.favoritesRemoveTooltip
|
||||
: l10n.favoritesAddTooltip,
|
||||
);
|
||||
|
||||
return Semantics(
|
||||
button: true,
|
||||
toggled: esFavorito,
|
||||
label: esFavorito ? 'Quitar de favoritos' : 'Añadir a favoritos',
|
||||
label:
|
||||
esFavorito ? l10n.favoritesRemoveTooltip : l10n.favoritesAddTooltip,
|
||||
child: Material(
|
||||
color: mini ? t.glassSurface : Colors.transparent,
|
||||
shape: const CircleBorder(),
|
||||
@@ -318,7 +336,7 @@ class _TarjetaEmisoraState extends State<TarjetaEmisora> {
|
||||
glyph: PluriIconGlyph.player,
|
||||
variant: PluriIconVariant.activeGlow,
|
||||
size: size,
|
||||
semanticLabel: 'Icono de emisora',
|
||||
semanticLabel: AppLocalizations.of(context).stationIconLabel,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -345,6 +363,7 @@ class _LiveBadge extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final color = Theme.of(context).colorScheme.secondary;
|
||||
final l10n = AppLocalizations.of(context);
|
||||
return Container(
|
||||
padding: EdgeInsets.symmetric(horizontal: mini ? 8 : 6, vertical: mini ? 5 : 4),
|
||||
decoration: BoxDecoration(
|
||||
@@ -358,7 +377,7 @@ class _LiveBadge extends StatelessWidget {
|
||||
Icon(Icons.fiber_manual_record_rounded, size: mini ? 10 : 8, color: color),
|
||||
if (mini) ...[
|
||||
const SizedBox(width: 5),
|
||||
Text('Live', style: Theme.of(context).textTheme.labelSmall?.copyWith(fontWeight: FontWeight.w900)),
|
||||
Text(l10n.liveNow, style: Theme.of(context).textTheme.labelSmall?.copyWith(fontWeight: FontWeight.w900)),
|
||||
],
|
||||
],
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user