gettext_i18n_rails 0.4.5 → 0.4.6
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/Readme.md +1 -1
- data/VERSION +1 -1
- data/gettext_i18n_rails.gemspec +3 -2
- data/lib/gettext_i18n_rails/base_parser.rb +41 -0
- data/lib/gettext_i18n_rails/haml_parser.rb +7 -35
- data/lib/gettext_i18n_rails/hamlet_parser.rb +6 -28
- data/lib/gettext_i18n_rails/slim_parser.rb +6 -28
- data/spec/gettext_i18n_rails/haml_parser_spec.rb +8 -1
- metadata +6 -5
data/Readme.md
CHANGED
@@ -28,7 +28,7 @@ Setup
|
|
28
28
|
|
29
29
|
##### Optional:
|
30
30
|
Add `gettext` if you want to find translations or build .mo files<br/>
|
31
|
-
Add `ruby_parser` if you want to find translations inside haml files
|
31
|
+
Add `ruby_parser` if you want to find translations inside haml/slim/hamlet files (does not support ruby 1.9 syntax)
|
32
32
|
|
33
33
|
|
34
34
|
# Gemfile
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.6
|
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.6"
|
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-04-05"
|
13
13
|
s.email = "grosser.michael@gmail.com"
|
14
14
|
s.files = [
|
15
15
|
"Gemfile",
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
"lib/gettext_i18n_rails/action_controller.rb",
|
24
24
|
"lib/gettext_i18n_rails/active_record.rb",
|
25
25
|
"lib/gettext_i18n_rails/backend.rb",
|
26
|
+
"lib/gettext_i18n_rails/base_parser.rb",
|
26
27
|
"lib/gettext_i18n_rails/haml_parser.rb",
|
27
28
|
"lib/gettext_i18n_rails/hamlet_parser.rb",
|
28
29
|
"lib/gettext_i18n_rails/html_safe_translations.rb",
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'gettext/utils'
|
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
|
+
class BaseParser
|
10
|
+
def self.target?(file)
|
11
|
+
File.extname(file) == ".#{extension}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.parse(file, msgids = [])
|
15
|
+
return msgids unless load_library
|
16
|
+
code = convert_to_code(File.read(file))
|
17
|
+
RubyGettextExtractor.parse_string(code, file, msgids)
|
18
|
+
rescue Racc::ParseError => e
|
19
|
+
$stderr.puts "file ignored: ruby_parser cannot read #{extension} files with 1.9 syntax --- (#{e.message})"
|
20
|
+
return msgids
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.load_library
|
24
|
+
return true if @library_loaded
|
25
|
+
|
26
|
+
begin
|
27
|
+
require "#{::Rails.root.to_s}/vendor/plugins/#{extension}/lib/#{extension}"
|
28
|
+
rescue LoadError
|
29
|
+
begin
|
30
|
+
require extension # From gem
|
31
|
+
rescue LoadError
|
32
|
+
puts "A #{extension} file was found, but #{extension} library could not be found, so nothing will be parsed..."
|
33
|
+
return false
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
require 'gettext_i18n_rails/ruby_gettext_extractor'
|
38
|
+
@library_loaded = true
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -1,43 +1,15 @@
|
|
1
|
-
require '
|
2
|
-
begin
|
3
|
-
require 'gettext/tools/rgettext'
|
4
|
-
rescue LoadError #version prior to 2.0
|
5
|
-
require 'gettext/rgettext'
|
6
|
-
end
|
1
|
+
require 'gettext_i18n_rails/base_parser'
|
7
2
|
|
8
3
|
module GettextI18nRails
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def target?(file)
|
13
|
-
File.extname(file) == '.haml'
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse(file, msgids = [])
|
17
|
-
return msgids unless prepare_haml_parsing
|
18
|
-
text = File.read(file)
|
19
|
-
code = Haml::Engine.new(text).precompiled()
|
20
|
-
RubyGettextExtractor.parse_string(code, file, msgids)
|
4
|
+
class HamlParser < BaseParser
|
5
|
+
def self.extension
|
6
|
+
"haml"
|
21
7
|
end
|
22
8
|
|
23
|
-
def
|
24
|
-
|
25
|
-
|
26
|
-
begin
|
27
|
-
require "#{::Rails.root.to_s}/vendor/plugins/haml/lib/haml"
|
28
|
-
rescue LoadError
|
29
|
-
begin
|
30
|
-
require 'haml' # From gem
|
31
|
-
rescue LoadError
|
32
|
-
puts "A haml file was found, but haml library could not be found, so nothing will be parsed..."
|
33
|
-
return false
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
require 'gettext_i18n_rails/ruby_gettext_extractor'
|
38
|
-
@haml_loaded = true
|
9
|
+
def self.convert_to_code(text)
|
10
|
+
Haml::Engine.new(text).precompiled()
|
39
11
|
end
|
40
12
|
end
|
41
13
|
end
|
42
14
|
|
43
|
-
GetText::RGetText.add_parser(GettextI18nRails::HamlParser)
|
15
|
+
GetText::RGetText.add_parser(GettextI18nRails::HamlParser)
|
@@ -1,35 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
begin
|
3
|
-
require 'gettext/tools/rgettext'
|
4
|
-
rescue LoadError #version prior to 2.0
|
5
|
-
require 'gettext/rgettext'
|
6
|
-
end
|
1
|
+
require 'gettext_i18n_rails/base_parser'
|
7
2
|
|
8
3
|
module GettextI18nRails
|
9
|
-
|
10
|
-
|
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)
|
4
|
+
class HamletParser < BaseParser
|
5
|
+
def self.extension
|
6
|
+
"hamlet"
|
21
7
|
end
|
22
8
|
|
23
|
-
def
|
24
|
-
|
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
|
9
|
+
def self.convert_to_code(text)
|
10
|
+
Hamlet::Engine.new.call(text)
|
33
11
|
end
|
34
12
|
end
|
35
13
|
end
|
@@ -1,35 +1,13 @@
|
|
1
|
-
require '
|
2
|
-
begin
|
3
|
-
require 'gettext/tools/rgettext'
|
4
|
-
rescue LoadError #version prior to 2.0
|
5
|
-
require 'gettext/rgettext'
|
6
|
-
end
|
1
|
+
require 'gettext_i18n_rails/base_parser'
|
7
2
|
|
8
3
|
module GettextI18nRails
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
def target?(file)
|
13
|
-
File.extname(file) == '.slim'
|
14
|
-
end
|
15
|
-
|
16
|
-
def parse(file, msgids = [])
|
17
|
-
return msgids unless prepare_slim_parsing
|
18
|
-
text = File.read(file)
|
19
|
-
code = Slim::Engine.new.call(text)
|
20
|
-
RubyGettextExtractor.parse_string(code, file, msgids)
|
4
|
+
class SlimParser < BaseParser
|
5
|
+
def self.extension
|
6
|
+
"slim"
|
21
7
|
end
|
22
8
|
|
23
|
-
def
|
24
|
-
|
25
|
-
begin
|
26
|
-
require 'slim'
|
27
|
-
rescue LoadError
|
28
|
-
puts "A slim file was found, but slim library could not be found, so nothing will be parsed..."
|
29
|
-
return false
|
30
|
-
end
|
31
|
-
require 'gettext_i18n_rails/ruby_gettext_extractor'
|
32
|
-
@slim_loaded = true
|
9
|
+
def self.convert_to_code(text)
|
10
|
+
Slim::Engine.new.call(text)
|
33
11
|
end
|
34
12
|
end
|
35
13
|
end
|
@@ -23,10 +23,17 @@ describe GettextI18nRails::HamlParser do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
it "ignores 1.9 errors" do
|
27
|
+
with_file '= _("xxxx", x: 1)' do |path|
|
28
|
+
$stderr.should_receive(:puts).with{|x| x =~ /file ignored/ }
|
29
|
+
parser.parse(path, [1]).should == [1]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
26
33
|
it "does not find messages in text" do
|
27
34
|
with_file '_("xxxx")' do |path|
|
28
35
|
parser.parse(path, []).should == []
|
29
36
|
end
|
30
37
|
end
|
31
38
|
end
|
32
|
-
end
|
39
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gettext_i18n_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fast_gettext
|
16
|
-
requirement: &
|
16
|
+
requirement: &13650380 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *13650380
|
25
25
|
description:
|
26
26
|
email: grosser.michael@gmail.com
|
27
27
|
executables: []
|
@@ -39,6 +39,7 @@ files:
|
|
39
39
|
- lib/gettext_i18n_rails/action_controller.rb
|
40
40
|
- lib/gettext_i18n_rails/active_record.rb
|
41
41
|
- lib/gettext_i18n_rails/backend.rb
|
42
|
+
- lib/gettext_i18n_rails/base_parser.rb
|
42
43
|
- lib/gettext_i18n_rails/haml_parser.rb
|
43
44
|
- lib/gettext_i18n_rails/hamlet_parser.rb
|
44
45
|
- lib/gettext_i18n_rails/html_safe_translations.rb
|
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
segments:
|
75
76
|
- 0
|
76
|
-
hash:
|
77
|
+
hash: 846699544332952376
|
77
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
79
|
none: false
|
79
80
|
requirements:
|