diff --git a/app/controllers/invitations_controller.rb b/app/controllers/invitations_controller.rb index ef6a0b0f62a968e1ab6bdfac4c78f578500fbb23..3f4e954351c0e5256b838d177e7836fb44c8c878 100644 --- a/app/controllers/invitations_controller.rb +++ b/app/controllers/invitations_controller.rb @@ -22,8 +22,10 @@ class InvitationsController < Devise::InvitationsController emails = params[:user][:email].to_s.gsub(/\s/, '').split(/, */) #NOTE should we try and find users by email here? probs aspect = current_user.aspects.find(aspect_id) + + language = params[:user][:language] - invites = Invitation.batch_invite(emails, :message => message, :sender => current_user, :aspect => aspect, :service => 'email') + invites = Invitation.batch_invite(emails, :message => message, :sender => current_user, :aspect => aspect, :service => 'email', :language => language) flash[:notice] = extract_messages(invites) diff --git a/app/models/invitation.rb b/app/models/invitation.rb index 3465211dfdc39ded515f8c3fd0117c23470bfb71..3be97a991606eba60cd376fedc5c03bee2861e5e 100644 --- a/app/models/invitation.rb +++ b/app/models/invitation.rb @@ -8,7 +8,7 @@ class Invitation < ActiveRecord::Base belongs_to :recipient, :class_name => 'User' belongs_to :aspect - attr_accessible :sender, :recipient, :aspect, :service, :identifier, :admin, :message + attr_accessible :sender, :recipient, :aspect, :language, :service, :identifier, :admin, :message before_validation :set_email_as_default_service @@ -47,7 +47,8 @@ class Invitation < ActiveRecord::Base end emails end - + + # Downcases the incoming service identifier and assigns it # # @param ident [String] Service identifier diff --git a/app/models/jobs/mail/invite_user_by_email.rb b/app/models/jobs/mail/invite_user_by_email.rb index 37b403d342aed9ebb5533b443259fcb4d92a9c3c..e1e348a3f78822e037c33bd7c150630a1693c9cb 100644 --- a/app/models/jobs/mail/invite_user_by_email.rb +++ b/app/models/jobs/mail/invite_user_by_email.rb @@ -9,7 +9,9 @@ module Jobs @queue = :mail def self.perform(invite_id) invite = Invitation.find(invite_id) - invite.send! + I18n.with_locale(invite.language) do + invite.send! + end end end end diff --git a/app/views/devise/mailer/invitation_instructions.erb b/app/views/devise/mailer/invitation_instructions.erb index fc825618791286d8666e709c586ac26576a06af4..f3fe8a240ac065e5880620f8212e9315d2c203f9 100644 --- a/app/views/devise/mailer/invitation_instructions.erb +++ b/app/views/devise/mailer/invitation_instructions.erb @@ -3,7 +3,7 @@ <head> <title><%=invite_email_title %></title> </head> -<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;">Email not displaying correctly? <a href="<%=invite_email_url(:invitation_token => @resource.invitation_token) %>" style="color: #3F8FBA; text-decoration: none;">View it</a> in your browser</p> +<p style="background-color: rgb(255, 255, 255); text-align: center; font-size: 11px;"><%= t('.displaying_correctly', :link => link_to(t('.view_in'), invite_email_url(:invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </p> <table border="0" cellpadding="0" cellspacing="0" width="100%"><tbody><tr><td style="padding: 30px 15px 0pt; background-color: rgb(221, 221, 221);"> <table style="font-family: 'Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 16px; color: rgb(51, 51, 51);" align="center" border="0" cellpadding="0" cellspacing="0" width="600"> @@ -20,7 +20,7 @@ <tr> <td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);"> - Finally - it's here.<br> + <%= t('.finally') %><br> </td> </tr> @@ -30,10 +30,10 @@ <tr><td style="padding: 0pt 30px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; line-height: 20px;"> - The social network you have been waiting for has arrived. Revamped, more secure, and more fun, <strong>DIASPORA*</strong> is ready to help you share and explore the web in a whole new way. + <%= t('.arrived', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %> <br> <br> - <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="<%= accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank">Sign up now →</a> + <%= link_to(t('.sign_up_now').html_safe, accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %> </td></tr> @@ -43,7 +43,7 @@ <tr> <td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 24px; font-weight: bold; color: rgb(0, 0, 0);"> <br> - What your friends are saying...<br> + <%= t('.friends_saying') %><br> </td> </tr> @@ -59,7 +59,7 @@ <tr> <td style="padding: 10px 0pt 0px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 24px; font-weight: bold; color: rgb(0, 0, 0);"> <br> - Even more people are excited to see you!<br> + <%= t('.more_people') %><br> </td> </tr> @@ -77,7 +77,7 @@ <tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);"> - 1. Get Connected</td></tr> + 1. <%= t('.get_connected') %></td></tr> <tr><td> <table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody><tr> @@ -85,7 +85,7 @@ <a href="<%=accept_invitation_url(@resource, :invitation_token => @resource.invitation_token) %>" target="_blank"><img style="border: 0pt none ; padding: 0pt 10px 0px 5px; display: block;" src="https://joindiaspora.s3.amazonaws.com/uploads/images/scaled_full_c7506ec0b3ae6694c64d.gif" height="156" width="200"></a> </td> <td style="line-height: 20px; width: 360px;"> - An international movement with a shared vision for a better web, DIASPORA*'s #1 feature is its community. Meet new people, connect with friends, and join the fun. + <%= t('.get_connected_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %> <br> <!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://joindiaspora.com/channels" target="_blank">Tune in to your favorite Channels</a>--> </td> @@ -94,14 +94,14 @@ </td></tr> <tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);"> - 2. Be Yourself</td></tr> + 2. <%= t('.be_yourself') %></td></tr> <tr><td> <table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody><tr> <td style="line-height: 20px; width: 360px;"> - The Internet has created unique new ways for us to express ourselves. - <strong>DIASPORA*</strong> lets you be yourself and share however you want, with or without your real name. + <%= t('.be_yourself_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*")).html_safe %> + <br> <!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>--> </td> @@ -115,7 +115,7 @@ <tr><td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; font-size: 44px; font-weight: bold; color: rgb(0, 0, 0);"> - 3. Have Fun</td></tr> + 3. <%= t('.have_fun') %></td></tr> <tr><td> <table style="padding: 0pt 20px; background: rgb(255, 255, 255) none repeat scroll 0%; font-size: 16px; color: rgb(51, 51, 51); -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;" align="center" border="0" cellpadding="0" cellspacing="0" width="600"> <tbody><tr> @@ -123,11 +123,8 @@ <a href="<%= accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank"><img style="border: 0pt none ; padding: 0pt 5px; display: block;" src="http://joindiaspora.com/images/cubbies_screenshot2.png" height="151" width="200"></a> </td> <td style="line-height: 20px; width: 360px;"> - <strong>DIASPORA*</strong> is all about discovering amazing new content and people online. - - <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="https://cubbi.es" target="_blank">Cubbi.es</a>, - the world's first <strong>DIASPORA*</strong> application is just the begining. - Collect and share the web in all of its glory. + + <%= t('.have_fun_paragraph', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :link => link_to(t('.cubbies'), "https://cubbi.es", :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank")).html_safe %> <!-- <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="#" target="_blank">Watch all the bumpers</a>--> </td> </tr> @@ -139,7 +136,7 @@ <tbody> <tr> <td style="padding: 40px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> - <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;" href="<%=accept_invitation_url(@resource, :invitation_token => @resource.invitation_token)%>" target="_blank">Sign up now →</a> + <%= link_to(t('.sign_up_now').html_safe, accept_invitation_url(@resource, :invitation_token => @resource.invitation_token), :style => "color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 20px;", :target => "_blank").html_safe %> </td> </tr> </tbody> @@ -151,9 +148,8 @@ <tbody> <tr> <td style="padding: 20px 20px 0px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> - <strong>DIASPORA*</strong> is made by people who love the Internet as much as you do. - <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;" href="https://github.com/diaspora/diaspora/wiki/Become-a-Contributor" target="_blank">Join our team</a>, or - <a style="color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;" href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU" target="_blank">help fund Diaspora</a>! + <%= t('.made_by_people', :strong_diaspora => content_tag(:strong, "DIASPORA*"), :jointeam => link_to(t('.join_team'), "https://github.com/diaspora/diaspora/wiki/Become-a-Contributor", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank"), :helpfund => link_to(t('.help_fund'), "https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=QG4L6VYD8YGPU", :style =>"color: #3F8FBA; text-decoration: underline; font-weight: bold; font-size: 18px;", :target => "_blank")).html_safe %> + </td> </tr> </tbody> @@ -161,12 +157,14 @@ </td></tr> <tr><td style="padding: 35px 20px 20px; background: rgb(255, 255, 255) none repeat scroll 0%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"> - Love,<br> - Team Diaspora<br> + <%= t('.love') %><br> + <%= t('.team_diaspora') %><br> </td></tr> <tr><td style="padding: 35px 40px; font-size: 11px; color: rgb(102, 102, 102); line-height: 16px;"> - To unsubscribe please click <a style="color: #3F8FBA; text-decoration: none;" href="http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b">here</a>. - For general inquiries or support with your Diaspora account, please email us at <a style="color: #3F8FBA; text-decoration: none;" href="mailto:questions@joindiaspora.com">questions@joindiaspora.com</a>. + <% if AppConfig[:pod_uri].host.match(/joindiaspora.com/) %> + <%= t('.unsubscribe', :link => link_to(t('.here'), "http://joindiaspora.us1.list-manage.com/unsubscribe?u=d759919b94f9cdcf39d204f3f&id=7b5ceb2f8b", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> + <% end %> + <%= t('.email_us', :email => link_to(t('.email_address'), "mailto:questions@joindiaspora.com", :style => "color: #3F8FBA; text-decoration: none;")).html_safe %> </td></tr> </tbody> </table> diff --git a/app/views/invitations/new.html.haml b/app/views/invitations/new.html.haml index 82abcf8554b2302e22bd3425cd5a2addcd66a3eb..2a55bf40c5e6981297e788a9b5e7b38e063cc372 100644 --- a/app/views/invitations/new.html.haml +++ b/app/views/invitations/new.html.haml @@ -23,6 +23,13 @@ %br %br + %h4 + = t('.language') + = invite.select(:language, available_language_options, :selected => current_user.language) + + %br + %br + %h4 = t('.personal_message') = invite.text_area :invite_messages, :rows => 3, :value => "" diff --git a/config/locales/devise/devise.en.yml b/config/locales/devise/devise.en.yml index fcca12c356a0f5d022a7b7fbbfa7e5c7b25082c2..83ad2a20a4757085f6cc1c02906ff0b31c961ea7 100644 --- a/config/locales/devise/devise.en.yml +++ b/config/locales/devise/devise.en.yml @@ -73,6 +73,30 @@ en: click_to_unlock: "Click the link below to unlock your account:" unlock: "Unlock my account" invitation_instructions: + displaying_correctly: "Email not displaying correctly? %{link} in your browser" + view_in: "View in" + finally: "Finally - it's here" + arrived: "The social network you have been waiting for has arrived. Revamped, more secure, and more fun, %{strong_diaspora} is ready to help you share and explore the web in a whole new way." + sign_up_now: "Sign up now →" + friends_saying: "What your friends are saying..." + more_people: "Even more people are excited to see you!" + get_connected: "Get Connected" + get_connected_paragraph: "An international movement with a shared vision for a better web, %{strong_diaspora}'s #1 feature is its community. Meet new people, connect with friends, and join the fun." + be_yourself: "Be Yourself" + be_yourself_paragraph: "The Internet has created unique new ways for us to express ourselves. %{strong_diaspora} lets you be yourself and share however you want, with or without your real name." + have_fun: "Have Fun" + cubbies: "Cubbi.es" + have_fun_paragraph: "%{strong_diaspora} is all about discovering amazing new content and people online. %{link}, the world's first %{strong_diaspora} application is just the begining. Collect and share the web in all of its glory." + made_by_people: "%{strong_diaspora} is made by people who love the Internet as much as you do. %{jointeam}, or %{helpfund}!" + join_team: "Join our Team" + or: "or" + help_fund: "help fund Diaspora" + unsubscribe: "To unsubscribe please click %{link}." + here: "here" + love: "Love," + team_diaspora: "Team Diaspora" + email_us: "For general inquiries or support with your Diaspora account, please email us at %{email}." + email_address: "questions@joindiaspora.com" subject: "You've been invited to join Diaspora!" accept: "Accept invitation" ignore: "If you don't want to accept the invitation, please ignore this email." diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml index 3d3728fef3d4f5f89fbe622835e11a9137561611..bd915ca2f9ac28f9f1cb4e3cb5bf5282ff9e8d5b 100644 --- a/config/locales/diaspora/en.yml +++ b/config/locales/diaspora/en.yml @@ -318,6 +318,7 @@ en: already_contacts: "You are already connected with this person" own_address: "You can't send an invitation to your own address." new: + language: "Language" invite_someone_to_join: "Invite someone to join Diaspora!" if_they_accept_info: "if they accept, they will be added to the aspect you invited them." comma_seperated_plz: "You can enter multiple email addresses separated by commas." diff --git a/db/migrate/20111016145626_add_language_to_invitations.rb b/db/migrate/20111016145626_add_language_to_invitations.rb new file mode 100644 index 0000000000000000000000000000000000000000..4f9129f40cd06d43b2150720bf4bf189ff490e63 --- /dev/null +++ b/db/migrate/20111016145626_add_language_to_invitations.rb @@ -0,0 +1,9 @@ +class AddLanguageToInvitations < ActiveRecord::Migration + def self.up + add_column :invitations, :language, :string, :default => "en" + end + + def self.down + remove_column :invitations, :language + end +end diff --git a/spec/models/invitation_spec.rb b/spec/models/invitation_spec.rb index 11c2cc82d1be735092f2b6114326b04ec1ef8a7e..8837700f7dcb635ff440551ee0b755b2298e40c0 100644 --- a/spec/models/invitation_spec.rb +++ b/spec/models/invitation_spec.rb @@ -13,13 +13,14 @@ describe Invitation do end describe 'validations' do before do - @invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first) + @invitation = Factory.build(:invitation, :sender => user, :recipient => nil, :aspect => user.aspects.first, :language => "de") end it 'is valid' do @invitation.sender.should == user @invitation.recipient.should == nil @invitation.aspect.should == user.aspects.first + @invitation.language.should == "de" @invitation.should be_valid end @@ -29,20 +30,30 @@ describe Invitation do end end + describe '#language' do + it 'returns the correct language if the language is set' do + @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => "de") + @invitation.language.should == "de" + end + + it 'returns en if no language is set' do + @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) + @invitation.language.should == "en" + end + end + it 'has a message' do - @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first) + @invitation = Factory.build(:invitation, :sender => user, :recipient => eve, :aspect => user.aspects.first, :language => user.language) @invitation.message = "!" @invitation.message.should == "!" end - - describe 'the invite process' do before do end it 'works for a new user' do - invite = Invitation.new(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'foo@bar.com') + invite = Invitation.new(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'foo@bar.com', :language => alice.language) lambda { invite.save invite.send! @@ -50,7 +61,7 @@ describe Invitation do end it 'works for a current user(with the right email)' do - invite = Invitation.create(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => bob.email) + invite = Invitation.create(:sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => bob.email, :language => alice.language) lambda { invite.send! }.should_not change(User, :count) @@ -80,7 +91,7 @@ describe Invitation do describe '.batch_invite' do before do @emails = ['max@foo.com', 'bob@mom.com'] - @opts = {:aspect => eve.aspects.first, :sender => eve, :service => 'email'} + @opts = {:aspect => eve.aspects.first, :sender => eve, :service => 'email', :language => eve.language} end it 'returns an array of invites based on the emails passed in' do @@ -102,7 +113,7 @@ describe Invitation do describe 'send' do before do - @invitation = Factory(:invitation, :sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'a@a.com') + @invitation = Factory(:invitation, :sender => alice, :aspect => alice.aspects.first, :service => 'email', :identifier => 'a@a.com' , :language => alice.language) end it 'sends an email' do @@ -133,7 +144,7 @@ describe Invitation do describe '#recipient_identifier' do it 'calls email if the invitation_service is email' do email = 'abc@abc.com' - invitation = Factory(:invitation, :sender => alice, :service => 'email', :identifier => email, :aspect => alice.aspects.first) + invitation = Factory(:invitation, :sender => alice, :service => 'email', :identifier => email, :aspect => alice.aspects.first, :language => alice.language) invitation.recipient_identifier.should == email end