fix(i18n): normalize translations and fallbacks
This commit is contained in:
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../estado/estado_radio.dart';
|
||||
import '../l10n/display_names.dart';
|
||||
import '../l10n/gen/app_localizations.dart';
|
||||
import '../pantallas/pantalla_reproductor.dart';
|
||||
import '../servicios/servicio_audio.dart';
|
||||
import '../tema/pluriwave_theme.dart';
|
||||
@@ -17,11 +19,14 @@ class MiniReproductor extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final estado = context.watch<EstadoRadio>();
|
||||
final l10n = AppLocalizations.of(context);
|
||||
estado.configurarLocalizaciones(l10n);
|
||||
final emisora = estado.emisoraActual;
|
||||
|
||||
if (emisora == null) return const SizedBox.shrink();
|
||||
|
||||
final t = context.pluriTokens;
|
||||
final stationName = localizedStationName(l10n, emisora.nombre);
|
||||
|
||||
return SafeArea(
|
||||
top: false,
|
||||
@@ -43,7 +48,7 @@ class MiniReproductor extends StatelessWidget {
|
||||
Expanded(
|
||||
child: Semantics(
|
||||
button: true,
|
||||
label: 'Abrir reproductor de ${emisora.nombre}',
|
||||
label: l10n.miniPlayerOpenLabel(stationName),
|
||||
child: Material(
|
||||
color: Colors.transparent,
|
||||
child: InkWell(
|
||||
@@ -74,7 +79,7 @@ class MiniReproductor extends StatelessWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
emisora.nombre,
|
||||
stationName,
|
||||
style: Theme.of(context)
|
||||
.textTheme
|
||||
.titleSmall
|
||||
@@ -91,7 +96,7 @@ class MiniReproductor extends StatelessWidget {
|
||||
final activo =
|
||||
s == EstadoReproduccion.reproduciendo;
|
||||
return Text(
|
||||
_labelEstado(s),
|
||||
_labelEstado(l10n, s),
|
||||
style: Theme.of(
|
||||
context,
|
||||
).textTheme.bodySmall?.copyWith(
|
||||
@@ -117,7 +122,7 @@ class MiniReproductor extends StatelessWidget {
|
||||
glyph: PluriIconGlyph.player,
|
||||
variant: PluriIconVariant.activeGlow,
|
||||
size: 18,
|
||||
semanticLabel: 'Reproductor',
|
||||
semanticLabel: l10n.playerIconLabel,
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -144,7 +149,7 @@ class MiniReproductor extends StatelessWidget {
|
||||
if (s == EstadoReproduccion.error) {
|
||||
final emisoraActual = estado.emisoraActual;
|
||||
return IconButton(
|
||||
tooltip: 'Reintentar',
|
||||
tooltip: l10n.retryAction,
|
||||
icon: const Icon(Icons.refresh_rounded),
|
||||
onPressed:
|
||||
emisoraActual != null
|
||||
@@ -161,13 +166,13 @@ class MiniReproductor extends StatelessWidget {
|
||||
button: true,
|
||||
label:
|
||||
s == EstadoReproduccion.reproduciendo
|
||||
? 'Pausar'
|
||||
: 'Reproducir',
|
||||
? l10n.pauseAction
|
||||
: l10n.playAction,
|
||||
child: IconButton(
|
||||
tooltip:
|
||||
s == EstadoReproduccion.reproduciendo
|
||||
? 'Pausar'
|
||||
: 'Reproducir',
|
||||
? l10n.pauseAction
|
||||
: l10n.playAction,
|
||||
icon: Icon(
|
||||
s == EstadoReproduccion.reproduciendo
|
||||
? Icons.pause_circle_filled_rounded
|
||||
@@ -190,13 +195,13 @@ class MiniReproductor extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
String _labelEstado(EstadoReproduccion estado) {
|
||||
String _labelEstado(AppLocalizations l10n, EstadoReproduccion estado) {
|
||||
return switch (estado) {
|
||||
EstadoReproduccion.cargando => 'Conectando...',
|
||||
EstadoReproduccion.reproduciendo => 'En directo',
|
||||
EstadoReproduccion.pausado => 'Pausado',
|
||||
EstadoReproduccion.error => 'Error de conexión',
|
||||
EstadoReproduccion.detenido => 'Detenido',
|
||||
EstadoReproduccion.cargando => l10n.playbackStatusConnecting,
|
||||
EstadoReproduccion.reproduciendo => l10n.playbackStatusLive,
|
||||
EstadoReproduccion.pausado => l10n.playbackStatusPaused,
|
||||
EstadoReproduccion.error => l10n.playbackStatusConnectionError,
|
||||
EstadoReproduccion.detenido => l10n.playbackStatusStopped,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user