Take out some of the concatenation from NotificationsHelper. VSO languages will still be impossible, but our Caucasian friends should now be able to have valid sentences here. I don't particularly like passing a translation into a link helper which is passed into a translation.

This commit is contained in:
Raphael Sofaer 2011-05-23 23:09:48 -07:00
parent 609439f948
commit fc7b2cfe3f
2 changed files with 16 additions and 15 deletions

View file

@ -4,21 +4,21 @@ module NotificationsHelper
if note.instance_of?(Notifications::Mentioned)
post = Mention.find(note.target_id).post
if post
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post)}".html_safe
translation(target_type, :post_link => link_to(t('notifications.post'), object_path(post)).html_safe)
else
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
t('notifications.mentioned_deleted')
end
elsif note.instance_of?(Notifications::CommentOnPost)
post = Post.where(:id => note.target_id).first
if post
"#{translation(target_type)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe
translation(target_type, :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
"#{translation(target_type)} #{t('notifications.deleted')} #{t('notifications.post')}"
t('notifications.also_commented_deleted')
end
elsif note.instance_of?(Notifications::AlsoCommented)
post = Post.where(:id => note.target_id).first
if post
"#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe
translation(target_type, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t('notifications.also_commented_deleted')
end
@ -26,7 +26,7 @@ module NotificationsHelper
post = note.target
post = post.post if post.is_a? Like
if post
"#{translation(target_type, post.author.name)} #{link_to t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link'}".html_safe
translation(target_type, :post_author => h(post.author.name), :post_link => link_to(t('notifications.post'), object_path(post), 'data-ref' => post.id, :class => 'hard_object_link').html_safe)
else
t('notifications.liked_post_deleted')
end
@ -35,8 +35,9 @@ module NotificationsHelper
end
end
def translation(target_type, post_author = nil)
t("#{target_type}", :post_author => post_author)
def translation(target_type, opts = {})
{:post_author => nil}.merge!(opts)
t("#{target_type}", opts).html_safe
end
@ -51,7 +52,7 @@ module NotificationsHelper
number_of_actors = actors.count
sentence_translations = {:two_words_connector => " #{t('notifications.index.and')} ", :last_word_connector => ", #{t('notifications.index.and')} " }
actor_links = actors.collect{ |person| link_to("#{h(person.name.titlecase.strip)}", person_path(person))}
if number_of_actors < 4
message = actor_links.to_sentence(sentence_translations)
else

View file

@ -292,14 +292,14 @@ en:
started_sharing: "started sharing with you."
new_request: "offered to share with you."
private_message: "sent you a message."
comment_on_post: "commented on your"
also_commented: "also commented on %{post_author}'s"
mentioned: "has mentioned you in a "
liked: "has just liked your"
post: "post."
deleted: "deleted"
comment_on_post: "commented on your %{post_link}."
also_commented: "also commented on %{post_author}'s %{post_link}."
mentioned: "has mentioned you in a %{post_link}."
liked: "has just liked your %{post_link}."
post: "post"
also_commented_deleted: "commented on a deleted post."
liked_post_deleted: "liked your deleted post."
mentioned_deleted: "mentioned you in a deleted post."
index:
notifications: "Notifications"
mark_all_as_read: "Mark All as Read"