doMT method

Future<CxMt?> doMT(
  1. String from,
  2. String html
)

Machine-translate content

Fetches the machine translation for the posted content from the source to the language of this wiki. Stability: unstable

Parameters:

  • String from (required): The source language code

  • String html (required): The HTML content to translate

Implementation

Future<CxMt?> doMT(
  String from,
  String html,
) async {
  final response = await doMTWithHttpInfo(
    from,
    html,
  );
  if (response.statusCode >= HttpStatus.badRequest) {
    throw ApiException(response.statusCode, await _decodeBodyBytes(response));
  }
  // When a remote server returns no body with a status of 204, we shall not decode it.
  // At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
  // FormatException when trying to decode an empty string.
  if (response.body.isNotEmpty &&
      response.statusCode != HttpStatus.noContent) {
    return await apiClient.deserializeAsync(
      await _decodeBodyBytes(response),
      'CxMt',
    ) as CxMt;
  }
  return null;
}