mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-28 22:49:49 +00:00
ce21098e98
* CW-488 minor code cleanup * Add Derivation Path selector for BTC and LTC * CW-488 Initial Passphrase Impl * CW-488 Final Passphrase Impl * Quick Fix of language Service * CW-488 Implement PR Suggestions * CW-488 Implement PR Suggestions * CW-488 Implement Passphrase for Bitcoin Cash * CW-488 Implement Passphrase for Bitcoin Cash * CW-488 Implement Passphrase for Bitcoin Cash * remove monero and wownero support for passphrase until merged [skip ci] * CW-488 Apply requested change * CW-488 Add Passphrase to QR * CW-488 Fix Seed generation * CW-488 Implement Electrum Passphrases * CW-488 Add Seed Length Selector to BIP39 Seeds * CW-488 Minor fix [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
91 lines
2.2 KiB
Dart
91 lines
2.2 KiB
Dart
import 'package:cake_wallet/generated/locales.dart';
|
|
import 'package:devicelocale/devicelocale.dart';
|
|
import 'package:intl/intl.dart';
|
|
|
|
class LanguageService {
|
|
static const Map<String, String> supportedLocales = {
|
|
'en': 'English',
|
|
'de': 'Deutsch (German)',
|
|
'es': 'Español (Spanish)',
|
|
'fr': 'Français (French)',
|
|
'hi': 'हिंदी (Hindi)',
|
|
'ja': '日本 (Japanese)',
|
|
'ko': '한국어 (Korean)',
|
|
'nl': 'Nederlands (Dutch)',
|
|
'pl': 'Polski (Polish)',
|
|
'pt': 'Português (Portuguese)',
|
|
'ru': 'Русский (Russian)',
|
|
'uk': 'Українська (Ukrainian)',
|
|
'zh': '中文 (Chinese)',
|
|
'hr': 'Hrvatski (Croatian)',
|
|
'it': 'Italiano (Italian)',
|
|
'th': 'ภาษาไทย (Thai)',
|
|
'ar': 'العربية (Arabic)',
|
|
'tr': 'Türkçe (Turkish)',
|
|
'my': 'မြန်မာ (Burmese)',
|
|
'bg': 'Български (Bulgarian)',
|
|
'cs': 'čeština (Czech)',
|
|
'ur': 'اردو (Urdu)',
|
|
'id': 'Bahasa Indonesia (Indonesian)',
|
|
'yo': 'Yorùbá (Yoruba)',
|
|
'ha': 'Hausa Najeriya (Nigeria)',
|
|
'tl': 'Filipino (Tagalog)',
|
|
'hy': 'Հայերեն (Armenian)',
|
|
};
|
|
|
|
static const Map<String, String> localeCountryCode = {
|
|
'en': 'usa',
|
|
'de': 'deu',
|
|
'es': 'esp',
|
|
'fr': 'fra',
|
|
'hi': 'ind',
|
|
'ja': 'jpn',
|
|
'ko': 'kor',
|
|
'nl': 'nld',
|
|
'pl': 'pol',
|
|
'pt': 'prt',
|
|
'ru': 'rus',
|
|
'uk': 'ukr',
|
|
'zh': 'chn',
|
|
'hr': 'hrv',
|
|
'it': 'ita',
|
|
'th': 'tha',
|
|
'ar': 'sau',
|
|
'tr': 'tur',
|
|
'my': 'mmr',
|
|
'bg': 'bgr',
|
|
'cs': 'czk',
|
|
'ur': 'pak',
|
|
'id': 'idn',
|
|
'yo': 'nga',
|
|
'ha': 'hau',
|
|
'tl': 'phl',
|
|
'hy': 'arm',
|
|
};
|
|
|
|
static final list = <String, String>{};
|
|
|
|
static const defaultLocale = 'en';
|
|
|
|
static void loadLocaleList() {
|
|
supportedLocales.forEach((key, value) {
|
|
if (locales.contains(key)) {
|
|
list[key] = value;
|
|
}
|
|
});
|
|
}
|
|
|
|
static Future<String> localeDetection() async {
|
|
try {
|
|
var locale = await Devicelocale.currentLocale ?? '';
|
|
locale = Intl.shortLocale(locale);
|
|
|
|
if (list.keys.contains(locale)) {
|
|
return locale;
|
|
}
|
|
return LanguageService.defaultLocale;
|
|
} catch(_) {
|
|
return LanguageService.defaultLocale;
|
|
}
|
|
}
|
|
}
|