refinerycms-i18n 0.9.8 → 0.9.8.1
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/lib/gemspec.rb +1 -1
- data/lib/refinery/i18n.rb +36 -0
- metadata +4 -3
data/lib/gemspec.rb
CHANGED
data/lib/refinery/i18n.rb
CHANGED
@@ -18,6 +18,42 @@ module Refinery
|
|
18
18
|
end
|
19
19
|
|
20
20
|
config.to_prepare do
|
21
|
+
::Refinery::ApplicationController.class_eval do
|
22
|
+
def default_url_options(options={})
|
23
|
+
::Refinery::I18n.enabled? ? { :locale => I18n.locale } : {}
|
24
|
+
end
|
25
|
+
|
26
|
+
prepend_before_filter :find_or_set_locale
|
27
|
+
|
28
|
+
def find_or_set_locale
|
29
|
+
if ::Refinery::I18n.enabled?
|
30
|
+
if ::Refinery::I18n.has_locale?(locale = params[:locale].try(:to_sym))
|
31
|
+
::I18n.locale = locale
|
32
|
+
elsif locale.present? and locale != ::Refinery::I18n.default_frontend_locale
|
33
|
+
params[:locale] = I18n.locale = ::Refinery::I18n.default_frontend_locale
|
34
|
+
redirect_to(params, :notice => "The locale '#{locale.to_s}' is not supported.") and return
|
35
|
+
else
|
36
|
+
::I18n.locale = ::Refinery::I18n.default_frontend_locale
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
protected :default_url_options, :find_or_set_locale
|
42
|
+
end
|
43
|
+
|
44
|
+
::Refinery::AdminBaseController.class_eval do
|
45
|
+
def find_or_set_locale
|
46
|
+
if (params[:set_locale].present? and ::Refinery::I18n.locales.include?(params[:set_locale].to_sym))
|
47
|
+
::Refinery::I18n.current_locale = params[:set_locale].to_sym
|
48
|
+
redirect_back_or_default(admin_dashboard_path) and return
|
49
|
+
else
|
50
|
+
I18n.locale = ::Refinery::I18n.current_locale
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
protected :find_or_set_locale
|
55
|
+
end
|
56
|
+
|
21
57
|
::Refinery::I18n.setup! if defined?(RefinerySetting) and RefinerySetting.table_exists?
|
22
58
|
end
|
23
59
|
end
|
metadata
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refinerycms-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 37
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 9
|
9
9
|
- 8
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 0.9.8.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
14
|
- Resolve Digital
|
@@ -15,7 +16,7 @@ autorequire:
|
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-08-
|
19
|
+
date: 2010-08-30 00:00:00 +12:00
|
19
20
|
default_executable:
|
20
21
|
dependencies: []
|
21
22
|
|