You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cake_wallet/lib/entities/language.dart

38 lines
1002 B

import 'package:flutter/material.dart';
import 'package:devicelocale/devicelocale.dart';
import 'package:intl/intl.dart';
const Map<String, String> languages = {
'en': 'English',
'de': 'Deutsch (German)',
'es': 'Español (Spanish)',
'hi': 'हिंदी (Hindi)',
'ja': '日本 (Japanese)',
'ko': '한국어 (Korean)',
'nl': 'Nederlands (Dutch)',
'pl': 'Polski (Polish)',
'pt': 'Português (Portuguese)',
'ru': 'Русский (Russian)',
'uk': 'Українська (Ukrainian)',
'zh': '中文 (Chinese)'
};
class Language with ChangeNotifier {
Language(this._currentLanguage);
String _currentLanguage;
String getCurrentLanguage() => _currentLanguage;
void setCurrentLanguage(String language) {
_currentLanguage = language;
notifyListeners();
}
static Future<String> localeDetection() async {
var locale = await Devicelocale.currentLocale;
locale = Intl.shortLocale(locale);
return languages.keys.contains(locale) ? locale : 'en';
}
}