lastobelus-merb_global 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/lib/merb_global/helpers/haml_gettext.rb +25 -0
- data/lib/merb_global/parsers/haml_parser.rb +40 -0
- metadata +5 -1
data/Rakefile
CHANGED
@@ -4,7 +4,7 @@ require 'rake/rdoctask'
|
|
4
4
|
|
5
5
|
PLUGIN = "merb_global"
|
6
6
|
NAME = "merb_global"
|
7
|
-
GEM_VERSION = "0.0.
|
7
|
+
GEM_VERSION = "0.0.11"
|
8
8
|
AUTHORS = ["Alex Coles", "Maciej Piechotka"]
|
9
9
|
EMAIL = "merb_global@googlegroups.com"
|
10
10
|
HOMEPAGE = "http://trac.ikonoklastik.com/merb_global/"
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Merb
|
2
|
+
module Global
|
3
|
+
module Helpers
|
4
|
+
module HamlGettext
|
5
|
+
# Inject _ gettext into plain text and tag plain text calls
|
6
|
+
def push_plain(text)
|
7
|
+
if text =~ /JOIN THE/
|
8
|
+
Merb.logger.debug("push plain for #{text}")
|
9
|
+
end
|
10
|
+
super(_(text.strip))
|
11
|
+
end
|
12
|
+
def parse_tag(line)
|
13
|
+
tag_name, attributes, attributes_hash, object_ref, nuke_outer_whitespace,
|
14
|
+
nuke_inner_whitespace, action, value = super(line)
|
15
|
+
value = _(value) unless action || value.empty?
|
16
|
+
[tag_name, attributes, attributes_hash, object_ref, nuke_outer_whitespace,
|
17
|
+
nuke_inner_whitespace, action, value]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
Haml::Engine.send(:include, Merb::Global::Helpers::HamlGettext)
|
25
|
+
Haml::Engine.send(:include, Merb::Global)
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# Haml gettext parser module
|
2
|
+
#
|
3
|
+
# http://pastie.org/445297
|
4
|
+
require 'gettext/tools/rgettext'
|
5
|
+
require 'gettext/parser/ruby'
|
6
|
+
require 'haml'
|
7
|
+
|
8
|
+
class Haml::Engine
|
9
|
+
# Overriden function that parses Haml tags
|
10
|
+
# Injects gettext call for plain text action.
|
11
|
+
def parse_tag(line)
|
12
|
+
tag_name, attributes, attributes_hash, object_ref, nuke_outer_whitespace,
|
13
|
+
nuke_inner_whitespace, action, value = super(line)
|
14
|
+
@precompiled << "_(\"#{value}\")\n" unless action || value.empty?
|
15
|
+
[tag_name, attributes, attributes_hash, object_ref, nuke_outer_whitespace,
|
16
|
+
nuke_inner_whitespace, action, value]
|
17
|
+
end
|
18
|
+
# Overriden function that producted Haml plain text
|
19
|
+
# Injects gettext call for plain text action.
|
20
|
+
def push_plain(text)
|
21
|
+
@precompiled << "_(\"#{text.strip}\")\n"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Haml gettext parser
|
26
|
+
module HamlParser
|
27
|
+
module_function
|
28
|
+
|
29
|
+
def target?(file)
|
30
|
+
File.extname(file) == ".haml"
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse(file, ary = [])
|
34
|
+
haml = Haml::Engine.new(IO.readlines(file).join)
|
35
|
+
code = haml.precompiled.split(/$/)
|
36
|
+
GetText::RubyParser.parse_lines(file, code, ary)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
GetText::RGetText.add_parser(HamlParser)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lastobelus-merb_global
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Coles
|
@@ -88,6 +88,8 @@ files:
|
|
88
88
|
- lib/merb_global/date_providers
|
89
89
|
- lib/merb_global/date_providers/fork.rb
|
90
90
|
- lib/merb_global/date_providers.rb
|
91
|
+
- lib/merb_global/helpers
|
92
|
+
- lib/merb_global/helpers/haml_gettext.rb
|
91
93
|
- lib/merb_global/locale.rb
|
92
94
|
- lib/merb_global/merbrake.rb
|
93
95
|
- lib/merb_global/message_providers
|
@@ -103,6 +105,8 @@ files:
|
|
103
105
|
- lib/merb_global/numeric_providers/fork.rb
|
104
106
|
- lib/merb_global/numeric_providers/java.rb
|
105
107
|
- lib/merb_global/numeric_providers.rb
|
108
|
+
- lib/merb_global/parsers
|
109
|
+
- lib/merb_global/parsers/haml_parser.rb
|
106
110
|
- lib/merb_global/plural.rb
|
107
111
|
- lib/merb_global/plural.treetop
|
108
112
|
- lib/merb_global/providers.rb
|