init static method
dynamic
init({})
Implementation
static init({
required String url,
Map<String, String>? headers,
String sourceLocale = 'en',
String? locale,
List<String>? locales,
}) {
_reqUrl = url;
_reqHeaders = headers ?? {};
_sourceLocale = sourceLocale;
_targetLocale = locale ?? 'en';
_availableLocales = locales ?? ['en'];
Uri fetchUri = Uri.parse(_reqUrl + '/' + _targetLocale + '.json');
http.get(fetchUri, headers: _reqHeaders).then((res) {
List body = jsonDecode(utf8.decode(res.bodyBytes));
for (int i = 0; i < body.length; i++) {
String hash = md5.convert(utf8.encode(body[i]['en'])).toString();
globalTranslations[hash] = body[i][_targetLocale];
}
});
}