gettext_i18n_rails 0.4.3 → 0.4.4
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/Gemfile +1 -0
- data/Gemfile.lock +3 -0
- data/VERSION +1 -1
- data/gettext_i18n_rails.gemspec +4 -2
- data/lib/gettext_i18n_rails/hamlet_parser.rb +38 -0
- data/lib/gettext_i18n_rails/tasks.rb +1 -0
- data/spec/gettext_i18n_rails/hamlet_parser_spec.rb +33 -0
- data/spec/gettext_i18n_rails/slim_parser_spec.rb +9 -1
- metadata +32 -49
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -40,6 +40,8 @@ GEM
|
|
40
40
|
locale (>= 2.0.5)
|
41
41
|
git (1.2.5)
|
42
42
|
haml (3.1.4)
|
43
|
+
hamlet (0.1)
|
44
|
+
slim (~> 1.0)
|
43
45
|
hike (1.2.1)
|
44
46
|
i18n (0.6.0)
|
45
47
|
jeweler (1.6.4)
|
@@ -114,6 +116,7 @@ DEPENDENCIES
|
|
114
116
|
fast_gettext
|
115
117
|
gettext
|
116
118
|
haml
|
119
|
+
hamlet
|
117
120
|
jeweler
|
118
121
|
rails (~> 3)
|
119
122
|
rake
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.4
|
data/gettext_i18n_rails.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "gettext_i18n_rails"
|
8
|
-
s.version = "0.4.
|
8
|
+
s.version = "0.4.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Michael Grosser"]
|
12
|
-
s.date = "2012-
|
12
|
+
s.date = "2012-03-10"
|
13
13
|
s.email = "grosser.michael@gmail.com"
|
14
14
|
s.files = [
|
15
15
|
"Gemfile",
|
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
|
|
24
24
|
"lib/gettext_i18n_rails/active_record.rb",
|
25
25
|
"lib/gettext_i18n_rails/backend.rb",
|
26
26
|
"lib/gettext_i18n_rails/haml_parser.rb",
|
27
|
+
"lib/gettext_i18n_rails/hamlet_parser.rb",
|
27
28
|
"lib/gettext_i18n_rails/html_safe_translations.rb",
|
28
29
|
"lib/gettext_i18n_rails/i18n_hacks.rb",
|
29
30
|
"lib/gettext_i18n_rails/model_attributes_finder.rb",
|
@@ -37,6 +38,7 @@ Gem::Specification.new do |s|
|
|
37
38
|
"spec/gettext_i18n_rails/active_record_spec.rb",
|
38
39
|
"spec/gettext_i18n_rails/backend_spec.rb",
|
39
40
|
"spec/gettext_i18n_rails/haml_parser_spec.rb",
|
41
|
+
"spec/gettext_i18n_rails/hamlet_parser_spec.rb",
|
40
42
|
"spec/gettext_i18n_rails/slim_parser_spec.rb",
|
41
43
|
"spec/gettext_i18n_rails/string_interpolate_fix_spec.rb",
|
42
44
|
"spec/gettext_i18n_rails_spec.rb",
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'gettext/tools'
|
2
|
+
begin
|
3
|
+
require 'gettext/tools/rgettext'
|
4
|
+
rescue LoadError #version prior to 2.0
|
5
|
+
require 'gettext/rgettext'
|
6
|
+
end
|
7
|
+
|
8
|
+
module GettextI18nRails
|
9
|
+
module HamletParser
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def target?(file)
|
13
|
+
File.extname(file) == '.hamlet'
|
14
|
+
end
|
15
|
+
|
16
|
+
def parse(file, msgids = [])
|
17
|
+
return msgids unless prepare_hamlet_parsing
|
18
|
+
text = File.read(file)
|
19
|
+
code = Hamlet::Engine.new.call(text)
|
20
|
+
RubyGettextExtractor.parse_string(code, file, msgids)
|
21
|
+
end
|
22
|
+
|
23
|
+
def prepare_hamlet_parsing
|
24
|
+
return true if @hamlet_loaded
|
25
|
+
begin
|
26
|
+
require 'hamlet'
|
27
|
+
rescue LoadError
|
28
|
+
puts "A hamlet file was found, but hamlet library could not be found, so nothing will be parsed..."
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
require 'gettext_i18n_rails/ruby_gettext_extractor'
|
32
|
+
@hamlet_loaded = true
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
GetText::RGetText.add_parser(GettextI18nRails::HamletParser)
|
38
|
+
|
@@ -16,6 +16,7 @@ namespace :gettext do
|
|
16
16
|
$LOAD_PATH << File.join(File.dirname(__FILE__),'..','..','lib')
|
17
17
|
require 'gettext_i18n_rails/haml_parser'
|
18
18
|
require 'gettext_i18n_rails/slim_parser'
|
19
|
+
require 'gettext_i18n_rails/hamlet_parser'
|
19
20
|
|
20
21
|
|
21
22
|
if GetText.respond_to? :update_pofiles_org
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "gettext_i18n_rails/hamlet_parser"
|
3
|
+
|
4
|
+
describe GettextI18nRails::HamletParser do
|
5
|
+
let(:parser){ GettextI18nRails::HamletParser }
|
6
|
+
|
7
|
+
describe "#target?" do
|
8
|
+
it "targets .hamlet" do
|
9
|
+
parser.target?('foo/bar/xxx.hamlet').should == true
|
10
|
+
end
|
11
|
+
|
12
|
+
it "does not target anything else" do
|
13
|
+
parser.target?('foo/bar/xxx.erb').should == false
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#parse" do
|
18
|
+
it "finds messages in slim" do
|
19
|
+
with_file '<div>= _("xxxx")' do |path|
|
20
|
+
parser.parse(path, []).should == [
|
21
|
+
["xxxx", "#{path}:1"]
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
it "does not find messages in text" do
|
27
|
+
with_file '<div> _("xxxx")' do |path|
|
28
|
+
parser.parse(path, []).should == []
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
@@ -23,10 +23,18 @@ describe GettextI18nRails::SlimParser do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
xit "can parse 1.9 syntax" do
|
27
|
+
with_file 'div = _("xxxx", foo: :bar)' do |path|
|
28
|
+
parser.parse(path, []).should == [
|
29
|
+
["xxxx", "#{path}:1"]
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
26
34
|
it "does not find messages in text" do
|
27
35
|
with_file 'div _("xxxx")' do |path|
|
28
36
|
parser.parse(path, []).should == []
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
32
|
-
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,45 +1,33 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext_i18n_rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.4
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
- 3
|
10
|
-
version: 0.4.3
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Michael Grosser
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
prerelease: false
|
22
|
-
type: :runtime
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
hash: 3
|
29
|
-
segments:
|
30
|
-
- 0
|
31
|
-
version: "0"
|
12
|
+
date: 2012-03-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
32
15
|
name: fast_gettext
|
33
|
-
|
16
|
+
requirement: &20283380 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *20283380
|
34
25
|
description:
|
35
26
|
email: grosser.michael@gmail.com
|
36
27
|
executables: []
|
37
|
-
|
38
28
|
extensions: []
|
39
|
-
|
40
29
|
extra_rdoc_files: []
|
41
|
-
|
42
|
-
files:
|
30
|
+
files:
|
43
31
|
- Gemfile
|
44
32
|
- Gemfile.lock
|
45
33
|
- Rakefile
|
@@ -52,6 +40,7 @@ files:
|
|
52
40
|
- lib/gettext_i18n_rails/active_record.rb
|
53
41
|
- lib/gettext_i18n_rails/backend.rb
|
54
42
|
- lib/gettext_i18n_rails/haml_parser.rb
|
43
|
+
- lib/gettext_i18n_rails/hamlet_parser.rb
|
55
44
|
- lib/gettext_i18n_rails/html_safe_translations.rb
|
56
45
|
- lib/gettext_i18n_rails/i18n_hacks.rb
|
57
46
|
- lib/gettext_i18n_rails/model_attributes_finder.rb
|
@@ -65,42 +54,36 @@ files:
|
|
65
54
|
- spec/gettext_i18n_rails/active_record_spec.rb
|
66
55
|
- spec/gettext_i18n_rails/backend_spec.rb
|
67
56
|
- spec/gettext_i18n_rails/haml_parser_spec.rb
|
57
|
+
- spec/gettext_i18n_rails/hamlet_parser_spec.rb
|
68
58
|
- spec/gettext_i18n_rails/slim_parser_spec.rb
|
69
59
|
- spec/gettext_i18n_rails/string_interpolate_fix_spec.rb
|
70
60
|
- spec/gettext_i18n_rails_spec.rb
|
71
61
|
- spec/spec_helper.rb
|
72
62
|
homepage: http://github.com/grosser/gettext_i18n_rails
|
73
63
|
licenses: []
|
74
|
-
|
75
64
|
post_install_message:
|
76
65
|
rdoc_options: []
|
77
|
-
|
78
|
-
require_paths:
|
66
|
+
require_paths:
|
79
67
|
- lib
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
69
|
none: false
|
82
|
-
requirements:
|
83
|
-
- -
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
|
86
|
-
segments:
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
segments:
|
87
75
|
- 0
|
88
|
-
|
89
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
hash: -3876065388999349156
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
78
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
98
83
|
requirements: []
|
99
|
-
|
100
84
|
rubyforge_project:
|
101
85
|
rubygems_version: 1.8.15
|
102
86
|
signing_key:
|
103
87
|
specification_version: 3
|
104
88
|
summary: Simple FastGettext Rails integration.
|
105
89
|
test_files: []
|
106
|
-
|