rails_i18n_gettext 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "~> 3.0"
4
+
5
+ group :development do
6
+ gem "jeweler", "~> 1.8.3"
7
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,92 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ actionmailer (3.2.3)
5
+ actionpack (= 3.2.3)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.3)
8
+ activemodel (= 3.2.3)
9
+ activesupport (= 3.2.3)
10
+ builder (~> 3.0.0)
11
+ erubis (~> 2.7.0)
12
+ journey (~> 1.0.1)
13
+ rack (~> 1.4.0)
14
+ rack-cache (~> 1.2)
15
+ rack-test (~> 0.6.1)
16
+ sprockets (~> 2.1.2)
17
+ activemodel (3.2.3)
18
+ activesupport (= 3.2.3)
19
+ builder (~> 3.0.0)
20
+ activerecord (3.2.3)
21
+ activemodel (= 3.2.3)
22
+ activesupport (= 3.2.3)
23
+ arel (~> 3.0.2)
24
+ tzinfo (~> 0.3.29)
25
+ activeresource (3.2.3)
26
+ activemodel (= 3.2.3)
27
+ activesupport (= 3.2.3)
28
+ activesupport (3.2.3)
29
+ i18n (~> 0.6)
30
+ multi_json (~> 1.0)
31
+ arel (3.0.2)
32
+ builder (3.0.0)
33
+ erubis (2.7.0)
34
+ git (1.2.5)
35
+ hike (1.2.1)
36
+ i18n (0.6.0)
37
+ jeweler (1.8.3)
38
+ bundler (~> 1.0)
39
+ git (>= 1.2.5)
40
+ rake
41
+ rdoc
42
+ journey (1.0.3)
43
+ json (1.7.3)
44
+ mail (2.4.4)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.18)
49
+ multi_json (1.3.5)
50
+ polyglot (0.3.3)
51
+ rack (1.4.1)
52
+ rack-cache (1.2)
53
+ rack (>= 0.4)
54
+ rack-ssl (1.3.2)
55
+ rack
56
+ rack-test (0.6.1)
57
+ rack (>= 1.0)
58
+ rails (3.2.3)
59
+ actionmailer (= 3.2.3)
60
+ actionpack (= 3.2.3)
61
+ activerecord (= 3.2.3)
62
+ activeresource (= 3.2.3)
63
+ activesupport (= 3.2.3)
64
+ bundler (~> 1.0)
65
+ railties (= 3.2.3)
66
+ railties (3.2.3)
67
+ actionpack (= 3.2.3)
68
+ activesupport (= 3.2.3)
69
+ rack-ssl (~> 1.3.2)
70
+ rake (>= 0.8.7)
71
+ rdoc (~> 3.4)
72
+ thor (~> 0.14.6)
73
+ rake (0.9.2.2)
74
+ rdoc (3.12)
75
+ json (~> 1.4)
76
+ sprockets (2.1.3)
77
+ hike (~> 1.2)
78
+ rack (~> 1.0)
79
+ tilt (~> 1.1, != 1.3.0)
80
+ thor (0.14.6)
81
+ tilt (1.3.3)
82
+ treetop (1.4.10)
83
+ polyglot
84
+ polyglot (>= 0.3.1)
85
+ tzinfo (0.3.33)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ jeweler (~> 1.8.3)
92
+ rails (~> 3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 mcasimir
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.md ADDED
@@ -0,0 +1,34 @@
1
+ = rails_i18n_gettext
2
+
3
+ Use gettext-like `_('Just translate my damn text!')` with Rails I18n and find .yml messages to be translated across the project
4
+
5
+ ## Installation
6
+
7
+ ``` rb
8
+ # Gemfile
9
+ gem "rails_i18n_gettext"
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ``` rb
15
+ I18n._("Translate me")
16
+ ```
17
+
18
+ ### `ActionView` Helper
19
+
20
+ ``` rb
21
+ _("Translate me")
22
+ ```
23
+
24
+ ## Finding translations
25
+
26
+ ``` sh
27
+ rake gettext:find
28
+ ```
29
+
30
+ == Copyright
31
+
32
+ Copyright (c) 2012 mcasimir. See LICENSE.txt for
33
+ further details.
34
+
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "rails_i18n_gettext"
18
+ gem.homepage = "http://github.com/mcasimir/rails_i18n_gettext"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Use gettext-like `_('Just translate my damn text!')` in Rails and generate .yml translation files}
21
+ gem.description = %Q{Use gettext-like `_('Just translate my damn text!')` in Rails and generate .yml translation files}
22
+ gem.email = "maurizio.cas@gmail.com"
23
+ gem.authors = ["mcasimir"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,7 @@
1
+ module I18n
2
+ def _(string, options = {})
3
+ options[:default] = string
4
+ I18n.t(string, options)
5
+ end
6
+ module_function :_
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails_i18n_gettext/view_helpers'
2
+
3
+ module RailsI18nGettext
4
+ class Railtie < Rails::Railtie
5
+ railtie_name :rails_i18n_gettext
6
+
7
+ initializer "rails_i18n_gettext.view_helpers" do
8
+ ActionView::Base.send :include, ViewHelpers
9
+ end
10
+
11
+ rake_tasks do
12
+ load "tasks/rails_i18n_gettext.rake"
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module RailsI18nGettext
2
+ module ViewHelpers
3
+ def _(*args)
4
+ I18n._(*args)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,37 @@
1
+ # Author:: Maurizio Casimirri (mailto:maurizio.cas@gmail.com)
2
+ # Copyright:: Copyright (c) 2012 Maurizio Casimirri
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+
23
+
24
+
25
+ module RailsI18nGettext
26
+ end
27
+
28
+ require 'rails_i18n_gettext/i18n_patch'
29
+ require 'rails_i18n_gettext/railtie'
30
+
31
+ module I18n
32
+ def _(string, options = {})
33
+ options[:default] = string
34
+ I18n.t(string.downcase, options)
35
+ end
36
+ module_function :_
37
+ end
@@ -0,0 +1,40 @@
1
+ namespace :gettext do
2
+
3
+ desc "Find translations for rails_i18n_gettext"
4
+ task :find, [:scope] do |t, args|
5
+ scope = args[:scope] || ""
6
+ extnames = "rb,erb,haml,slim,rhtml,coffee"
7
+ paths = %w(app/models app/views app/controllers)
8
+ files = paths.map {|path|
9
+ Dir.glob(Rails.root.join(path, scope, "**/*.{#{extnames}}"))
10
+ }.flatten!
11
+
12
+ translations = []
13
+
14
+ files.each do |file|
15
+ File.open(file, "r") do |infile|
16
+ lines = infile.readlines
17
+
18
+ lines.each do |line|
19
+
20
+ if m = line.match(/ _\('([^']+)'\) /x)
21
+ translations << m[1]
22
+ end
23
+
24
+ if m = line.match(/ _\("([^"]+)"\) /x)
25
+ translations << m[1]
26
+ end
27
+
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+
34
+ translations.uniq|
35
+ translations.each do |translate_me|
36
+ puts "#{translate_me.inspect}: #{translate_me.inspect}"
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,57 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "rails_i18n_gettext"
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["mcasimir"]
12
+ s.date = "2012-05-14"
13
+ s.description = "Use gettext-like `_('Just translate my damn text!')` in Rails and generate .yml translation files"
14
+ s.email = "maurizio.cas@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.md",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "lib/rails_i18n_gettext.rb",
28
+ "lib/rails_i18n_gettext/i18n_patch.rb",
29
+ "lib/rails_i18n_gettext/railtie.rb",
30
+ "lib/rails_i18n_gettext/view_helpers.rb",
31
+ "lib/tasks/rails_i18n_gettext.rake",
32
+ "rails_i18n_gettext.gemspec",
33
+ "test/helper.rb",
34
+ "test/test_rails_i18n_gettext.rb"
35
+ ]
36
+ s.homepage = "http://github.com/mcasimir/rails_i18n_gettext"
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "1.8.24"
40
+ s.summary = "Use gettext-like `_('Just translate my damn text!')` in Rails and generate .yml translation files"
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 3
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_runtime_dependency(%q<rails>, ["~> 3.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
48
+ else
49
+ s.add_dependency(%q<rails>, ["~> 3.0"])
50
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
51
+ end
52
+ else
53
+ s.add_dependency(%q<rails>, ["~> 3.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
55
+ end
56
+ end
57
+
data/test/helper.rb ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
15
+ require 'rails_i18n_gettext'
16
+
17
+ class Test::Unit::TestCase
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestRailsI18nGettext < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_i18n_gettext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - mcasimir
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: jeweler
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 1.8.3
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.8.3
46
+ description: Use gettext-like `_('Just translate my damn text!')` in Rails and generate
47
+ .yml translation files
48
+ email: maurizio.cas@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files:
52
+ - LICENSE.txt
53
+ - README.md
54
+ files:
55
+ - .document
56
+ - Gemfile
57
+ - Gemfile.lock
58
+ - LICENSE.txt
59
+ - README.md
60
+ - Rakefile
61
+ - VERSION
62
+ - lib/rails_i18n_gettext.rb
63
+ - lib/rails_i18n_gettext/i18n_patch.rb
64
+ - lib/rails_i18n_gettext/railtie.rb
65
+ - lib/rails_i18n_gettext/view_helpers.rb
66
+ - lib/tasks/rails_i18n_gettext.rake
67
+ - rails_i18n_gettext.gemspec
68
+ - test/helper.rb
69
+ - test/test_rails_i18n_gettext.rb
70
+ homepage: http://github.com/mcasimir/rails_i18n_gettext
71
+ licenses:
72
+ - MIT
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ segments:
84
+ - 0
85
+ hash: -201259383311601259
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.24
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Use gettext-like `_('Just translate my damn text!')` in Rails and generate
98
+ .yml translation files
99
+ test_files: []