rails_admin_json_translate 0.1.1 → 0.2.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: c1aeac1e21bafefd02491c83fcc8cc2a79cbcc3e
4
- data.tar.gz: c19731c3606c8e43eec99dff1d4d1abedf291fc7
3
+ metadata.gz: 4d46b96692b3e83119f755ec33f6093bb72d19e4
4
+ data.tar.gz: 119bb58dee75c615386c357b2e7b7764f4eeb237
5
5
  SHA512:
6
- metadata.gz: 0bcdba175b8524f8a1a69f331bd409881f126ecd56659be29e2669eff68a7e1f420aad05a547f175e003284aeca7e8698052930e3da04d3d2e6e2802e5fc30a7
7
- data.tar.gz: b096052a94253317a8f2bfe530cbf303a1997ea7b237a5bcf815da3379644abd9e5471d61ea663c13c58bb7304f6db51dcfd3fd7d5b11797406877e5bcacc65a
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
- ![screenshot](https://cloud.githubusercontent.com/assets/75705/23833356/7c448ddc-0744-11e7-83fc-22eb1851d060.png)
5
-
6
4
  [![Travis](https://img.shields.io/travis/richardvenneman/rails_admin_json_translate.svg?style=flat-square)](https://travis-ci.org/richardvenneman/rails_admin_json_translate)
7
- [![Gem](https://img.shields.io/gem/v/rails_admin_json_translate.svg)](https://rubygems.org/gems/rails_admin_json_translate)
5
+ [![Gem](https://img.shields.io/gem/v/rails_admin_json_translate.svg?style=flat-square)](https://rubygems.org/gems/rails_admin_json_translate)
6
+
7
+ ![screenshot](https://cloud.githubusercontent.com/assets/75705/23833356/7c448ddc-0744-11e7-83fc-22eb1851d060.png)
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 %w(nl zh)
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-model basis as shown above.
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:
@@ -1,3 +1,3 @@
1
1
  module RailsAdminJsonTranslate
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
@@ -26,7 +26,10 @@ module RailsAdmin
26
26
 
27
27
  def value_for_locale(locale)
28
28
  val = @bindings[:object].send(name)
29
- val ? JSON.parse(val).try(:[], locale.to_s) : ''
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.1.1
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-12 00:00:00.000000000 Z
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.20'
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.20'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement