feat(i18n): add localization foundation
Build & Deploy Pluriwave / Build APK + AAB release (push) Successful in 1m52s
Build & Deploy Pluriwave / Análisis de código (push) Successful in 24s

This commit is contained in:
2026-05-22 13:29:52 +02:00
parent d85dee6fa8
commit 3f548fd53e
13 changed files with 986 additions and 65 deletions
+338
View File
@@ -0,0 +1,338 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:intl/intl.dart' as intl;
import 'app_localizations_en.dart';
import 'app_localizations_es.dart';
// ignore_for_file: type=lint
/// Callers can lookup localized strings with an instance of AppLocalizations
/// returned by `AppLocalizations.of(context)`.
///
/// Applications need to include `AppLocalizations.delegate()` in their app's
/// `localizationDelegates` list, and the locales they support in the app's
/// `supportedLocales` list. For example:
///
/// ```dart
/// import 'gen/app_localizations.dart';
///
/// return MaterialApp(
/// localizationsDelegates: AppLocalizations.localizationsDelegates,
/// supportedLocales: AppLocalizations.supportedLocales,
/// home: MyApplicationHome(),
/// );
/// ```
///
/// ## Update pubspec.yaml
///
/// Please make sure to update your pubspec.yaml to include the following
/// packages:
///
/// ```yaml
/// dependencies:
/// # Internationalization support.
/// flutter_localizations:
/// sdk: flutter
/// intl: any # Use the pinned version from flutter_localizations
///
/// # Rest of dependencies
/// ```
///
/// ## iOS Applications
///
/// iOS applications define key application metadata, including supported
/// locales, in an Info.plist file that is built into the application bundle.
/// To configure the locales supported by your app, youll need to edit this
/// file.
///
/// First, open your projects ios/Runner.xcworkspace Xcode workspace file.
/// Then, in the Project Navigator, open the Info.plist file under the Runner
/// projects Runner folder.
///
/// Next, select the Information Property List item, select Add Item from the
/// Editor menu, then select Localizations from the pop-up menu.
///
/// Select and expand the newly-created Localizations item then, for each
/// locale your application supports, add a new item and select the locale
/// you wish to add from the pop-up menu in the Value field. This list should
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
static AppLocalizations of(BuildContext context) {
return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
}
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
///
/// Returns a list of localizations delegates containing this delegate along with
/// GlobalMaterialLocalizations.delegate, GlobalCupertinoLocalizations.delegate,
/// and GlobalWidgetsLocalizations.delegate.
///
/// Additional delegates can be added by appending to this list in
/// MaterialApp. This list does not have to be used at all if a custom list
/// of delegates is preferred or required.
static const List<LocalizationsDelegate<dynamic>> localizationsDelegates =
<LocalizationsDelegate<dynamic>>[
delegate,
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
];
/// A list of this localizations delegate's supported locales.
static const List<Locale> supportedLocales = <Locale>[
Locale('en'),
Locale('es'),
];
/// No description provided for @appTitle.
///
/// In es, this message translates to:
/// **'PluriWave'**
String get appTitle;
/// No description provided for @navHome.
///
/// In es, this message translates to:
/// **'Inicio'**
String get navHome;
/// No description provided for @navSearch.
///
/// In es, this message translates to:
/// **'Buscar'**
String get navSearch;
/// No description provided for @navFavorites.
///
/// In es, this message translates to:
/// **'Favoritos'**
String get navFavorites;
/// No description provided for @navAlarms.
///
/// In es, this message translates to:
/// **'Alarmas'**
String get navAlarms;
/// No description provided for @navSettings.
///
/// In es, this message translates to:
/// **'Ajustes'**
String get navSettings;
/// No description provided for @actionOk.
///
/// In es, this message translates to:
/// **'OK'**
String get actionOk;
/// No description provided for @sleepTimer.
///
/// In es, this message translates to:
/// **'Timer de sueño'**
String get sleepTimer;
/// No description provided for @sleepTimerDescription.
///
/// In es, this message translates to:
/// **'Apagado suave de la radio con cuenta atrás exacta.'**
String get sleepTimerDescription;
/// No description provided for @cancelTimer.
///
/// In es, this message translates to:
/// **'Cancelar timer'**
String get cancelTimer;
/// No description provided for @optionOther.
///
/// In es, this message translates to:
/// **'Otro'**
String get optionOther;
/// No description provided for @customDurationTitle.
///
/// In es, this message translates to:
/// **'Duración personalizada'**
String get customDurationTitle;
/// No description provided for @durationGreaterThanZero.
///
/// In es, this message translates to:
/// **'Elegí una duración mayor que cero.'**
String get durationGreaterThanZero;
/// No description provided for @hoursLabel.
///
/// In es, this message translates to:
/// **'Horas'**
String get hoursLabel;
/// No description provided for @minutesLabel.
///
/// In es, this message translates to:
/// **'Minutos'**
String get minutesLabel;
/// No description provided for @secondsLabel.
///
/// In es, this message translates to:
/// **'Segundos'**
String get secondsLabel;
/// No description provided for @saveQuickAccess.
///
/// In es, this message translates to:
/// **'Guardar como acceso rápido'**
String get saveQuickAccess;
/// No description provided for @startTimer.
///
/// In es, this message translates to:
/// **'Iniciar timer'**
String get startTimer;
/// No description provided for @skipCurrentAlarmExecution.
///
/// In es, this message translates to:
/// **'Omitida esta ejecución de {alarmName}.'**
String skipCurrentAlarmExecution(Object alarmName);
/// No description provided for @settingsTitle.
///
/// In es, this message translates to:
/// **'Ajustes'**
String get settingsTitle;
/// No description provided for @settingsSubtitle.
///
/// In es, this message translates to:
/// **'Control fino de sonido, copias de seguridad y emisoras personalizadas.'**
String get settingsSubtitle;
/// No description provided for @languageSectionTitle.
///
/// In es, this message translates to:
/// **'Idioma'**
String get languageSectionTitle;
/// No description provided for @languageSectionDescription.
///
/// In es, this message translates to:
/// **'Elegí cómo se muestra el idioma de la app.'**
String get languageSectionDescription;
/// No description provided for @languageSystemDefault.
///
/// In es, this message translates to:
/// **'Sistema'**
String get languageSystemDefault;
/// No description provided for @languageSpanish.
///
/// In es, this message translates to:
/// **'Español'**
String get languageSpanish;
/// No description provided for @languageEnglish.
///
/// In es, this message translates to:
/// **'Inglés'**
String get languageEnglish;
/// No description provided for @languageUpdated.
///
/// In es, this message translates to:
/// **'Idioma actualizado: {languageName}'**
String languageUpdated(Object languageName);
/// No description provided for @languageUpdatedSystem.
///
/// In es, this message translates to:
/// **'Idioma actualizado: Sistema'**
String get languageUpdatedSystem;
/// No description provided for @timerSectionTitle.
///
/// In es, this message translates to:
/// **'Timer de sueño'**
String get timerSectionTitle;
/// No description provided for @timerSectionAdd.
///
/// In es, this message translates to:
/// **'Añadir'**
String get timerSectionAdd;
/// No description provided for @timerSectionDescription.
///
/// In es, this message translates to:
/// **'Personalizá los accesos rápidos que aparecen al apagar la radio automáticamente.'**
String get timerSectionDescription;
/// No description provided for @timerSectionRestoreRecommended.
///
/// In es, this message translates to:
/// **'Restaurar tiempos recomendados'**
String get timerSectionRestoreRecommended;
/// No description provided for @newQuickAccessTitle.
///
/// In es, this message translates to:
/// **'Nuevo acceso rápido'**
String get newQuickAccessTitle;
/// No description provided for @saveQuickAccessButton.
///
/// In es, this message translates to:
/// **'Guardar acceso rápido'**
String get saveQuickAccessButton;
}
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
Future<AppLocalizations> load(Locale locale) {
return SynchronousFuture<AppLocalizations>(lookupAppLocalizations(locale));
}
@override
bool isSupported(Locale locale) =>
<String>['en', 'es'].contains(locale.languageCode);
@override
bool shouldReload(_AppLocalizationsDelegate old) => false;
}
AppLocalizations lookupAppLocalizations(Locale locale) {
// Lookup logic when only language code is specified.
switch (locale.languageCode) {
case 'en':
return AppLocalizationsEn();
case 'es':
return AppLocalizationsEs();
}
throw FlutterError(
'AppLocalizations.delegate failed to load unsupported locale "$locale". This is likely '
'an issue with the localizations generation tool. Please file an issue '
'on GitHub with a reproducible sample app and the gen-l10n configuration '
'that was used.',
);
}
+120
View File
@@ -0,0 +1,120 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for English (`en`).
class AppLocalizationsEn extends AppLocalizations {
AppLocalizationsEn([String locale = 'en']) : super(locale);
@override
String get appTitle => 'PluriWave';
@override
String get navHome => 'Home';
@override
String get navSearch => 'Search';
@override
String get navFavorites => 'Favorites';
@override
String get navAlarms => 'Alarms';
@override
String get navSettings => 'Settings';
@override
String get actionOk => 'OK';
@override
String get sleepTimer => 'Sleep timer';
@override
String get sleepTimerDescription =>
'Smooth radio shutdown with an exact countdown.';
@override
String get cancelTimer => 'Cancel timer';
@override
String get optionOther => 'Other';
@override
String get customDurationTitle => 'Custom duration';
@override
String get durationGreaterThanZero => 'Choose a duration greater than zero.';
@override
String get hoursLabel => 'Hours';
@override
String get minutesLabel => 'Minutes';
@override
String get secondsLabel => 'Seconds';
@override
String get saveQuickAccess => 'Save as quick access';
@override
String get startTimer => 'Start timer';
@override
String skipCurrentAlarmExecution(Object alarmName) {
return 'Skipped this execution of $alarmName.';
}
@override
String get settingsTitle => 'Settings';
@override
String get settingsSubtitle =>
'Fine-grained sound control, backups, and custom stations.';
@override
String get languageSectionTitle => 'Language';
@override
String get languageSectionDescription =>
'Choose how the app language is displayed.';
@override
String get languageSystemDefault => 'System';
@override
String get languageSpanish => 'Spanish';
@override
String get languageEnglish => 'English';
@override
String languageUpdated(Object languageName) {
return 'Language updated: $languageName';
}
@override
String get languageUpdatedSystem => 'Language updated: System';
@override
String get timerSectionTitle => 'Sleep timer';
@override
String get timerSectionAdd => 'Add';
@override
String get timerSectionDescription =>
'Customize the quick presets shown when automatically stopping the radio.';
@override
String get timerSectionRestoreRecommended => 'Restore recommended times';
@override
String get newQuickAccessTitle => 'New quick access';
@override
String get saveQuickAccessButton => 'Save quick access';
}
+120
View File
@@ -0,0 +1,120 @@
// ignore: unused_import
import 'package:intl/intl.dart' as intl;
import 'app_localizations.dart';
// ignore_for_file: type=lint
/// The translations for Spanish Castilian (`es`).
class AppLocalizationsEs extends AppLocalizations {
AppLocalizationsEs([String locale = 'es']) : super(locale);
@override
String get appTitle => 'PluriWave';
@override
String get navHome => 'Inicio';
@override
String get navSearch => 'Buscar';
@override
String get navFavorites => 'Favoritos';
@override
String get navAlarms => 'Alarmas';
@override
String get navSettings => 'Ajustes';
@override
String get actionOk => 'OK';
@override
String get sleepTimer => 'Timer de sueño';
@override
String get sleepTimerDescription =>
'Apagado suave de la radio con cuenta atrás exacta.';
@override
String get cancelTimer => 'Cancelar timer';
@override
String get optionOther => 'Otro';
@override
String get customDurationTitle => 'Duración personalizada';
@override
String get durationGreaterThanZero => 'Elegí una duración mayor que cero.';
@override
String get hoursLabel => 'Horas';
@override
String get minutesLabel => 'Minutos';
@override
String get secondsLabel => 'Segundos';
@override
String get saveQuickAccess => 'Guardar como acceso rápido';
@override
String get startTimer => 'Iniciar timer';
@override
String skipCurrentAlarmExecution(Object alarmName) {
return 'Omitida esta ejecución de $alarmName.';
}
@override
String get settingsTitle => 'Ajustes';
@override
String get settingsSubtitle =>
'Control fino de sonido, copias de seguridad y emisoras personalizadas.';
@override
String get languageSectionTitle => 'Idioma';
@override
String get languageSectionDescription =>
'Elegí cómo se muestra el idioma de la app.';
@override
String get languageSystemDefault => 'Sistema';
@override
String get languageSpanish => 'Español';
@override
String get languageEnglish => 'Inglés';
@override
String languageUpdated(Object languageName) {
return 'Idioma actualizado: $languageName';
}
@override
String get languageUpdatedSystem => 'Idioma actualizado: Sistema';
@override
String get timerSectionTitle => 'Timer de sueño';
@override
String get timerSectionAdd => 'Añadir';
@override
String get timerSectionDescription =>
'Personalizá los accesos rápidos que aparecen al apagar la radio automáticamente.';
@override
String get timerSectionRestoreRecommended => 'Restaurar tiempos recomendados';
@override
String get newQuickAccessTitle => 'Nuevo acceso rápido';
@override
String get saveQuickAccessButton => 'Guardar acceso rápido';
}