Aidra Connect 10.0.2+16
Aidra Connect Mobile Application
Loading...
Searching...
No Matches
app_localizations.dart
Go to the documentation of this file.
1import 'package:flutter/material.dart';
2import 'translations/ar.dart';
3import 'translations/en.dart';
4
6 final Locale locale;
7
8 AppLocalizations(this.locale);
9
10 // Helper method to keep the code in the widgets concise
11 static AppLocalizations of(BuildContext context) {
12 return Localizations.of<AppLocalizations>(context, AppLocalizations)!;
13 }
14
15 // Static member to have a simple access to the delegate from the MaterialApp
16 static const LocalizationsDelegate<AppLocalizations> delegate = _AppLocalizationsDelegate();
17
18 // List of supported locales
19 static const List<Locale> supportedLocales = [
20 Locale('en', ''), // English
21 Locale('ar', ''), // Arabic
22 ];
23
24 // Maps language code to the respective translations
25 static final Map<String, Map<String, String>> _localizedValues = {
26 'en': en,
27 'ar': ar,
28 };
29
30 // This method will be called from every widget that needs a localized text
31 String translate(String key) {
32 return _localizedValues[locale.languageCode]?[key] ?? key;
33 }
34}
35
36// LocalizationsDelegate is a factory for a set of localized resources
37class _AppLocalizationsDelegate extends LocalizationsDelegate<AppLocalizations> {
39
40 @override
41 bool isSupported(Locale locale) {
42 return ['en', 'ar'].contains(locale.languageCode);
43 }
44
45 @override
46 Future<AppLocalizations> load(Locale locale) async {
48 }
49
50 @override
52}
class AppLocalizations _AppLocalizationsDelegate()
override bool shouldReload(_AppLocalizationsDelegate old)
override bool isSupported(Locale locale)
override Future< AppLocalizations > load(Locale locale) async
final Locale locale
AppLocalizations(this.locale)
const Map< String, String > ar
Definition ar.dart:1
static final Map< String, Map< String, String > > _localizedValues
String translate(String key)
AppLocalizations(this.locale)
static const LocalizationsDelegate< AppLocalizations > delegate
static AppLocalizations of(BuildContext context)
static const List< Locale > supportedLocales
const Map< String, String > en
Definition en.dart:1