Skip to content

Commit

Permalink
Merge pull request #1 from fabn/develop
Browse files Browse the repository at this point in the history
Update from fabn fork
  • Loading branch information
Rob Florence authored Aug 7, 2017
2 parents b5d61a7 + 49c219d commit 8ac8dee
Show file tree
Hide file tree
Showing 30 changed files with 304 additions and 56 deletions.
16 changes: 13 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
sudo: false
language: ruby
# Limit ruby versions to currently supported versions to avoid a big build matrix
rvm:
- 1.9.3
- 2.0.0
- 2.2
- 2.3.0
# Update bundler on travis, since current one is broken, see https://github.com/rubygems/rubygems/issues/1419
before_install:
- gem install bundler
# Load database schema before rake
before_script: bundle exec rake db:schema:load
before_script: bundle exec rake db:schema:load
# Test on all supported rails versions
gemfile:
- gemfiles/activeadmin_master.gemfile
- gemfiles/rails4_1.gemfile
- gemfiles/rails4_2.gemfile
15 changes: 15 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
appraise 'rails4_1' do
gem 'rails', '~> 4.1.12'
gem 'globalize', '~> 4.0.3'
end

appraise 'rails4_2' do
gem 'rails', '~> 4.2.3'
gem 'globalize', '~> 5.0.0'
end

# Run tests on latest github version of ActiveAdmin
appraise 'activeadmin_master' do
gem 'rails', '~> 4.2.0'
gem 'activeadmin', github: 'activeadmin/activeadmin'
end
9 changes: 4 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ gemspec
# gem 'debugger'

# Gems used by the dummy application
gem 'rails', '~> 4.0.0'
gem 'sass-rails', '~> 4.0.2'
gem 'sass-rails'
gem 'coffee-rails'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
Expand All @@ -25,21 +24,21 @@ gem 'uglifier'
# jquery-rails is
gem 'jquery-rails'

# Fetch activeadmin from github until is released
gem 'devise'
# ActiveAdmin requires devise < 4.0
gem 'devise', '~> 3.2'

group :test do
gem 'sqlite3', '~> 1.3.5'
gem 'rspec-rails', '~> 2.14.0'
gem 'factory_girl_rails', '~> 4.2.1'
gem 'database_cleaner', '~> 1.0.1'
gem 'guard-rspec', require: false
gem 'spring', require: false
gem 'spring-commands-rspec', require: false
gem 'capybara', '~> 2.1.0'
gem 'capybara-screenshot'
gem 'poltergeist'
gem 'fuubar'
gem 'appraisal'
# Useful to debug tests
gem 'awesome_print'
gem 'pry'
Expand Down
16 changes: 0 additions & 16 deletions Guardfile

This file was deleted.

57 changes: 53 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,79 @@ active_admin_translates :title, :description do
validates_presence_of :title
end
```
## Editor configuration
## In your Active Admin resource definition

**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
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.

```ruby

# For usage with strong parameters you'll need to permit them
permit_params translations_attributes: [:id, :locale, :title, :content, :_destroy]
permit_params translations_attributes: [:id, :locale, :title, :description, :_destroy]

index do
# textual translation status
translation_status
# or with flag icons
translation_status_flags
# ...
default_actions
actions
end

# This was the original syntax proposed in this gem, however currently it doesn't work
form do |f|
# ...
f.translated_inputs "Translated fields", switch_locale: false do |t|
t.input :title
t.input :content
t.input :description
end
# ...
end

# Instead you have to nest the block inside an #inputs block and the title
# should be passed to the inputs method
form do |f|
# ...
f.inputs "Translated fields" do
f.translated_inputs 'ignored title', switch_locale: false do |t|
t.input :title
t.input :description
end
end
# ...
end

# You can also set locales to show in tabs
# For example we want to show English translation fields without tab, and want to show other languages within tabs
form do |f|
# ...
f.inputs do
Globalize.with_locale(:en) do
f.input :title
end
end
f.inputs "Translated fields" do
f.translated_inputs 'ignored title', switch_locale: false, available_locales: (I18n.available_locales - [:en]) do |t|
t.input :title
t.input :description
end
end
# ...
end

# You can also set default language tab
# For example we want to make Bengali translation tab as default
form do |f|
# ...
f.inputs "Translated fields" do
f.translated_inputs 'ignored title', switch_locale: false, default_locale: :bn do |t|
t.input :title
t.input :description
end
end
# ...
end

