rails_admin_json_translate 0.1.1 → 0.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 +4 -4
- data/README.md +5 -5
- data/lib/rails_admin_json_translate/version.rb +1 -1
- data/lib/rails_admin_json_translate.rb +4 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d46b96692b3e83119f755ec33f6093bb72d19e4
|
4
|
+
data.tar.gz: 119bb58dee75c615386c357b2e7b7764f4eeb237
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5cc62922e9d9970e4491cfdb522e2d9eaf18671ae2087f9d43126ab575d668304141dd88c5cf3dcf813493b6bcc3ed5dbac1d49c493825091649b20331bb611
|
7
|
+
data.tar.gz: 879351fee21a2571922c6ec79c9107e1b319f10c26b45eee2e868410d2938af10c1509846c55c9434885c3e5790562ab87a3b22716760403bcffa7d553e89f91
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# RailsAdminJsonTranslate
|
2
2
|
This gem integrates [json_translate](https://github.com/cfabianski/json_translate) into [rails_admin](https://github.com/sferik/rails_admin). It aims to provide a reasonably good interface for managing translations. It does so by grouping translations into a tabbed interface, having full language names and accompanying [country flags](https://github.com/richardvenneman/emoji_flag) allowing for good scannability.
|
3
3
|
|
4
|
-

|
5
|
-
|
6
4
|
[](https://travis-ci.org/richardvenneman/rails_admin_json_translate)
|
7
|
-
[](https://rubygems.org/gems/rails_admin_json_translate)
|
5
|
+
[](https://rubygems.org/gems/rails_admin_json_translate)
|
6
|
+
|
7
|
+

|
8
8
|
|
9
9
|
## Usage
|
10
10
|
First make sure you've setup [json_translate](https://github.com/cfabianski/json_translate) for your models. You'll then need update your rails_admin configuration:
|
@@ -18,13 +18,13 @@ RailsAdmin.config do |config|
|
|
18
18
|
|
19
19
|
# Overriding locales
|
20
20
|
configure :body_translations, :json_translate do
|
21
|
-
locales
|
21
|
+
locales [:nl, :zh]
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
25
25
|
```
|
26
26
|
|
27
|
-
By default, rails_admin_json_translate uses the `I18n.available_locales` locales to create the tabbed interface. However you can specify the locales to use on a per-
|
27
|
+
By default, rails_admin_json_translate uses the `I18n.available_locales` locales to create the tabbed interface. However you can specify the locales to use on a per-field basis as shown above.
|
28
28
|
|
29
29
|
## Installation
|
30
30
|
Add this line to your application's Gemfile:
|
@@ -26,7 +26,10 @@ module RailsAdmin
|
|
26
26
|
|
27
27
|
def value_for_locale(locale)
|
28
28
|
val = @bindings[:object].send(name)
|
29
|
-
|
29
|
+
return '' unless val
|
30
|
+
|
31
|
+
val = JSON.parse(val) unless val.is_a?(Hash)
|
32
|
+
val.try(:[], locale.to_s)
|
30
33
|
rescue JSON::ParserError
|
31
34
|
''
|
32
35
|
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_admin_json_translate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Venneman
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0
|
19
|
+
version: '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
|
-
version: '0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|