<commit_before>import { observes } from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { withPluginApi } from 'discourse/lib/plugin-api';
import User from 'discourse/models/user';

function translatePost(post) {
  return Discourse.ajax('/translator/translate', {
    type: 'POST',
    data: { post_id: post.get('id') }
  }).then(function(res) {
    post.setProperties({
      "translated_text": res.translation,
      "detected_lang": res.detected_lang
    });
  });
}
<commit_msg>Use ajax module<commit_after>import { observes } from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import { withPluginApi } from 'discourse/lib/plugin-api';
import { ajax } from 'discourse/lib/ajax';
import User from 'discourse/models/user';

function translatePost(post) {
  return ajax('/translator/translate', {
    type: 'POST',
    data: { post_id: post.get('id') }
  }).then(function(res) {
    post.setProperties({
      "translated_text": res.translation,
      "detected_lang": res.detected_lang
    });
  });
}

{'fraction_non_alphanumeric': 0.15370866845397677, 'fraction_numerical': 0.0, 'mean_word_length': 4.333333333333333, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1375805', 'n_tokens_mistral': 369, 'n_tokens_neox': 359, 'n_words': 68}