i18n_screwdriver 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc
CHANGED
@@ -26,6 +26,15 @@ In your views, helpers and controllers use the convenient underscore helper meth
|
|
26
26
|
|
27
27
|
_("your translation")
|
28
28
|
|
29
|
+
Variable interpolation works as for normal strings
|
30
|
+
|
31
|
+
_("Hello %{name}!") % {name: "Liah"}
|
32
|
+
|
33
|
+
For awesome support for links inside translations you can use this syntax, which uses the normal rails view/ route helpers internally
|
34
|
+
|
35
|
+
_("Please <<click here>> for more details or visit <<this link>> to continue."){ [@item, "http://continue.com"] }
|
36
|
+
_("Open this <<fancy link>> in new window or visit <<this link>> to continue."){ [[@item, target: "_blank"], "http://continue.com"] }
|
37
|
+
|
29
38
|
When you are done you have 2 helper rake tasks. The first one scans all your views, controllers and
|
30
39
|
helpers for translations. It removes unused translation strings and creates an application.<lang>.yml file
|
31
40
|
for each of your I18n.available_locales.
|
data/lib/i18n_screwdriver.rb
CHANGED
@@ -1,10 +1,30 @@
|
|
1
1
|
module I18nScrewdriver
|
2
|
-
|
3
|
-
def
|
4
|
-
I18n.translate(I18nScrewdriver.for_key(text), options)
|
2
|
+
class Translation < ActiveSupport::SafeBuffer
|
3
|
+
def self.new(text, options = {}, &block)
|
4
|
+
super(I18n.translate(I18nScrewdriver.for_key(text), options)).tap do |translation|
|
5
|
+
translation.linkify(block.binding, *block.call) if block
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def linkify(binding, *urls)
|
10
|
+
context = binding ? eval('self', binding) : self
|
11
|
+
keep_html_safety do
|
12
|
+
gsub!(/<<.+?>>/).each_with_index do |text, index|
|
13
|
+
context.instance_eval do
|
14
|
+
link_to text[2..-3], *urls[index]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def keep_html_safety
|
23
|
+
html_safe = @html_safe
|
24
|
+
yield
|
25
|
+
@html_safe = html_safe
|
26
|
+
self
|
5
27
|
end
|
6
28
|
end
|
7
29
|
end
|
8
30
|
|
9
|
-
Object.send(:include, I18nScrewdriver::Translation)
|
10
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_screwdriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-06-
|
13
|
+
date: 2012-06-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -62,6 +62,7 @@ files:
|
|
62
62
|
- lib/i18n_screwdriver/rails.rb
|
63
63
|
- lib/i18n_screwdriver/rails/engine.rb
|
64
64
|
- lib/i18n_screwdriver/translation.rb
|
65
|
+
- lib/i18n_screwdriver/translation_helper.rb
|
65
66
|
- lib/i18n_screwdriver/version.rb
|
66
67
|
- lib/tasks/i18n.rake
|
67
68
|
homepage: https://github.com/agileapplications/i18n_screwdriver
|
@@ -78,7 +79,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
78
79
|
version: '0'
|
79
80
|
segments:
|
80
81
|
- 0
|
81
|
-
hash: -
|
82
|
+
hash: -2643611881432222959
|
82
83
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
83
84
|
none: false
|
84
85
|
requirements:
|
@@ -87,7 +88,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
88
|
version: '0'
|
88
89
|
segments:
|
89
90
|
- 0
|
90
|
-
hash: -
|
91
|
+
hash: -2643611881432222959
|
91
92
|
requirements: []
|
92
93
|
rubyforge_project: i18n_screwdriver
|
93
94
|
rubygems_version: 1.8.24
|