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

View file

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