alephant-renderer 0.0.6 → 0.0.7
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.
- checksums.yaml +4 -4
- data/lib/alephant/renderer/engines/mustache.rb +1 -1
- data/lib/alephant/renderer/version.rb +1 -1
- data/lib/alephant/views/base.rb +3 -9
- data/spec/fixtures/components/foo/models/welsh.rb +5 -0
- data/spec/fixtures/components/locale/cy.yml +3 -0
- data/spec/fixtures/components/locale/en.yml +3 -0
- data/spec/spec_helper.rb +1 -0
- data/spec/views_base_spec.rb +27 -0
- metadata +9 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc887b41ef374aeb80db2cb2a46ec195cca52e7e
|
4
|
+
data.tar.gz: 51cc19c95ec243a96cee9238f78389c04ced70f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eea51315385b73e5ff8971d8bdf4e75cc40ef2716cc241aeee43f7828abadd0836560a648d573964d4fade6e7a918e502294dd952f7031fad196f55767d820b
|
7
|
+
data.tar.gz: bf73813fd0c097ebf63a77296cdde9b4f28f9374bc02abb051eb95225b0595fda64c7556a366aa153c600a65bbe687d6147450ff0d0c09b985e87ac471708013
|
@@ -40,7 +40,7 @@ module Alephant
|
|
40
40
|
def load_translations_from(base_path)
|
41
41
|
if I18n.load_path.empty?
|
42
42
|
I18n.config.enforce_available_locales = false
|
43
|
-
I18n.load_path
|
43
|
+
I18n.load_path = i18n_load_path_from(base_path)
|
44
44
|
I18n.backend.load_translations
|
45
45
|
end
|
46
46
|
end
|
data/lib/alephant/views/base.rb
CHANGED
@@ -14,16 +14,10 @@ module Alephant::Views
|
|
14
14
|
@data = Hashie::Mash.new data
|
15
15
|
end
|
16
16
|
|
17
|
-
def t(
|
17
|
+
def t(key, params = {})
|
18
18
|
I18n.locale = self.class::LOCALE
|
19
|
-
|
20
|
-
|
21
|
-
key = args.shift
|
22
|
-
params = args.empty? ? {} : JSON.parse(args.first).with_indifferent_access
|
23
|
-
prefix = /\/([^\/]+)\./.match(template_file)[1]
|
24
|
-
|
25
|
-
I18n.translate("#{prefix}.#{key}", params)
|
26
|
-
end
|
19
|
+
prefix = /\/([^\/]+)\./.match(template_file)[1]
|
20
|
+
I18n.translate("#{prefix}.#{key}", params)
|
27
21
|
end
|
28
22
|
|
29
23
|
def self.inherited(subclass)
|
data/spec/spec_helper.rb
CHANGED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fixtures/components/foo/models/welsh'
|
3
|
+
|
4
|
+
describe Alephant::Views::Base do
|
5
|
+
let(:base_path) do
|
6
|
+
File.join(
|
7
|
+
File.dirname(__FILE__),
|
8
|
+
'fixtures',
|
9
|
+
'components',
|
10
|
+
'foo'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "t(key, param{})" do
|
15
|
+
it "Translates a key for the default locale" do
|
16
|
+
Alephant::Renderer.create('foo', base_path, :model)
|
17
|
+
|
18
|
+
expect(subject.t('bar')).to eq('Translation')
|
19
|
+
end
|
20
|
+
|
21
|
+
it "Translates a key for an overridden locale" do
|
22
|
+
Alephant::Renderer.create('welsh', base_path, :model)
|
23
|
+
|
24
|
+
expect(Fixtures::Welsh.new.t('bar')).to eq('Welsh Translation')
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Kenny
|
@@ -214,10 +214,14 @@ files:
|
|
214
214
|
- lib/alephant/views.rb
|
215
215
|
- lib/alephant/views/base.rb
|
216
216
|
- spec/fixtures/components/foo/models/foo.rb
|
217
|
+
- spec/fixtures/components/foo/models/welsh.rb
|
217
218
|
- spec/fixtures/components/foo/templates/bar.mustache
|
218
219
|
- spec/fixtures/components/foo/templates/foo.mustache
|
220
|
+
- spec/fixtures/components/locale/cy.yml
|
221
|
+
- spec/fixtures/components/locale/en.yml
|
219
222
|
- spec/renderer_spec.rb
|
220
223
|
- spec/spec_helper.rb
|
224
|
+
- spec/views_base_spec.rb
|
221
225
|
- trans.yml
|
222
226
|
homepage: ''
|
223
227
|
licenses:
|
@@ -245,7 +249,11 @@ specification_version: 4
|
|
245
249
|
summary: Render HTML snippets
|
246
250
|
test_files:
|
247
251
|
- spec/fixtures/components/foo/models/foo.rb
|
252
|
+
- spec/fixtures/components/foo/models/welsh.rb
|
248
253
|
- spec/fixtures/components/foo/templates/bar.mustache
|
249
254
|
- spec/fixtures/components/foo/templates/foo.mustache
|
255
|
+
- spec/fixtures/components/locale/cy.yml
|
256
|
+
- spec/fixtures/components/locale/en.yml
|
250
257
|
- spec/renderer_spec.rb
|
251
258
|
- spec/spec_helper.rb
|
259
|
+
- spec/views_base_spec.rb
|