lolita-translation 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 688c3ccc5a593530530da8349faca89f96b3fce1
4
- data.tar.gz: 651660c2ea1eb2b03c3a8c6c06d9ffa9e410d8e1
3
+ metadata.gz: 070a74f72c3081db7d9843eef436c730732da445
4
+ data.tar.gz: ec4937281283f6ab32c6984ff3100c209ba78aad
5
5
  SHA512:
6
- metadata.gz: 584b8f2dab48f28b96107df17dd725bd064d118a86e02e681098d21ea9abd341d8dda114189c0be17661782057acd8db8326231d9594fe55a35af6f4ea9e2427
7
- data.tar.gz: 4c45b2282ddba3342479a12765b61243bd5928b42fa7511bd593ed8a6d3659ec25323cdc4b9edc451dd9dc0d970386406e5ed10434b5944a73a76c270a2e1aab
6
+ metadata.gz: 5e4df60be4270e2d4ca36b7ef51a8493e860aa4253b48d489c715ac755f4ad03235d9684b993697fd5daa737c6b5d0fd76412952dfb5607fd2db8ef3b79c7bd4
7
+ data.tar.gz: fd96732df5ae355a79e04e48493cf054f3554f61eb390ad24db0cc8861b75e262b86485e907d9cbdd53adf217c67f94933ee1edce14ba9be9340dd8b0438a63b
data/README.md CHANGED
@@ -32,9 +32,19 @@ Translations table holds only translations, but not the original data from defau
32
32
  a.title
33
33
  #=> "Title in LV"
34
34
 
35
+ a.in(:lv) # switching locale to lv
36
+ a.title #returns record's title attribute in locale that's passed
37
+ #=> "Title in LV"
38
+
35
39
  a.in(:lv).title #returns record's title attribute in locale that's passed
36
40
  #=> "Title in LV"
37
41
 
42
+ a.in(:lv) do |item|
43
+ item.title #returns record's title attribute in locale that's passed
44
+ #=> "Title in LV"
45
+ end
46
+ # after block the default locale is switched back
47
+
38
48
  When a "find" is executed and current language is not the same as default language then `:translations` are added to `:includes` to pre fetch all translations.
39
49
 
40
50
  The `ModelNameTranslation` class is created for you automaticly with all validations for ranslated fields. Of course you can create it manualy for custom vlidations and other.
@@ -173,8 +173,10 @@ module Lolita
173
173
  old_locale = @record_current_locale
174
174
  @record_current_locale = locale
175
175
  if block_given?
176
- yield
176
+ yield(self.original_record)
177
177
  @record_current_locale = old_locale
178
+ else
179
+ self.original_record
178
180
  end
179
181
  end
180
182
 
@@ -215,4 +217,4 @@ module Lolita
215
217
  end
216
218
  end
217
219
  end
218
- end
220
+ end
@@ -2,8 +2,8 @@ module Lolita
2
2
  module Translation
3
3
  module Version
4
4
  MAJOR = 0
5
- MINOR = 7
6
- PATCH = 4
5
+ MINOR = 8
6
+ PATCH = 0
7
7
  BUILD = nil
8
8
 
9
9
  STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
@@ -110,7 +110,17 @@ describe Lolita::Translation::Record do
110
110
  obj.orm_wrapper.should_receive(:attribute).with(:name)
111
111
  obj.attribute(:name)
112
112
  end
113
+
114
+ it "should yield record with given locale" do
115
+ obj = klass.new(rec)
116
+ obj.in(:ru) do |new_obj|
117
+ rec.should_receive(:name)
118
+ new_obj.name
119
+ end
120
+ obj.orm_wrapper.should_receive(:attribute).with(:name)
121
+ obj.attribute(:name)
122
+ end
113
123
  end
114
124
 
115
125
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
116
- end
126
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolita-translation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.4
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ITHouse (Latvia) and Arturs Meisters
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  version: '0'
123
123
  requirements: []
124
124
  rubyforge_project:
125
- rubygems_version: 2.2.1
125
+ rubygems_version: 2.2.0
126
126
  signing_key:
127
127
  specification_version: 4
128
128
  summary: Lolita extension that add multilanguate support to Lolita.