var Q = require("q");
var _ = require("underscore");
var Jed = require('jed');

var fixtures = require('./fixtures');
var dummy = require('./dummy');
var DummyApi = dummy.DummyApi;

var app = require('./app');
var App = app.App;

var interaction_machine = require('./interaction_machine');
var InteractionMachine = interaction_machine.InteractionMachine;


function make_im(opts) {
    opts = _.defaults(opts || {}, {
        api: new DummyApi(),
        app: new App('start'),
        kv: fixtures.kv(),
        config: fixtures.config(),
        msg: fixtures.msg(),
        setup: true
    });

    var im = new InteractionMachine(opts.api, opts.app);
    im.api.config_store = opts.config;
    im.api.kv_store = opts.kv;

    var p = Q();
    if (opts.setup) {
        p = im.setup(opts.msg);
    }

    return p.thenResolve(im);
}

function i18n_for(lang, opts) {
    return new Jed(fixtures.lang(lang));
}


function catch_err(fn) {
    try {
        fn();
    }
    catch (e) {
        return e;
    }
}


this.make_im = make_im;
this.i18n_for = i18n_for;
this.catch_err = catch_err;

@@ -49,34 +49,8 @@
 e%22);
-%0Avar Jed = require('jed');
 %0A%0Ava
@@ -323,16 +323,143 @@
 chine;%0A%0A
+var translate = require('./translate');%0Avar Translator = translate.Translator;%0Avar LazyTranslator = translate.LazyTranslator;%0A%0A
 %0Afunctio
@@ -982,11 +982,18 @@
 new 
-Jed
+Translator
 (fix
@@ -1014,17 +1014,16 @@
 g));%0A%7D%0A%0A
-%0A
 function
@@ -1163,16 +1163,16 @@
 8n_for;%0A
-
 this.cat
@@ -1191,8 +1191,39 @@
 ch_err;%0A
+this.$ = new LazyTranslator();%0A

Change test_utils to work with the new translation tools