def factory(obj, field, source_text, lang, context=""):
		"""
		Static method that constructs a translation based on its contents.
		"""

		# Model name
		obj_classname = obj.__class__.__name__

		# Module name
		obj_module = obj.__module__
		
		# Computation of MD5 of the source text
		source_md5 = checksum(source_text)

		# Translated text
		translation = ""

		# Translation text attribute name
		field_lang = trans_attr(field,lang)

		# If in source object there is a translation and is not empty, we asume it was assigned and it's correct
		if hasattr(obj,field_lang) and getattr(obj,field_lang)!="":
			translation = getattr(obj,field_lang)

		# Is the translation fuzzy?
		is_fuzzy = True
		is_fuzzy_lang = trans_is_fuzzy_attr(field,lang)
		if hasattr(obj,is_fuzzy_lang):
			is_fuzzy = getattr(obj,is_fuzzy_lang)

		# Construction of the translation
		trans = FieldTranslation(module=obj_module, model=obj_classname, object_id=obj.id,
		                         field=field, lang=lang, source_text=source_text, source_md5=source_md5,
		                         translation=translation, is_fuzzy=is_fuzzy, context=context)
		return trans
def factory ( obj , field , source_text , lang , context = "" ) : obj_classname = obj . __class__ . __name__ obj_module = obj . __module__ source_md5 = checksum ( source_text ) translation = "" field_lang = trans_attr ( field , lang ) if hasattr ( obj , field_lang ) and getattr ( obj , field_lang ) != "" : translation = getattr ( obj , field_lang ) is_fuzzy = True is_fuzzy_lang = trans_is_fuzzy_attr ( field , lang ) if hasattr ( obj , is_fuzzy_lang ) : is_fuzzy = getattr ( obj , is_fuzzy_lang ) trans = FieldTranslation ( module = obj_module , model = obj_classname , object_id = obj . id , field = field , lang = lang , source_text = source_text , source_md5 = source_md5 , translation = translation , is_fuzzy = is_fuzzy , context = context ) return trans
Static method that constructs a translation based on its contents.