getBestLanguageMatch static method

Language? getBestLanguageMatch(
  1. String languageCode, {
  2. String regionCode = '',
  3. String scriptCode = '',
  4. 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 null when no match is available.

Also see:

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;
}