getBestLanguageMatch static method
Language?
getBestLanguageMatch(
- String languageCode, {
- String regionCode = '',
- String scriptCode = '',
- ScriptVariant variant = ScriptVariant.native,
Finds the best language match for the provided codes and variant.
The method attempts to match language, region, script and variant to an
SDK-supported Language. If no suitable match exists an explicit null
is returned.
Parameters
languageCode: ISO 639-3 three-letter language code.regionCode: ISO 3166-1_3 three-letter region code (optional).scriptCode: ISO 15924 four-letter script code (optional).variant: a ScriptVariant indicating the script variant to prefer.
Returns
- Language?: the matched language or
nullwhen no match is available.
Also see:
- language - Get the currently selected API language.
- setTTSVoiceByLanguage - Set the TTS voice (used by text-to-speech) by language.
Implementation
static Language? getBestLanguageMatch(
String languageCode, {
String regionCode = '',
String scriptCode = '',
ScriptVariant variant = ScriptVariant.native,
}) {
final OperationResult resultString = staticMethod(
'SdkSettings',
'getBestLanguageMatch',
args: <String, Object>{
'languageCode': languageCode,
'regionCode': regionCode,
'scriptCode': scriptCode,
'variant': variant.id,
},
);
final Language result = Language.fromJson(resultString['result']);
if (result.name.isEmpty) {
return null;
}
return result;
}