localite 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/localite/filter.rb +6 -3
- data/lib/localite/settings.rb +2 -2
- data/localite.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/lib/localite/filter.rb
CHANGED
@@ -18,17 +18,20 @@ module Localite::Filter
|
|
18
18
|
filter_response controller
|
19
19
|
end
|
20
20
|
rescue
|
21
|
-
|
21
|
+
if Rails.env.development?
|
22
|
+
controller.response.body = "Caught exception: " + CGI::escapeHTML($!.inspect)
|
23
|
+
STDERR.puts $!.to_s + "\n\t" + $!.backtrace.join("\n\t")
|
24
|
+
end
|
22
25
|
raise
|
23
26
|
end
|
24
27
|
|
25
28
|
def self.filter_response(controller)
|
26
|
-
|
29
|
+
return unless controller.response.headers["Content-Type"] =~ /text\/html/
|
27
30
|
controller.response.body = filter_lang_nodes(controller.response.body)
|
28
31
|
end
|
29
32
|
|
30
33
|
def self.filter_lang_nodes(body)
|
31
|
-
doc = Nokogiri.XML "<filter-outer-span>#{body}</filter-outer-span>"
|
34
|
+
doc = Nokogiri.XML "<filter-outer-span xmlns:fb='http://facebook.com/'>#{body}</filter-outer-span>"
|
32
35
|
|
33
36
|
doc.css("[lang]").each do |node|
|
34
37
|
if Localite.locale.to_s != node["lang"]
|
data/lib/localite/settings.rb
CHANGED
@@ -8,7 +8,7 @@ module Localite::Settings
|
|
8
8
|
#
|
9
9
|
# returns the current locale; defaults to the base locale
|
10
10
|
def locale
|
11
|
-
|
11
|
+
I18n.locale
|
12
12
|
end
|
13
13
|
|
14
14
|
#
|
@@ -22,7 +22,7 @@ module Localite::Settings
|
|
22
22
|
# the locale to the default locale.
|
23
23
|
def locale=(locale)
|
24
24
|
locale = locale.to_sym
|
25
|
-
|
25
|
+
I18n.locale = available?(locale) ? locale : base
|
26
26
|
end
|
27
27
|
|
28
28
|
#
|
data/localite.gemspec
CHANGED