i18n_action_mailer 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/i18n_action_mailer.gemspec +4 -3
- data/lib/i18n_action_mailer.rb +31 -2
- metadata +5 -3
data/History.txt
ADDED
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ begin
|
|
9
9
|
gemspec.description = "ActionMailer to use the I18n library without affecting the controllers language"
|
10
10
|
gemspec.email = "matsumura.aki@gmail.com"
|
11
11
|
gemspec.homepage = "http://github.com/mataki/i18n_action_mailer"
|
12
|
-
gemspec.authors = ["Akihiro Matsumura", "Bert Goethals"]
|
12
|
+
gemspec.authors = ["Akihiro Matsumura", "Bert Goethals", "Lars Pind"]
|
13
13
|
end
|
14
14
|
Jeweler::GemcutterTasks.new
|
15
15
|
rescue LoadError
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/i18n_action_mailer.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{i18n_action_mailer}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Akihiro Matsumura", "Bert Goethals"]
|
12
|
-
s.date = %q{2010-
|
11
|
+
s.authors = ["Akihiro Matsumura", "Bert Goethals", "Lars Pind"]
|
12
|
+
s.date = %q{2010-09-21}
|
13
13
|
s.description = %q{ActionMailer to use the I18n library without affecting the controllers language}
|
14
14
|
s.email = %q{matsumura.aki@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
]
|
18
18
|
s.files = [
|
19
19
|
".gitignore",
|
20
|
+
"History.txt",
|
20
21
|
"MIT-LICENSE",
|
21
22
|
"README",
|
22
23
|
"Rakefile",
|
data/lib/i18n_action_mailer.rb
CHANGED
@@ -3,12 +3,31 @@ module I18nActionMailer
|
|
3
3
|
def self.included(base)
|
4
4
|
base.send :include, I18nActionMailer::InstanceMethods
|
5
5
|
base.send :alias_method_chain, :render_message, :i18n
|
6
|
-
base.helper_method :locale, :
|
6
|
+
base.helper_method :locale, :l, :localize
|
7
|
+
base.helper do
|
8
|
+
def translate(key, options = {})
|
9
|
+
I18n.translate(scope_key_by_partial(key), options.merge!(:raise => true, :locale => self.locale))
|
10
|
+
end
|
11
|
+
alias_method :t, :translate
|
12
|
+
|
13
|
+
private
|
14
|
+
def scope_key_by_partial(key)
|
15
|
+
if key.to_s.first == "."
|
16
|
+
if @_virtual_path
|
17
|
+
@_virtual_path.gsub(%r{/_?}, ".") + key.to_s
|
18
|
+
else
|
19
|
+
raise "Cannot use t(#{key.inspect}) shortcut because path is not available"
|
20
|
+
end
|
21
|
+
else
|
22
|
+
key
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
7
26
|
end
|
8
27
|
|
9
28
|
module InstanceMethods
|
10
29
|
def translate(key, options = {})
|
11
|
-
I18n.translate(key, options.merge(:locale => self.locale))
|
30
|
+
I18n.translate(scope_key_by_partial(key), options.merge(:raise => true, :locale => self.locale))
|
12
31
|
end
|
13
32
|
alias_method :t, :translate
|
14
33
|
|
@@ -29,6 +48,16 @@ module I18nActionMailer
|
|
29
48
|
method_name = "#{method_name}_#{locale}" if locale and !Dir["#{template_path}/#{method_name}_#{locale}*"].empty?
|
30
49
|
render_message_without_i18n(method_name, body)
|
31
50
|
end
|
51
|
+
|
52
|
+
private
|
53
|
+
def scope_key_by_partial(key)
|
54
|
+
if key.to_s.first == "."
|
55
|
+
mailer_scope = self.class.mailer_name.gsub('/', '.')
|
56
|
+
mailer_scope + "." + action_name + key.to_s
|
57
|
+
else
|
58
|
+
key
|
59
|
+
end
|
60
|
+
end
|
32
61
|
end
|
33
62
|
|
34
63
|
end
|
metadata
CHANGED
@@ -5,17 +5,18 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 2
|
9
|
+
version: 0.2.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Akihiro Matsumura
|
13
13
|
- Bert Goethals
|
14
|
+
- Lars Pind
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-
|
19
|
+
date: 2010-09-21 00:00:00 +09:00
|
19
20
|
default_executable:
|
20
21
|
dependencies: []
|
21
22
|
|
@@ -29,6 +30,7 @@ extra_rdoc_files:
|
|
29
30
|
- README
|
30
31
|
files:
|
31
32
|
- .gitignore
|
33
|
+
- History.txt
|
32
34
|
- MIT-LICENSE
|
33
35
|
- README
|
34
36
|
- Rakefile
|