localizable_db 1.0.7 → 1.0.8

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
  SHA256:
3
- metadata.gz: 2417072f63e592da31beda3d43c51ee0892687e285523983a8def07561c7c30c
4
- data.tar.gz: 7382beda5c96256617bc0f2a756ece69fa24a0d00d7f474b32637d13f8f848f5
3
+ metadata.gz: b3b146a07a330015a49c876e7b91bcf2913ac665db180b18faf3adfd888a0b62
4
+ data.tar.gz: 4d3b3fe7f5a08cf553bf3f202bee15c83bf65bed9e3b67df9ff8087ba9dc24ce
5
5
  SHA512:
6
- metadata.gz: df29f593085bac7f529115270766a118791546ae4af0957241d660a149a77b46caa91cc882aad4972f024f86bf3e7116a18de016e8f8f4561f09b5dac42913c3
7
- data.tar.gz: 2e83139d802a037df6069c19e87befb3af3829168bd3d38579eb2cfb4ad88999dd27287622201ab38429c55215765248f48a30320dafb6cdea4e549c7d07871e
6
+ metadata.gz: 8c52fcedbb92af8255e9e2279200dac7bf27c0e60dc8aeb48b610409fe14bf027474fe1ad97c7c85b0aecb920fdaf17674f6a00351bc2e659ca9fe6803bc1d8e
7
+ data.tar.gz: acf102e91f3a1c4d8b2d73e522d6f1b4456698993413e5e3767a3125aa0fd72f46047cffd387007e81749110862c0b450121f4b0340683a7ac90b6ddaed78d9b
data/README.md CHANGED
@@ -18,7 +18,7 @@ Product.l.where(id: 1)
18
18
  #=> <ActiveRecord::Relation [#<Product id: 1, name: "suerte">]>
19
19
 
20
20
  ````
21
- Specify the lenguage you want
21
+ Specify the language you want
22
22
 
23
23
  ````ruby
24
24
  Product.find(1) #=> <Product id: 1, name: "luck">
@@ -26,14 +26,17 @@ Product.where(id: 1)
26
26
  #=> <ActiveRecord::Relation [#<Product id: 1, name: "luck">]>
27
27
 
28
28
  Product.l(:es).find(1) #=> <Product id: 1, name: "suerte">
29
+ Product.find(1).l(:es) #=> <Product id: 1, name: "suerte">
29
30
  Product.l(:es).where(id: 1)
30
31
  #=> <ActiveRecord::Relation [#<Product id: 1, name: "suerte">]>
31
32
 
32
33
  Product.l(:pt).find(1) #=> <Product id: 1, name: "sortudo">
34
+ Product.find(1).l(:pt) #=> <Product id: 1, name: "sortudo">
33
35
  Product.l(:pt).where(id: 1)
34
36
  #=> <ActiveRecord::Relation [#<Product id: 1, name: "sortudo">]>
35
37
 
36
38
  Product.l(:fr).find(1) #=> <Product id: 1, name: "heureux">
39
+ Product.find(1).l(:fr) #=> <Product id: 1, name: "heureux">
37
40
  Product.l(:fr).where(id: 1)
38
41
  #=> <ActiveRecord::Relation [#<Product id: 1, name: "heureux">]>
39
42
  ````
@@ -4,6 +4,18 @@ module LocalizableDb
4
4
 
5
5
  included do
6
6
 
7
+ def localize(language = nil)
8
+ self.class.l(language).find_by_id(self.id)
9
+ end
10
+
11
+ alias :l :localize
12
+
13
+ def with_languages(*languages)
14
+ self.class.wl(languages).find_by_id(self.id)
15
+ end
16
+
17
+ alias :wl :with_languages
18
+
7
19
  def save_languages
8
20
  if !self._locale and self.languages
9
21
  self.languages.each do |language_key, language_values|
@@ -1,3 +1,3 @@
1
1
  module LocalizableDb
2
- VERSION = '1.0.7'
2
+ VERSION = '1.0.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localizable_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - yonga9121
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-02-12 00:00:00.000000000 Z
12
+ date: 2018-02-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails