traducto 1.0.0 → 1.0.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.
- checksums.yaml +4 -4
- data/README.md +13 -2
- data/lib/traducto/base.rb +12 -1
- data/spec/traducto/base_spec.rb +8 -0
- data/traducto.gemspec +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd86a1273a19699c24b8dc31ff4f4b5354b0c109
|
4
|
+
data.tar.gz: 3f70e6e5c17240fda3b795d568a8975dddd0131d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8fbb559494f65a298204c326f9a8b7e76d1fab5e81597ee48f3996c4cff7838045fdd3ac5573970f8c80b16392899e48357f79ef84d2539eb819bd7013e4c63d
|
7
|
+
data.tar.gz: 95e6fed7f5d176f31e2fe4253d850a5c6106411594cd800de010f5c9d26bbb00ef5e79c2a409b331bdc164207883f752f75cbaeed0cf97cd3ae662953820b503
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Traducto [](http://travis-ci.org/alchimikweb/traducto) [](https://codeclimate.com/repos/527c039556b10201a000874c/feed) [](https://coveralls.io/r/alchimikweb/traducto)
|
1
|
+
Traducto [](http://travis-ci.org/alchimikweb/traducto) [](https://codeclimate.com/repos/527c039556b10201a000874c/feed) [](https://coveralls.io/r/alchimikweb/traducto) [](http://badge.fury.io/rb/traducto)
|
2
2
|
===============
|
3
3
|
|
4
4
|
Rails helpers collection to simplify the localization code.
|
@@ -38,6 +38,8 @@ The lazy lookup will check three more path. Here's the full stack of checkup if
|
|
38
38
|
title: "Title"
|
39
39
|
```
|
40
40
|
|
41
|
+
This is for text in the persons view that is only present in the index action.
|
42
|
+
|
41
43
|
```yaml
|
42
44
|
en:
|
43
45
|
views:
|
@@ -45,12 +47,16 @@ The lazy lookup will check three more path. Here's the full stack of checkup if
|
|
45
47
|
title: "Title"
|
46
48
|
```
|
47
49
|
|
50
|
+
This is for text in the persons view that can be found in any actions.
|
51
|
+
|
48
52
|
```yaml
|
49
53
|
en:
|
50
54
|
views:
|
51
55
|
title: "Title"
|
52
56
|
```
|
53
57
|
|
58
|
+
This is for text that is used in any views.
|
59
|
+
|
54
60
|
```yaml
|
55
61
|
# Rails default
|
56
62
|
en:
|
@@ -59,6 +65,8 @@ The lazy lookup will check three more path. Here's the full stack of checkup if
|
|
59
65
|
title: "Title"
|
60
66
|
```
|
61
67
|
|
68
|
+
The reason I add the ```views``` key in front of ```persons``` is to clearly separate the translations of the views, models and helpers.
|
69
|
+
|
62
70
|
### Formatting
|
63
71
|
You can also provide the format options to wrap the content by paragraphs.
|
64
72
|
|
@@ -73,6 +81,9 @@ You can also provide the format options to wrap the content by paragraphs.
|
|
73
81
|
```
|
74
82
|
|
75
83
|
```ruby
|
84
|
+
t('description.intro', format: nil)
|
85
|
+
#--> Let me start by
|
86
|
+
|
76
87
|
t('description.intro', format: :text)
|
77
88
|
#--> <p>Let me start by</p>
|
78
89
|
|
@@ -84,4 +95,4 @@ You can also provide the format options to wrap the content by paragraphs.
|
|
84
95
|
Copyright
|
85
96
|
---------
|
86
97
|
|
87
|
-
Copyright (c) 2013 Alchimik. See LICENSE for further details.
|
98
|
+
Copyright (c) 2013 [Alchimik](http://www.alchimik.com). See [LICENSE](LICENCE) for further details.
|
data/lib/traducto/base.rb
CHANGED
@@ -21,7 +21,7 @@ module Traducto
|
|
21
21
|
|
22
22
|
i18n_translate @base_key if translation_missing?
|
23
23
|
|
24
|
-
|
24
|
+
format
|
25
25
|
|
26
26
|
return @text.html_safe
|
27
27
|
end
|
@@ -36,10 +36,21 @@ module Traducto
|
|
36
36
|
request[:controller]
|
37
37
|
end
|
38
38
|
|
39
|
+
def format
|
40
|
+
case @options[:format]
|
41
|
+
when :text then format_text
|
42
|
+
else format_base
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
39
46
|
def format?
|
40
47
|
@options[:format] ? true : false
|
41
48
|
end
|
42
49
|
|
50
|
+
def format_base
|
51
|
+
@text = @text.join("\n") if @text.is_a? Array
|
52
|
+
end
|
53
|
+
|
43
54
|
def format_text
|
44
55
|
@text = [@text] if not @text.is_a? Array
|
45
56
|
|
data/spec/traducto/base_spec.rb
CHANGED
@@ -54,6 +54,14 @@ describe Traducto::Base do
|
|
54
54
|
context "with the key intro having the value ['par1', 'par2', 'par3']" do
|
55
55
|
before { I18n.stub('translate').with('intro', anything()).and_return(['par1', 'par2', 'par3']) }
|
56
56
|
|
57
|
+
context "when translating the key 'intro' without a text format" do
|
58
|
+
before { @base = Traducto::Base.new(ActionView::Base.new) }
|
59
|
+
|
60
|
+
subject { @base.translate('intro') }
|
61
|
+
|
62
|
+
it { should eql "par1\npar2\npar3" }
|
63
|
+
end
|
64
|
+
|
57
65
|
context "when translating the key 'intro' with a text format" do
|
58
66
|
before { @base = Traducto::Base.new(ActionView::Base.new) }
|
59
67
|
|
data/traducto.gemspec
CHANGED
@@ -3,7 +3,7 @@ Gem::Specification.new do |gem|
|
|
3
3
|
gem.description = "Rails helpers collection to simplify the localization code."
|
4
4
|
gem.summary = "Rails helpers collection to simplify the localization code."
|
5
5
|
gem.homepage = "https://github.com/alchimikweb/traducto"
|
6
|
-
gem.version = "1.0.
|
6
|
+
gem.version = "1.0.1"
|
7
7
|
gem.licenses = ["MIT"]
|
8
8
|
|
9
9
|
gem.authors = ["Sebastien Rosa"]
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
|
17
|
-
gem.add_dependency "rails", ['>=
|
17
|
+
gem.add_dependency "rails", ['>= 3.0.0']
|
18
18
|
gem.add_development_dependency "sqlite3"
|
19
19
|
gem.add_development_dependency "rspec-rails"
|
20
20
|
gem.add_development_dependency "simplecov"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traducto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sebastien Rosa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 3.0.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|