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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fee80f6f73582dd588edaa90618125a27ceaf6c
4
- data.tar.gz: 19487c21a2c959aa75195ce3039cd5ebad362edc
3
+ metadata.gz: fc887b41ef374aeb80db2cb2a46ec195cca52e7e
4
+ data.tar.gz: 51cc19c95ec243a96cee9238f78389c04ced70f5
5
5
  SHA512:
6
- metadata.gz: 108b9c8f2ba7e33146c5c377c9bb2fd36bb6e331a162308a4dfbc066cd7744b21172a51c4b3b343133bb4837399a5ff4f5664a1c10db0e4c04de267f6dde512b
7
- data.tar.gz: 46db4d9d1bbe6e89d5bbbe5fcf5c1461ab5172dc4b1a5120a1ce31b4e9d916b2d04ebbc3f4a11765aab9091b05d1af743f8b061c2d05a08719271cf3381f971e
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 << i18n_load_path_from(base_path)
43
+ I18n.load_path = i18n_load_path_from(base_path)
44
44
  I18n.backend.load_translations
45
45
  end
46
46
  end
@@ -1,5 +1,5 @@
1
1
  module Alephant
2
2
  module Renderer
3
- VERSION = "0.0.6"
3
+ VERSION = "0.0.7"
4
4
  end
5
5
  end
@@ -14,16 +14,10 @@ module Alephant::Views
14
14
  @data = Hashie::Mash.new data
15
15
  end
16
16
 
17
- def t(*args)
17
+ def t(key, params = {})
18
18
  I18n.locale = self.class::LOCALE
19
- lambda do |comma_delimited_args|
20
- args = comma_delimited_args.strip.split ','
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)
@@ -0,0 +1,5 @@
1
+ module Fixtures
2
+ class Welsh < ::Alephant::Views::Base
3
+ LOCALE = :cy
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ cy:
2
+ welsh:
3
+ bar: 'Welsh Translation'
@@ -0,0 +1,3 @@
1
+ en:
2
+ base:
3
+ bar: 'Translation'
data/spec/spec_helper.rb CHANGED
@@ -2,4 +2,5 @@ $: << File.join(File.dirname(__FILE__),"..", "lib")
2
2
 
3
3
  require 'pry'
4
4
  require 'alephant/renderer'
5
+ require 'alephant/views/base'
5
6
 
@@ -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.6
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