Skip to content

Commit 723bc67

Browse files
committed
Merge branch 'release/0.9.9', closes #16 and #21
2 parents 13bd8fe + dd9f432 commit 723bc67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+540
-237
lines changed

.travis.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
sudo: false
12
language: ruby
3+
# Limit ruby versions to currently supported versions to avoid a big build matrix
24
rvm:
3-
- 1.9.3
4-
- 2.0.0
5+
- 2.2.7
6+
- 2.3.4
7+
- 2.4.1
58
# Load database schema before rake
6-
before_script: bundle exec rake db:schema:load
9+
before_script: bundle exec rake db:schema:load
10+
# Test on all supported rails versions
11+
gemfile:
12+
- gemfiles/rails4_2.gemfile
13+
- gemfiles/rails5_0.gemfile
14+
- gemfiles/rails5_1.gemfile

Appraisals

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
appraise 'rails4_2' do
2+
gem 'rails', '~> 4.2.9'
3+
gem 'globalize', '~> 5.0.0'
4+
end
5+
6+
appraise 'rails5_0' do
7+
gem 'rails', '~> 4.2.9'
8+
gem 'globalize', '~> 5.0.0'
9+
end
10+
11+
appraise 'rails5_1' do
12+
gem 'devise', '~> 4.3'
13+
gem 'rails', '~> 5.1.3'
14+
gem 'globalize', '~> 5.1.0.beta2'
15+
end

Gemfile

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,31 +14,31 @@ gemspec
1414
# gem 'debugger'
1515

1616
# Gems used by the dummy application
17-
group :assets do
18-
gem 'sass-rails', '~> 3.2.3'
19-
gem 'coffee-rails', '~> 3.2.1'
17+
gem 'sass-rails'
18+
gem 'coffee-rails'
2019

21-
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
22-
gem 'therubyracer', platforms: :ruby
23-
24-
gem 'uglifier', '>= 1.0.3'
25-
end
20+
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
21+
gem 'therubyracer', platforms: :ruby
22+
gem 'uglifier'
2623

2724
# jquery-rails is
2825
gem 'jquery-rails'
2926

27+
# ActiveAdmin requires devise < 4.0
28+
gem 'devise', '~> 3.2'
29+
3030
group :test do
3131
gem 'sqlite3', '~> 1.3.5'
32-
gem 'rspec-rails', '~> 2.14.0'
32+
gem 'rspec-rails', '~> 3.6.1'
3333
gem 'factory_girl_rails', '~> 4.2.1'
3434
gem 'database_cleaner', '~> 1.0.1'
35-
gem 'guard-rspec', require: false
3635
gem 'spring', require: false
3736
gem 'spring-commands-rspec', require: false
38-
gem 'capybara', '~> 2.1.0'
37+
gem 'capybara', '~> 2.15'
3938
gem 'capybara-screenshot'
4039
gem 'poltergeist'
41-
gem 'fuubar'
40+
gem 'fuubar', '~> 2.2'
41+
gem 'appraisal'
4242
# Useful to debug tests
4343
gem 'awesome_print'
4444
gem 'pry'

Guardfile

Lines changed: 0 additions & 16 deletions
This file was deleted.

README.md

Lines changed: 80 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,32 @@
11
# ActiveAdmin::Globalize
2+
23
Makes it easy to translate your resource fields.
34

