def translate_task(instance_key, system, src_lang, src_field, dst_lang, dst_field): """Celery task to perform a single translation .. Note:: This is rate-limited at 60/m. We really want the translate call to be rate-limited based on the translation system, but given we're only supporting Gengo right now, I'm going to do the rate limiting here across all translation systems rather than figure out how to do it just for Gengo. :arg instance_key: The key for the instance we're translating :arg system: The name of the translation system to use :arg src_lang: The source language :arg src_field: The field in the instance holding the text to translate :arg dst_lang: The destination language :arg dst_field: The field in the instance to shove the translated text into """ instance = key_to_instance(instance_key) translate(instance, system, src_lang, src_field, dst_lang, dst_field)
def test_key_to_instance(self): foo = FakeModel(15) key = 'fjord.base.tests.test_utils:FakeModel:15' eq_(key_to_instance(key), foo)
def test_key_to_instance(self): foo = FakeModel(15) key = 'fjord.base.tests.test_utils:FakeModel:15' assert key_to_instance(key) == foo