93 lines
2.0 KiB
Dart
93 lines
2.0 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'dart:async';
|
|
import 'package:identity/l10n/messages_all.dart';
|
|
|
|
class S {
|
|
S();
|
|
|
|
static S? _current;
|
|
|
|
static S get current {
|
|
assert(_current != null,
|
|
'No instance of S was loaded. Try to initialize the S delegate before accessing S.current.');
|
|
return _current!;
|
|
}
|
|
|
|
static const AppLocalizationDelegate delegate = AppLocalizationDelegate();
|
|
|
|
static Future<S> load(Locale locale) {
|
|
final name = locale.countryCode?.isEmpty ?? false
|
|
? locale.languageCode
|
|
: locale.toString();
|
|
final localeName = Intl.canonicalizedLocale(name);
|
|
Intl.defaultLocale = localeName;
|
|
return initializeMessages(localeName).then((_) {
|
|
final instance = S();
|
|
S._current = instance;
|
|
|
|
return instance;
|
|
});
|
|
}
|
|
|
|
static S of(BuildContext context) {
|
|
final instance = S.maybeOf(context);
|
|
assert(instance != null,
|
|
'No instance of S present in the widget tree. Did you add S.delegate in localizationsDelegates?');
|
|
return instance!;
|
|
}
|
|
|
|
static S? maybeOf(BuildContext context) {
|
|
return Localizations.of<S>(context, S);
|
|
}
|
|
|
|
// Translations
|
|
String get appTitle {
|
|
return Intl.message(
|
|
'My Application',
|
|
name: 'appTitle',
|
|
desc: '',
|
|
args: [],
|
|
);
|
|
}
|
|
|
|
String get likeButton {
|
|
return Intl.message(
|
|
'Like',
|
|
name: 'likeButton',
|
|
desc: '',
|
|
args: [],
|
|
);
|
|
}
|
|
|
|
String get changeLanguage {
|
|
return Intl.message(
|
|
'Change Language',
|
|
name: 'changeLanguage',
|
|
desc: '',
|
|
args: [],
|
|
);
|
|
}
|
|
}
|
|
|
|
class AppLocalizationDelegate extends LocalizationsDelegate<S> {
|
|
const AppLocalizationDelegate();
|
|
|
|
@override
|
|
bool isSupported(Locale locale) {
|
|
return <String>['en', 'ru'].contains(locale.languageCode);
|
|
}
|
|
|
|
@override
|
|
Future<S> load(Locale locale) {
|
|
return S.load(locale);
|
|
}
|
|
|
|
@override
|
|
bool shouldReload(covariant LocalizationsDelegate<S> old) {
|
|
return false;
|
|
}
|
|
}
|