def set_translation(self, lang, field, text):
<EOL>auto_slug_obj = None<EOL>if lang == self._get_default_language():<EOL><INDENT>raise CanNotTranslate(<EOL>_('<STR_LIT>'<EOL>'<STR_LIT>')<EOL>)<EOL><DEDENT>trans_obj = self.get_translation_obj(lang, field, create=True)<EOL>trans_obj.translation = text<EOL>trans_obj.save()<EOL>if INSTALLED_AUTOSLUG:<EOL><INDENT>if self.translatable_slug:<EOL><INDENT>try:<EOL><INDENT>auto_slug_obj = self._meta.get_field(self.translatable_slug).populate_from<EOL><DEDENT>except AttributeError:<EOL><INDENT>pass<EOL><DEDENT><DEDENT><DEDENT>if auto_slug_obj:<EOL><INDENT>tobj = self.get_translation_obj(lang, self.translatable_slug, create=True)<EOL>translation = self.get_translation(lang, auto_slug_obj)<EOL>tobj.translation = slugify(translation)<EOL>tobj.save()<EOL><DEDENT>key = self._get_translation_cache_key(lang, field)<EOL>cache.set(key, text)<EOL>cache.delete(self._get_translations_cache_key(lang))<EOL>return trans_obj<EOL>
Store a translation string in the specified field for a Translatable
istance

@type lang: string
@param lang: a string with the name of the language

@type field: string
@param field: a string with the name that we try to get

@type text: string
@param text: a string to be stored as translation of the field