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 +4 -4
- data/README.md +4 -1
- data/lib/localizable_db/localizable.rb +12 -0
- data/lib/localizable_db/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3b146a07a330015a49c876e7b91bcf2913ac665db180b18faf3adfd888a0b62
|
4
|
+
data.tar.gz: 4d3b3fe7f5a08cf553bf3f202bee15c83bf65bed9e3b67df9ff8087ba9dc24ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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|
|
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.
|
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
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|