5+
[![Gem Version](https://badge.fury.io/rb/activeadmin-globalize.svg)](http://badge.fury.io/rb/activeadmin-globalize)
6+
[![Build Status](https://travis-ci.org/fabn/activeadmin-globalize.svg?branch=develop)](https://travis-ci.org/fabn/activeadmin-globalize)
7+
8+
## Help Needed
9+
10+
Looking for maintainers. See https://github.com/fabn/activeadmin-globalize/issues/26
11+
412
## Installation
513

14+
Current released version on rubygems is `1.0.0.pre`, I won't call it 1.0.0 until some issues has been solved,
15+
but, as reported in [this PR](https://github.com/fabn/activeadmin-globalize/pull/25) it should work with both
16+
AA 1.0.0 and AA 1.1.0.
17+
18+
Current version targets Rails 4 and greater and ActiveAdmin >= 1.0.0.
19+
620
```ruby
7-
gem 'activeadmin-globalize', '~> 0.6.3'
21+
gem 'activeadmin-globalize', '~> 1.0.0.pre'
822
```
923

10-
This version targets Rails 3.2.x only and ActiveAdmin ~> 0.6.3.
24+
Previous version with support for Rails 3 is maintained in branch [support/0.6.x](https://github.com/fabn/activeadmin-globalize/tree/support/0.6.x)
25+
26+
## Require Assets
27+
28+
- active_admin.js: `//= require active_admin/active_admin_globalize.js`
29+
- active_admin.css: `*= require active_admin/active_admin_globalize`
1130

1231
## Your model
1332

@@ -16,42 +35,93 @@ active_admin_translates :title, :description do
1635
validates_presence_of :title
1736
end
1837
```
19-
## Editor configuration
38+
## In your Active Admin resource definition
39+
40+
**Important note:** I'm working on a fix for #4 because after AA deprecated and then removed [#form_buffers](https://github.com/activeadmin/activeadmin/pull/3486) the
41+
syntax shown below for form declaration doesn't work as is. See comments in code and [discussion](#4) to fix it until I found a solution.
2042

2143
```ruby
44+
45+
# For usage with strong parameters you'll need to permit them
46+
permit_params translations_attributes: [:id, :locale, :title, :description, :_destroy]
47+
2248
index do
2349
# textual translation status
2450
translation_status
2551
# or with flag icons
2652
translation_status_flags
2753
# ...
28-
default_actions
54+
actions
2955
end
3056

57+
# This was the original syntax proposed in this gem, however currently it doesn't work
3158
form do |f|
3259
# ...
3360
f.translated_inputs "Translated fields", switch_locale: false do |t|
3461
t.input :title
35-
t.input :content
62+
t.input :description
63+
end
64+
# ...
65+
end
66+
67+
# Instead you have to nest the block inside an #inputs block and the title
68+
# should be passed to the inputs method
69+
form do |f|
70+
# ...
71+
f.inputs "Translated fields" do
72+
f.translated_inputs 'ignored title', switch_locale: false do |t|
73+
t.input :title
74+
t.input :description
75+
end
3676
end
3777
# ...
3878
end
79+
80+
# You can also set locales to show in tabs
81+
# For example we want to show English translation fields without tab, and want to show other languages within tabs
82+
form do |f|
83+
# ...
84+
f.inputs do
85+
Globalize.with_locale(:en) do
86+
f.input :title
87+
end
88+
end
89+
f.inputs "Translated fields" do
90+
f.translated_inputs 'ignored title', switch_locale: false, available_locales: (I18n.available_locales - [:en]) do |t|
91+
t.input :title
92+
t.input :description
93+
end
94+
end
95+
# ...
96+
end
97+
98+
# You can also set default language tab
99+
# For example we want to make Bengali translation tab as default
100+
form do |f|
101+
# ...
102+
f.inputs "Translated fields" do
103+
f.translated_inputs 'ignored title', switch_locale: false, default_locale: :bn do |t|
104+
t.input :title
105+
t.input :description
106+
end
107+
end
108+
# ...
109+
end
110+
39111
```
40112
If `switch_locale` is set, each tab will be rendered switching locale.
41113

42-
## Friendly ID
43-
44-
If you want to use Friendly ID together with Globalize, please take a look
45-
at the `activeadmin-seo` gem.
46114

47115
## Hints
48116

49117
To use the dashed locale keys as 'pt-BR' or 'pt-PT' you need to convert a string
50118
to symbol (in application.rb)
51119

120+
```ruby
52121
config.i18n.available_locales = [:en, :it, :de, :es, :"pt-BR"]
122+
```
53123

54124
## Credits
55125

56126
This work is based on original idea by [@stefanoverna](https://github.com/stefanoverna/activeadmin-globalize),
57-
I needed it for AA 0.6.x so I forked the original project.
127+
I needed it for AA 0.6.x so I forked the original project and expanded it with more features.

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.9.9

activeadmin-globalize.gemspec

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ Gem::Specification.new do |s|
1111
s.email = ['stefano.verna@gmail.com', 'f.napoleoni@gmail.com']
1212
s.homepage = 'http://github.com/fabn/activeadmin-globalize'
1313
s.summary = 'Handles globalize translations'
14-
s.description = 'Handles globalize translations in ActiveAdmin 0.6.3 and Rails 3.2.x'
14+
s.description = 'Handles globalize translations in ActiveAdmin 1.0 and Rails 4.x-5.x'
1515

1616
s.files = Dir['{app,config,db,lib}/**/*'] + %w(MIT-LICENSE README.md)
1717

18-
s.add_dependency 'activeadmin', '~> 0.6.3'
19-
s.add_dependency 'globalize', '~> 3.0.4'
18+
s.add_dependency 'activeadmin', '>= 1.0', '< 1.2'
19+
# Try to support rails from 3.2 up to 4.2.x
20+
s.add_dependency 'globalize', '>= 3.1.0', '< 6.0'
2021

2122
# development dependencies
2223
s.add_development_dependency 'bundler', '>= 1.6.1'
2324
s.add_development_dependency 'rake'
2425
# Other development dependencies moved into Gemfile
2526

2627
end
27-
119 Bytes
Loading
-42 Bytes
Binary file not shown.

app/assets/javascripts/active_admin/active_admin_globalize.js.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ $ ->
148148
$td = $(this).closest('td')
149149
$('.field-translation', $td).hide()
150150
$(".locale-#{$locale}", $td).show()
151+
$(this).parent().children('a.ui-translation-trigger').removeClass('active')
152+
$(this).addClass('active')
151153
e.preventDefault()
152154

153155
translations()
154-

0 commit comments

Comments
 (0)