-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
66 lines (40 loc) · 1.24 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
I came across the need to have actionmailer send out localized versions of e-mails, so I made the necessary changes to make this work for me...
I was using version 2.3.2 of Rails.
Herman verschooten
Example:
class Notification < ActionMailer::Base
def user_created(from, user)
@locale = 'en'
@from = from
@recipients = user.email
@bcc = "[email protected]"
@subject = t("user_created_email")
@body[:user] = user
end
end
given that a .yml under config/locales/ contains:
:nl
user_created_email: "Uw nieuwe gebruiker werd aangemaakt!"
:en
user_created_email: "Your new account was created!"
and
app/views/notification contains:
user_created_en.html.erb
Dear <%= @user.name %>,
Your account has been created.
You can sign in with:
Login: <%= @user.login %>
Password: <%= @user.password %>
Sincerely,
The team
user_created.html.erb
Geachte <%= @user.name %>,
Je account werd aangemaakt.
Je kan vanaf nu aanmelden met volgende gegevens:
Gebruiker: <%= @user.login %>
Paswoord: <%= @user.password %>
Met vriendelijke groeten,
Het Team
Then when the locale is set to 'en' as in the above example,
the recipient will receive the enlish e-mail, all others
will receive the dutch e-mail.