feat: enhance localization support with additional strings and improved structure

This commit is contained in:
cogwheel0
2025-08-24 20:27:11 +05:30
parent 25201cbcfc
commit cc46799e20
15 changed files with 1150 additions and 365 deletions

View File

@@ -64,7 +64,8 @@ import 'app_localizations_it.dart';
/// be consistent with the languages listed in the AppLocalizations.supportedLocales
/// property.
abstract class AppLocalizations {
AppLocalizations(String locale) : localeName = intl.Intl.canonicalizedLocale(locale.toString());
AppLocalizations(String locale)
: localeName = intl.Intl.canonicalizedLocale(locale.toString());
final String localeName;
@@ -72,7 +73,8 @@ abstract class AppLocalizations {
return Localizations.of<AppLocalizations>(context, AppLocalizations);
}
static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
static const LocalizationsDelegate<AppLocalizations> delegate =
_AppLocalizationsDelegate();
/// A list of this localizations delegate along with the default localizations
/// delegates.
@@ -84,19 +86,20 @@ abstract class AppLocalizations {
/// 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,
];
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('de'),
Locale('en'),
Locale('fr'),
Locale('it')
Locale('it'),
];
/// No description provided for @appTitle.
@@ -1190,9 +1193,154 @@ abstract class AppLocalizations {
/// In en, this message translates to:
/// **'Conduit information and links'**
String get aboutAppSubtitle;
/// No description provided for @appLanguage.
///
/// In en, this message translates to:
/// **'App language'**
String get appLanguage;
/// No description provided for @typeBelowToBegin.
///
/// In en, this message translates to:
/// **'Type below to begin'**
String get typeBelowToBegin;
/// No description provided for @listening.
///
/// In en, this message translates to:
/// **'Listening…'**
String get listening;
/// No description provided for @recording.
///
/// In en, this message translates to:
/// **'Recording…'**
String get recording;
/// No description provided for @transcribing.
///
/// In en, this message translates to:
/// **'Transcribing…'**
String get transcribing;
/// No description provided for @speakNow.
///
/// In en, this message translates to:
/// **'Speak now…'**
String get speakNow;
/// No description provided for @chats.
///
/// In en, this message translates to:
/// **'Chats'**
String get chats;
/// No description provided for @darkMode.
///
/// In en, this message translates to:
/// **'Dark Mode'**
String get darkMode;
/// No description provided for @transcript.
///
/// In en, this message translates to:
/// **'Transcript'**
String get transcript;
/// No description provided for @pinned.
///
/// In en, this message translates to:
/// **'Pinned'**
String get pinned;
/// No description provided for @folders.
///
/// In en, this message translates to:
/// **'Folders'**
String get folders;
/// No description provided for @archived.
///
/// In en, this message translates to:
/// **'Archived'**
String get archived;
/// No description provided for @holdToTalk.
///
/// In en, this message translates to:
/// **'Hold to talk'**
String get holdToTalk;
/// No description provided for @autoSend.
///
/// In en, this message translates to:
/// **'Auto-send'**
String get autoSend;
/// No description provided for @stopListening.
///
/// In en, this message translates to:
/// **'Stop listening'**
String get stopListening;
/// No description provided for @startListening.
///
/// In en, this message translates to:
/// **'Start listening'**
String get startListening;
/// No description provided for @start.
///
/// In en, this message translates to:
/// **'Start'**
String get start;
/// No description provided for @stop.
///
/// In en, this message translates to:
/// **'Stop'**
String get stop;
/// No description provided for @web.
///
/// In en, this message translates to:
/// **'Web'**
String get web;
/// No description provided for @imageGen.
///
/// In en, this message translates to:
/// **'Image Gen'**
String get imageGen;
/// No description provided for @webSearch.
///
/// In en, this message translates to:
/// **'Web Search'**
String get webSearch;
/// No description provided for @webSearchDescription.
///
/// In en, this message translates to:
/// **'Let the assistant search the internet while answering.'**
String get webSearchDescription;
/// No description provided for @imageGeneration.
///
/// In en, this message translates to:
/// **'Image Generation'**
String get imageGeneration;
/// No description provided for @imageGenerationDescription.
///
/// In en, this message translates to:
/// **'Generate images from your prompt and attach them.'**
String get imageGenerationDescription;
}
class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
class _AppLocalizationsDelegate
extends LocalizationsDelegate<AppLocalizations> {
const _AppLocalizationsDelegate();
@override
@@ -1201,27 +1349,30 @@ class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations>
}
@override
bool isSupported(Locale locale) => <String>['de', 'en', 'fr', 'it'].contains(locale.languageCode);
bool isSupported(Locale locale) =>
<String>['de', 'en', 'fr', 'it'].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 'de': return AppLocalizationsDe();
case 'en': return AppLocalizationsEn();
case 'fr': return AppLocalizationsFr();
case 'it': return AppLocalizationsIt();
case 'de':
return AppLocalizationsDe();
case 'en':
return AppLocalizationsEn();
case 'fr':
return AppLocalizationsFr();
case 'it':
return AppLocalizationsIt();
}
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.'
'that was used.',
);
}