Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'dart:async';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:intl/intl.dart';
- class MyLocalizations {
- MyLocalizations(this.locale);
- final Locale locale;
- Map<String, Map<String, String>> _localizedValues = {
- 'en': {
- },
- 'uk': {
- },
- 'ru': {
- },
- 'pl': {
- },
- "de": {
- }
- };
- String translate(key) {
- if ([locale.languageCode].contains(locale.languageCode))
- return _localizedValues[locale.languageCode][key];
- else
- return _localizedValues["en"][key];
- }
- static String of(BuildContext context, String key) {
- return Localizations.of<MyLocalizations>(context, MyLocalizations)
- .translate(key);
- }
- }
- class MyLocalizationsDelegate extends LocalizationsDelegate<MyLocalizations> {
- const MyLocalizationsDelegate();
- @override
- bool isSupported(Locale locale) => true;
- @override
- Future<MyLocalizations> load(Locale locale) {
- return SynchronousFuture<MyLocalizations>(MyLocalizations(locale));
- }
- @override
- bool shouldReload(MyLocalizationsDelegate old) => false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement