getLanguageJson static method
Language data isn't identical between what's currently available on Flutter and native Android/iOS. Agreed with product and team leader, at the moment, to provide what is possible and try and classify as closely as possible to Android/iOS values.
NOTE: 'window.locales' returned an informative list ("en_US, en, he_IL
") when I tried it, but it is officially known to change values for reasons I couldn't determine so not used right now.
Requires permission - Android:
Implementation
static Future<dynamic> getLanguageJson() async {
if (_lng == null) {
//Flutter (Found):
String simLanguage = ""; //Return empty as fallback.
final String localeLanguage = dartIo.Platform.localeName;
//SimInfo package throws exception when it can't find data, due to:
// - Publisher permission missing.
// - User not accepting permission.
// - Sim not present on device.
try {
simLanguage = await TBLSdkPlugin.getIsoCountryCode(); // for example: il
} catch (e) {
TBLLogger.logException(
"DeviceDescriptor | geLanguageJson() | failed. e = ${e.toString()}");
}
_lng = {
"main": localeLanguage,
"locale": localeLanguage,
"dsplng": "",
"sim": simLanguage,
"netw": "",
"kbd": []
};
}
return _lng;
}