i18n_action_mailer 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /rdoc/*
2
+ /pkg/*
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Bert Goethals
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,28 @@
1
+ I18nActionMailer
2
+ ================
3
+
4
+ This plugin will allow ActionMailer to use the I18n library without affecting the controllers language.
5
+
6
+ Rails currently saves the locale in a thread. When you want to send an email in a different language, this value is used.
7
+ When the ActionMailer changes the locale, the controller will be affected.
8
+
9
+ This library lets
10
+ * the ActionMailer save it's own locale
11
+ * provide translation and localisation functions for the mailer
12
+ * override the ActionView translation methods to use the ActionMailer's locale
13
+
14
+ Example
15
+ =======
16
+
17
+ class Mailer < ActionMailer::Base
18
+
19
+ def greet_user(user)
20
+ set_locale user.locale
21
+ subject t('mailer.greet_user.title')
22
+ recipients user.email
23
+ body :user => user
24
+ end
25
+
26
+ end
27
+
28
+ Copyright (c) 2009 Bert Goethals (@bertgoethals), released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,39 @@
1
+ require "rubygems"
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gemspec|
7
+ gemspec.name = "i18n_action_mailer"
8
+ gemspec.summary = "Action mailer with i18n options"
9
+ gemspec.description = "ActionMailer to use the I18n library without affecting the controllers language"
10
+ gemspec.email = "matsumura.aki@gmail.com"
11
+ gemspec.homepage = "http://github.com/mataki/i18n_action_mailer"
12
+ gemspec.authors = ["Akihiro Matsumura", "Bert Goethals"]
13
+ end
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: gem install jeweler"
17
+ end
18
+
19
+ desc 'Default: run unit tests.'
20
+ task :default => :test
21
+
22
+ require 'rake/testtask'
23
+ desc 'Test the i18n_action_mailer plugin.'
24
+ Rake::TestTask.new(:test) do |t|
25
+ t.libs << 'lib'
26
+ t.libs << 'test'
27
+ t.pattern = 'test/**/*_test.rb'
28
+ t.verbose = true
29
+ end
30
+
31
+ require 'rake/rdoctask'
32
+ desc 'Generate documentation for the i18n_action_mailer plugin.'
33
+ Rake::RDocTask.new(:rdoc) do |rdoc|
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = 'I18nActionMailer'
36
+ rdoc.options << '--line-numbers' << '--inline-source'
37
+ rdoc.rdoc_files.include('README')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
@@ -0,0 +1,54 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{i18n_action_mailer}
8
+ s.version = "0.2.0"
9
+
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-08-06}
13
+ s.description = %q{ActionMailer to use the I18n library without affecting the controllers language}
14
+ s.email = %q{matsumura.aki@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "MIT-LICENSE",
21
+ "README",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "i18n_action_mailer.gemspec",
25
+ "init.rb",
26
+ "install.rb",
27
+ "lib/i18n_action_mailer.rb",
28
+ "rails/init.rb",
29
+ "tasks/i18n_action_mailer_tasks.rake",
30
+ "test/i18n_action_mailer_test.rb",
31
+ "test/test_helper.rb",
32
+ "uninstall.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/mataki/i18n_action_mailer}
35
+ s.rdoc_options = ["--charset=UTF-8"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.3.6}
38
+ s.summary = %q{Action mailer with i18n options}
39
+ s.test_files = [
40
+ "test/i18n_action_mailer_test.rb",
41
+ "test/test_helper.rb"
42
+ ]
43
+
44
+ if s.respond_to? :specification_version then
45
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
46
+ s.specification_version = 3
47
+
48
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
49
+ else
50
+ end
51
+ else
52
+ end
53
+ end
54
+
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require File.dirname(__FILE__) + "/rails/init.rb"
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,36 @@
1
+ module I18nActionMailer
2
+
3
+ def self.included(base)
4
+ base.send :include, I18nActionMailer::InstanceMethods
5
+ base.send :alias_method_chain, :render_message, :i18n
6
+ base.helper_method :locale, :t, :translate, :l, :localize
7
+ end
8
+
9
+ module InstanceMethods
10
+ def translate(key, options = {})
11
+ I18n.translate(key, options.merge(:locale => self.locale))
12
+ end
13
+ alias_method :t, :translate
14
+
15
+ def localize(key, options = {})
16
+ I18n.localize(key, options.merge(:locale => self.locale))
17
+ end
18
+ alias_method :l, :localize
19
+
20
+ def locale
21
+ @locale
22
+ end
23
+
24
+ def set_locale(locale)
25
+ @locale = locale
26
+ end
27
+
28
+ def render_message_with_i18n(method_name, body)
29
+ method_name = "#{method_name}.#{locale}" if locale and !Dir["#{template_path}/#{method_name}.#{locale}*"].empty?
30
+ render_message_without_i18n(method_name, body)
31
+ end
32
+ end
33
+
34
+ end
35
+
36
+ ActionMailer::Base.send(:include, I18nActionMailer)
data/rails/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'i18n_action_mailer'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :i18n_action_mailer do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class I18nActionMailerTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
data/uninstall.rb ADDED
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,77 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n_action_mailer
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
10
+ platform: ruby
11
+ authors:
12
+ - Akihiro Matsumura
13
+ - Bert Goethals
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-08-06 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: ActionMailer to use the I18n library without affecting the controllers language
23
+ email: matsumura.aki@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README
30
+ files:
31
+ - .gitignore
32
+ - MIT-LICENSE
33
+ - README
34
+ - Rakefile
35
+ - VERSION
36
+ - i18n_action_mailer.gemspec
37
+ - init.rb
38
+ - install.rb
39
+ - lib/i18n_action_mailer.rb
40
+ - rails/init.rb
41
+ - tasks/i18n_action_mailer_tasks.rake
42
+ - test/i18n_action_mailer_test.rb
43
+ - test/test_helper.rb
44
+ - uninstall.rb
45
+ has_rdoc: true
46
+ homepage: http://github.com/mataki/i18n_action_mailer
47
+ licenses: []
48
+
49
+ post_install_message:
50
+ rdoc_options:
51
+ - --charset=UTF-8
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ segments:
66
+ - 0
67
+ version: "0"
68
+ requirements: []
69
+
70
+ rubyforge_project:
71
+ rubygems_version: 1.3.6
72
+ signing_key:
73
+ specification_version: 3
74
+ summary: Action mailer with i18n options
75
+ test_files:
76
+ - test/i18n_action_mailer_test.rb
77
+ - test/test_helper.rb