Allow Activity.content to be fully translatable
This commit is contained in:
parent
ce1344f40b
commit
1e0c938c63
@ -424,6 +424,15 @@ class ActivityMixin(object):
|
|||||||
"tag": {"simple": _("{username} tagged {object}")},
|
"tag": {"simple": _("{username} tagged {object}")},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object_map = {
|
||||||
|
"image": _("an image"),
|
||||||
|
"comment": _("a comment"),
|
||||||
|
"collection": _("a collection"),
|
||||||
|
"video": _("a video"),
|
||||||
|
"audio": _("audio"),
|
||||||
|
"person": _("a person"),
|
||||||
|
}
|
||||||
|
|
||||||
obj = self.get_object
|
obj = self.get_object
|
||||||
target = self.get_target
|
target = self.get_target
|
||||||
actor = self.get_actor
|
actor = self.get_actor
|
||||||
@ -432,15 +441,23 @@ class ActivityMixin(object):
|
|||||||
if content is None or obj is None:
|
if content is None or obj is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Decide what to fill the object with
|
||||||
|
if hasattr(obj, "title") and obj.title.strip(" "):
|
||||||
|
object = obj.title
|
||||||
|
elif obj.object_type in object_map:
|
||||||
|
object = object_map[obj.object_type]
|
||||||
|
else:
|
||||||
|
object = _("an object")
|
||||||
|
|
||||||
if target is None or "targetted" not in content:
|
if target is None or "targetted" not in content:
|
||||||
self.content = content["simple"].format(
|
self.content = content["simple"].format(
|
||||||
username=actor.username,
|
username=actor.username,
|
||||||
object=obj.object_type
|
object=object
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.content = content["targetted"].format(
|
self.content = content["targetted"].format(
|
||||||
username=actor.username,
|
username=actor.username,
|
||||||
object=obj.object_type,
|
object=object,
|
||||||
target=target.object_type,
|
target=target.object_type,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user