radiant-globalize2-extension 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/globalize2_extension.rb +1 -1
- data/lib/globalize2/globalize_tags.rb +15 -5
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.6
|
data/globalize2_extension.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'globalize2/form_builder_extensions'
|
4
4
|
|
5
5
|
class Globalize2Extension < Radiant::Extension
|
6
|
-
version "0.2.
|
6
|
+
version "0.2.6"
|
7
7
|
description "Translate content in Radiant CMS using the Globalize2 Rails plugin."
|
8
8
|
url "http://blog.aissac.ro/radiant/globalize2-extension/"
|
9
9
|
|
@@ -36,7 +36,7 @@ module Globalize2
|
|
36
36
|
<pre><code><r:locale /></code></pre>
|
37
37
|
}
|
38
38
|
tag 'locale' do |tag|
|
39
|
-
|
39
|
+
Globalize2Extension.content_locale
|
40
40
|
end
|
41
41
|
|
42
42
|
desc %{
|
@@ -64,8 +64,11 @@ module Globalize2
|
|
64
64
|
raise TagError.new("'codes' attribute must be set") if tag.attr['codes'].blank?
|
65
65
|
|
66
66
|
result = []
|
67
|
-
codes = tag.attr["codes"].split("|")
|
67
|
+
codes = tag.attr["codes"].split("|")
|
68
|
+
codes.each do |code|
|
68
69
|
hash[:code] = code
|
70
|
+
tag.locals.first = code == codes.first
|
71
|
+
tag.locals.last = code == codes.last
|
69
72
|
if I18n.locale.to_s == code
|
70
73
|
result << (hash[:active] || hash[:normal]).call
|
71
74
|
else
|
@@ -84,6 +87,13 @@ module Globalize2
|
|
84
87
|
hash[symbol] = tag.block
|
85
88
|
end
|
86
89
|
end
|
90
|
+
|
91
|
+
tag "locales:if_first" do |tag|
|
92
|
+
tag.expand if tag.locals.first
|
93
|
+
end
|
94
|
+
tag "locales:if_last" do |tag|
|
95
|
+
tag.expand if tag.locals.last
|
96
|
+
end
|
87
97
|
|
88
98
|
tag 'locales:code' do |tag|
|
89
99
|
hash = tag.locals.locale
|
@@ -193,10 +203,10 @@ module Globalize2
|
|
193
203
|
# Allows you to switch the current locale while within the block.
|
194
204
|
# The previously current locale is reset after the block is finished.
|
195
205
|
def switch_locale(locale)
|
196
|
-
current_locale =
|
197
|
-
|
206
|
+
current_locale = Globalize2Extension.content_locale
|
207
|
+
Globalize2Extension.content_locale = locale
|
198
208
|
result = yield
|
199
|
-
|
209
|
+
Globalize2Extension.content_locale = current_locale
|
200
210
|
result
|
201
211
|
end
|
202
212
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-globalize2-extension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Cristi Duma
|