```
If `switch_locale` is set, each tab will be rendered switching locale.

Expand Down
3 changes: 2 additions & 1 deletion activeadmin-globalize.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Gem::Specification.new do |s|
s.files = Dir['{app,config,db,lib}/**/*'] + %w(MIT-LICENSE README.md)

s.add_dependency 'activeadmin', '~> 1.0.0.pre'
s.add_dependency 'globalize', '~> 4.0'
# Try to support rails from 3.2 up to 4.2.x
s.add_dependency 'globalize', '>= 3.1.0', '< 6.0'

# development dependencies
s.add_development_dependency 'bundler', '>= 1.6.1'
Expand Down
Binary file modified app/assets/images/active_admin/flags.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/assets/images/active_admin/transparent.gif
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ $ ->
$td = $(this).closest('td')
$('.field-translation', $td).hide()
$(".locale-#{$locale}", $td).show()
$(this).parent().children('a.ui-translation-trigger').removeClass('active')
$(this).addClass('active')
e.preventDefault()

translations()

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Override flag positions in your stylesheet if you want to change default flags
.flag
display: inline-block
width: 16px
height: 11px
vertical-align: middle
Expand Down Expand Up @@ -33,10 +34,18 @@
background-position: -32px -22px
&.flag-en // originally flag-us
background-position: -48px -22px
&.flag-he // originally flag-il
background-position: 0 -33px

// Used to distantiate inline locale selector
span.inline-locale-selector
margin-right: 10px
> .ui-translation-trigger
opacity: .4
&.empty
filter: grayscale(100%)
&.active
opacity: 1

.field-translation.hidden
display: none
Expand All @@ -53,4 +62,4 @@ div.field-translation

// prevent tr height flickering
span.field-translation.empty
vertical-align: bottom
vertical-align: bottom
16 changes: 16 additions & 0 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
ar:
active_admin:
globalize:
translations: "ترجمة"
language:
de: "ألماني"
en: "الإنجليزية"
es: "الأسبانية"
fr: "اللغة الفرنسية"
hu: "الهنغارية"
it: "الإيطالي"
pt-BR: "البرتغالية"
pt-PT: "البرتغالية (البرتغال)"
tr: "اللغة التركية"
he: "العبرية"

2 changes: 2 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ de:
pt-BR: "Portugiesisch"
pt-PT: "Portugiesisch (Portugal)"
tr: "Türkisch"
he: "Hebräisch"
ar: "Arabisch"

2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ en:
pt-BR: "Portuguese"
pt-PT: "Portuguese (Portugal)"
tr: "Turkish"
he: "Hebrew"
ar: "Arabic"

17 changes: 17 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
es:
active_admin:
globalize:
translations: "Traducciones"
language:
de: "Alemán"
en: "Inglés"
es: "Español"
fr: "Francés"
hu: "Húngaro"
it: "Italiano"
pt-BR: "Portugués"
pt-PT: "Portugués (Portugal)"
tr: "Turco"
he: "Hebreo"
ar: "Arábica"

17 changes: 17 additions & 0 deletions config/locales/he.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
he:
active_admin:
globalize:
translations: "תרגומים"
language:
de: "גרמנית"
en: "אנגלית"
es: "ספרדית"
fr: "צרפתית"
hu: "הונגרית"
it: "איטלקית"
pt-BR: "פורטוגזית"
pt-PT: "פורטוגזית (פורטוגל)"
tr: "טורקית"
he: "עברית"
ar: "ערבית"

2 changes: 2 additions & 0 deletions config/locales/hu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ hu:
pt-BR: "Portuguese"
pt-PT: "Portuguese (Portugal)"
tr: "Török"
he: "Héber"
ar: "Arab"

2 changes: 2 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ it:
pt-BR: "Portoghese"
pt-PT: "Portoghese (Portogallo)"
tr: "Turco"
he: "Ebraico"
ar: "Arabo"

2 changes: 2 additions & 0 deletions config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ pt-BR:
pt-BR: "Português"
pt-PT: "Português (Portugal)"
tr: "Turco"
he: "Hebraico"
ar: "Árabe"

2 changes: 2 additions & 0 deletions config/locales/pt-PT.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ pt-PT:
pt-BR: "Português"
pt-PT: "Português (Portugal)"
tr: "Turco"
he: "Hebraico"
ar: "Árabe"

30 changes: 30 additions & 0 deletions gemfiles/activeadmin_master.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sass-rails"
gem "coffee-rails"
gem "therubyracer", :platforms => :ruby
gem "uglifier"
gem "jquery-rails"
gem "devise", "~> 3.2"
gem "rails", "~> 4.2.0"
gem "activeadmin", :github => "activeadmin/activeadmin"

group :test do
gem "sqlite3", "~> 1.3.5"
gem "rspec-rails", "~> 2.14.0"
gem "factory_girl_rails", "~> 4.2.1"
gem "database_cleaner", "~> 1.0.1"
gem "spring", :require => false
gem "spring-commands-rspec", :require => false
gem "capybara", "~> 2.1.0"
gem "capybara-screenshot"
gem "poltergeist"
gem "fuubar"
gem "appraisal"
gem "awesome_print"
gem "pry"
end

gemspec :path => "../"
30 changes: 30 additions & 0 deletions gemfiles/rails4_1.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file was generated by Appraisal

source "https://rubygems.org"

gem "sass-rails"
gem "coffee-rails"
gem "therubyracer", :platforms => :ruby
gem "uglifier"
gem "jquery-rails"
gem "devise", "~> 3.2"
gem "rails", "~> 4.1.12"
gem "globalize", "~> 4.0.3"

group :test do
gem "sqlite3", "~> 1.3.5"
gem "rspec-rails", "~> 2.14.0"
gem "factory_girl_rails", "~> 4.2.1"
gem "database_cleaner", "~> 1.0.1"
gem "spring", :require => false
gem "spring-commands-rspec", :require => false
gem "capybara", "~> 2.1.0"
gem "capybara-screenshot"
gem "poltergeist"
gem "fuubar"
gem "appraisal"
gem "awesome_print"
gem "pry"
end

gemspec :path => "../"
Loading

0 comments on commit 8ac8dee

Please sign in to comment.