josevalim-localized_templates 0.3 → 0.3.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/README +1 -1
- data/lib/localized_rescue/README +10 -0
- data/lib/localized_templates.rb +1 -24
- data/lib/localized_templates/README +24 -0
- metadata +3 -3
- data/init.rb +0 -3
- data/lib/localized_rescue.rb +0 -11
data/README
CHANGED
@@ -0,0 +1,10 @@
|
|
1
|
+
Localized rescue
|
2
|
+
----------------
|
3
|
+
|
4
|
+
This feature extends Rails rescue handling and allows the use of localized
|
5
|
+
rescues like <code>en-US/404.html</code> on the public dir. The plugin will
|
6
|
+
then pick the rescue page matching the currently used locale
|
7
|
+
(<code>I18n#locale</code>).
|
8
|
+
|
9
|
+
If the localized rescue page isn't found, the plugin will render the
|
10
|
+
<code>404.html</code> file if it exists.
|
data/lib/localized_templates.rb
CHANGED
@@ -1,27 +1,4 @@
|
|
1
|
-
|
2
|
-
#
|
3
|
-
# This feature extends Rails template handling and allows the use of localized
|
4
|
-
# templates on the root of your views folder like <code>pt-BR/projects/index.html.erb</code>.
|
5
|
-
# The plugin will pick the template matching the currently used locale
|
6
|
-
# (<code>I18n#locale</code>).
|
7
|
-
#
|
8
|
-
# If the localized template isn't found, the plugin will try to render the default
|
9
|
-
# <code>projects/index.html.erb</code>. If <code>index.html.erb</code> doesn't
|
10
|
-
# exist, a 404 will be raised.
|
11
|
-
#
|
12
|
-
# If you have a template that is the same for all languages (like a xml file)
|
13
|
-
# just keep it without localization: <code>index.xml.builder</code>.
|
14
|
-
#
|
15
|
-
# Theoretically, we just need to overwrite _pick_template and _pick_partial_template
|
16
|
-
# methods in order to have LocalizedTemplates, but memoize doesn't help
|
17
|
-
# since it doesn't see locale changes and would memoize values for only one locale.
|
18
|
-
#
|
19
|
-
# We can fix this by passing the locale to _pick_template as argument or creating a
|
20
|
-
# localized memoize, that would memoize different values based on the locale.
|
21
|
-
#
|
22
|
-
# For now, we will use the first solution: pass the locale to _pick_template. As
|
23
|
-
# consequence, we need to overwrite all methods that call _pick_template.
|
24
|
-
#
|
1
|
+
require 'localized_rescue/actioncontroller/rescue'
|
25
2
|
require 'localized_templates/actioncontroller/base'
|
26
3
|
require 'localized_templates/actioncontroller/layout'
|
27
4
|
require 'localized_templates/actionview/base'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Localized templates
|
2
|
+
-------------------
|
3
|
+
|
4
|
+
This feature extends Rails template handling and allows the use of localized
|
5
|
+
templates on the root of your views folder like <code>pt-BR/projects/index.html.erb</code>.
|
6
|
+
The plugin will pick the template matching the currently used locale
|
7
|
+
(<code>I18n#locale</code>).
|
8
|
+
|
9
|
+
If the localized template isn't found, the plugin will try to render the default
|
10
|
+
<code>projects/index.html.erb</code>. If <code>index.html.erb</code> doesn't
|
11
|
+
exist, a 404 will be raised.
|
12
|
+
|
13
|
+
If you have a template that is the same for all languages (like a xml file)
|
14
|
+
just keep it without localization: <code>index.xml.builder</code>.
|
15
|
+
|
16
|
+
Theoretically, we just need to overwrite _pick_template and _pick_partial_template
|
17
|
+
methods in order to have LocalizedTemplates, but memoize doesn't help
|
18
|
+
since it doesn't see locale changes and would memoize values for only one locale.
|
19
|
+
|
20
|
+
We can fix this by passing the locale to _pick_template as argument or creating a
|
21
|
+
localized memoize, that would memoize different values based on the locale.
|
22
|
+
|
23
|
+
For now, we will use the first solution: pass the locale to _pick_template. As
|
24
|
+
consequence, we need to overwrite all methods that call _pick_template.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: josevalim-localized_templates
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Jos\xC3\xA9 Valim"
|
@@ -25,10 +25,10 @@ files:
|
|
25
25
|
- MIT-LICENSE
|
26
26
|
- README
|
27
27
|
- Rakefile
|
28
|
-
- init.rb
|
29
|
-
- lib/localized_rescue.rb
|
30
28
|
- lib/localized_templates.rb
|
29
|
+
- lib/localized_rescue/README
|
31
30
|
- lib/localized_rescue/actioncontroller/rescue.rb
|
31
|
+
- lib/localized_templates/README
|
32
32
|
- lib/localized_templates/actioncontroller/base.rb
|
33
33
|
- lib/localized_templates/actioncontroller/layout.rb
|
34
34
|
- lib/localized_templates/actionview/base.rb
|
data/init.rb
DELETED
data/lib/localized_rescue.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
# = Localized rescue
|
2
|
-
#
|
3
|
-
# This feature extends Rails rescue handling and allows the use of localized
|
4
|
-
# rescues like <code>en-US/404.html</code> on the public dir. The plugin will
|
5
|
-
# then pick the rescue page matching the currently used locale
|
6
|
-
# (<code>I18n#locale</code>).
|
7
|
-
#
|
8
|
-
# If the localized rescue page isn't found, the plugin will render the
|
9
|
-
# <code>404.html</code> file if it exists.
|
10
|
-
#
|
11
|
-
require 'localized_rescue/actioncontroller/rescue'
|