Class: ActionMailer::Base

Inherits:
Object
  • Object
show all
Includes:
GetText
Defined in:
lib/gettext_rails/action_mailer.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods included from GetText

#create_mofiles, #create_mofiles_org

Instance Method Details

#base64(text, charset = "iso-2022-jp", convert = true) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/gettext_rails/action_mailer.rb', line 19

def base64(text, charset="iso-2022-jp", convert=true)
	if convert
	  if charset == "iso-2022-jp"
	    text = NKF.nkf('-j -m0', text)
    end
	end
	text = TMail::Base64.folding_encode(text)
	"=?#{charset}?B?#{text}?="
end

#create_with_gettext!(*arg) ⇒ Object

:nodoc:



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/gettext_rails/action_mailer.rb', line 29

def create_with_gettext!(*arg) #:nodoc:
	create_without_gettext!(*arg)
	if Locale.get.language == "ja"
	  require 'nkf'
	  @mail.subject = base64(@mail.subject)
	  part = @mail.parts.empty? ? @mail : @mail.parts.first
	  if part.content_type == 'text/plain'
	    part.charset = 'iso-2022-jp'
	    part.body = NKF.nkf('-j', part.body)
	  end
	end
  @mail
end