traco 3.0.0 → 3.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6593f9b00040b46726794a81103b204f708badd
4
- data.tar.gz: 65bb9ab64475d9935ecdee1adf0369898d7c8a90
3
+ metadata.gz: a8bd7fc75a987a4f1f791ac9d4e1eec0aed2a63e
4
+ data.tar.gz: 4089adbb897a21f2eefd3c3ea2cc88ea746705e2
5
5
  SHA512:
6
- metadata.gz: fcb768c9e6f93a6f2682875c87e5b028c6c5168f4d044e5970a3d3ecf57a768e39cda38a67ca381f31eb4da066b7379fdf9fb71830d2da9e4d506f0392670196
7
- data.tar.gz: 5083c41205a6d2c144b6dceb585b8fa88ee9cc66e133c8e86d567c3fa968e89000c7dba315a4c28e7de9605f841b0faa83b2969a760c15e07475b074ea8657e2
6
+ metadata.gz: 87640e9a6cf728ff073ed250497821582555b47a89c1274c14cdefcde446e39676fbd9091de27ac1f7f4ac373255393787600a1872469d27a858e57a86f44c6e
7
+ data.tar.gz: 1b64b064d9918cfb1909447dfb2a2f840de1f0f0f5142a4e5583b44b83c652f601557aab24712bff45d9d873a7702820fce21604f5a87e71ecf03fb6b0e64941
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 3.1.0
4
+
5
+ * Introduce `.current_locale_column`, e.g. `Post.current_locale_column(:title) # => :title_sv`.
6
+
7
+ ## 3.0.0
8
+
9
+ * Backwards incompatible: `fallback: true` is now `fallback: :default`. Since this was the implicit default value, you shouldn't have a problem unless you explicitly declared this value.
10
+
11
+ ## 2.2.0
12
+
13
+ * `fallback: :any` to fall back to any other locale if the text is blank in the current and default locales.
14
+
15
+ ## 2.1.0
16
+
17
+ * Attribute readers can override the attribute's `fallback` setting, e.g. `item.title(fallback: false)`.
18
+
3
19
  ## 2.0.0
4
20
 
5
21
  * Backwards incompatible: for dashed locales like `:"pt-BR"`, the column names are now expected to end in e.g. `_pt_br`, not `_pt-BR`.
data/README.md CHANGED
@@ -77,6 +77,8 @@ attr_accessible *locale_columns(:title, :body)
77
77
 
78
78
  The return value will be sorted like `[:title_sv, :title_en, :body_sv, :body_en]`.
79
79
 
80
+ `.current_locale_column(:title)`: Returns `:title_sv` if `:sv` is the current locale. Suitable for some SQL queries, such as sorting.
81
+
80
82
  `.locales_for_attribute(:title)`: Returns an array like `[:sv, :en]` sorted with default locale first and then alphabetically.
81
83
 
82
84
  And the equivalent methods for `body`, of course.
@@ -18,6 +18,10 @@ module Traco
18
18
  }
19
19
  end
20
20
 
21
+ def current_locale_column(attribute)
22
+ :"#{attribute}_#{I18n.locale}"
23
+ end
24
+
21
25
  def human_attribute_name(attribute, options = {})
22
26
  default = super(attribute, options.merge(default: ""))
23
27
 
@@ -1,3 +1,3 @@
1
1
  module Traco
2
- VERSION = "3.0.0"
2
+ VERSION = "3.1.0"
3
3
  end
@@ -74,6 +74,17 @@ describe Post, ".locale_columns" do
74
74
  end
75
75
  end
76
76
 
77
+ describe Post, ".current_locale_column" do
78
+ before do
79
+ Post.translates :title
80
+ end
81
+
82
+ it "returns the column name for the current locale" do
83
+ I18n.locale = :sv
84
+ Post.current_locale_column(:title).should == :title_sv
85
+ end
86
+ end
87
+
77
88
  describe Post, "#title" do
78
89
  let(:post) {
79
90
  Post.new(title_sv: "Hej", title_en: "Halloa", title_pt_br: "Olá")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: traco
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrik Nyh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-21 00:00:00.000000000 Z
11
+ date: 2014-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord