traco 2.1.0 → 2.2.0
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 +5 -13
- data/.travis.yml +1 -0
- data/README.md +5 -10
- data/lib/traco/localized_reader.rb +2 -1
- data/lib/traco/version.rb +1 -1
- data/spec/spec_helper.rb +1 -0
- data/spec/traco_spec.rb +18 -0
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
MzIxZjkyY2JiODc3YzU3NDhmYWNiNzI2ODMzMjI5MWY4ZmQ2YmRhMQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b558d968305b0326939037fb16d4a871092c39cc
|
4
|
+
data.tar.gz: 204f5478a41436d55d0c19954ce0ef971f86dc45
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
YzNhMWEyNDhiNjE0ZjYxYTc5N2IzMjljOWEyOGVlNDVhZTZhZTljOWE2MTM2
|
11
|
-
NzgwYTk3OGNjY2Y3ZWY0YTcwNWQxMzg2YWI4MWZmMDBiZDM5YzA=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YTQ4NmNhMDMxZmI2NTQxMzBkMWYzNDc1MGU0OTgzODEyYTUzZTE3MTAyOTFi
|
14
|
-
NDhlZDg5MzEzZTVjZThlYmU3NzExYTZmZjM1ZTMwYTQxOWQyMTE1ZTMxZjYw
|
15
|
-
NGM5ZDVlYTViYTlmMDE4MmI3YzgzMGQ2Y2U5YmQyYTgxMGI0NGI=
|
6
|
+
metadata.gz: 4e4745b20173434cb983d53bb2cb18074f398685f2fea9efb011e41f95842fe3108644fa11a0e971752bd30db436219d45455839d969aed988ce4936414ed28d
|
7
|
+
data.tar.gz: ccc4cdbbccf49ff129f2d9e634e1a9aab80650a1600d820f82cfabf8a2977ab669496fdeca1f3ffd7749f2abfc3eba6351fdca74773e8115245a503f35db871b
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -84,20 +84,15 @@ And the equivalent methods for `body`, of course.
|
|
84
84
|
Please note that your `translates :title, :body` declaration must be called before you call `locale_columns`. Otherwise you will get an error like "NoMethodError: undefined method `locale\_columns' for #\<Class:0x00000003f69188\>".
|
85
85
|
|
86
86
|
|
87
|
-
###
|
87
|
+
### Fallbacks
|
88
88
|
|
89
|
-
if
|
89
|
+
By default, Traco will fall back to the default locale if there is no translation in the current locale.
|
90
90
|
|
91
|
-
|
92
|
-
class Post < ActiveRecord::Base
|
93
|
-
translates :title, :body,
|
94
|
-
fallback: false
|
95
|
-
end
|
96
|
-
```
|
91
|
+
You can specify e.g. `translates :title, fallback: false` to never fall back and instead return `nil`.
|
97
92
|
|
98
|
-
|
93
|
+
You can specify e.g. `translates :title, fallback: :any` to fall back first to the default locale, then to any other locale.
|
99
94
|
|
100
|
-
|
95
|
+
You can override the default fallback strategy with a parameter passed to the reader: `post.title(fallback: :any)`.
|
101
96
|
|
102
97
|
|
103
98
|
### Overriding methods
|
@@ -24,7 +24,8 @@ module Traco
|
|
24
24
|
def locale_chain
|
25
25
|
chain = []
|
26
26
|
chain << I18n.locale
|
27
|
-
chain << I18n.default_locale
|
27
|
+
chain << I18n.default_locale if @fallback
|
28
|
+
chain += I18n.available_locales if @fallback == :any
|
28
29
|
chain.map { |locale| Traco.locale_suffix(locale) }
|
29
30
|
end
|
30
31
|
|
data/lib/traco/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
data/spec/traco_spec.rb
CHANGED
@@ -177,6 +177,24 @@ describe Post, "#title" do
|
|
177
177
|
post.title(fallback: true).should == "Halloa"
|
178
178
|
end
|
179
179
|
end
|
180
|
+
|
181
|
+
context "when the translation was defined with fallback: :any" do
|
182
|
+
before do
|
183
|
+
Post.translates :title, fallback: :any
|
184
|
+
I18n.default_locale = :en
|
185
|
+
I18n.locale = :"pt-BR"
|
186
|
+
end
|
187
|
+
|
188
|
+
it "falls back to any locale, not just the default" do
|
189
|
+
post = Post.new(title_en: "", title_pt_br: "", title_sv: "Hej")
|
190
|
+
post.title.should == "Hej"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "prefers the default locale" do
|
194
|
+
post = Post.new(title_en: "Hello", title_pt_br: "", title_sv: "Hej")
|
195
|
+
post.title.should == "Hello"
|
196
|
+
end
|
197
|
+
end
|
180
198
|
end
|
181
199
|
|
182
200
|
describe Post, "#title=" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traco
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Nyh
|
@@ -14,56 +14,56 @@ dependencies:
|
|
14
14
|
name: activerecord
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.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
26
|
version: '3.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: sqlite3
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description:
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rvmrc
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rvmrc"
|
78
|
+
- ".travis.yml"
|
79
79
|
- CHANGELOG.md
|
80
80
|
- Gemfile
|
81
81
|
- README.md
|
@@ -100,17 +100,17 @@ require_paths:
|
|
100
100
|
- lib
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- -
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
|
-
- -
|
108
|
+
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
112
|
rubyforge_project:
|
113
|
-
rubygems_version: 2.2.
|
113
|
+
rubygems_version: 2.2.0
|
114
114
|
signing_key:
|
115
115
|
specification_version: 4
|
116
116
|
summary: Translatable columns for Rails 3 or better, stored in the model table itself.
|