alephant-renderer 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/alephant/renderer/version.rb +1 -1
- data/lib/alephant/views/base.rb +2 -1
- data/spec/views_base_spec.rb +14 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7001528da4f7c06a258cce649ffe62ca7c4b4f4
|
4
|
+
data.tar.gz: 25abdd3bc60c640c21f31f1de2c4585955eeae81
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f8f5068a7969f9bf0faabd88d76740ffb33d7d8e758d9ab5d4ba8a507b3051bed41de5a3d910ac65510d8d2b4f1b6a5890435c16fa5d9c70e19274a19ed4e4d
|
7
|
+
data.tar.gz: f6612815917388f3e3370d20ed2d8b9fd3323f2c3eb4fd3d5b7f8a77ead7612894d9fedffad04b050a14d6e6cf880449609a28905bc887c4c0c5e5199f8e1fa7
|
data/lib/alephant/views/base.rb
CHANGED
@@ -19,7 +19,8 @@ module Alephant::Views
|
|
19
19
|
def t(key, params = {})
|
20
20
|
I18n.locale = locale
|
21
21
|
prefix = /\/([^\/]+)\.mustache/.match(template_file)[1]
|
22
|
-
|
22
|
+
params.merge! :default => key unless params[:default]
|
23
|
+
translation = I18n.translate("#{prefix}.#{key}", params)
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.inherited(subclass)
|
data/spec/views_base_spec.rb
CHANGED
@@ -23,5 +23,19 @@ describe Alephant::Views::Base do
|
|
23
23
|
|
24
24
|
expect(Fixtures::Welsh.new.t('bar')).to eq('Welsh Translation')
|
25
25
|
end
|
26
|
+
|
27
|
+
it "Uses the translation keys value if no translation and no default set" do
|
28
|
+
Alephant::Renderer.create('welsh', base_path, :model)
|
29
|
+
|
30
|
+
expect(Fixtures::Welsh.new.t('non_existent')).to eq('non_existent')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "t(key, param{:default => 'A default'})" do
|
35
|
+
it "Uses the passed in default if translation key does not exist" do
|
36
|
+
Alephant::Renderer.create('welsh', base_path, :model)
|
37
|
+
|
38
|
+
expect(Fixtures::Welsh.new.t('non_existent', :default => 'A default')).to eq('A default')
|
39
|
+
end
|
26
40
|
end
|
27
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alephant-renderer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|