Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update from fabn fork #1

Merged
merged 25 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
f02fc8d
Installed appraisal gem to test gems against all supported rails and …
fabn Jul 9, 2015
213150d
Removed rails 3.2 from appraisal for this version
fabn Jul 9, 2015
ec73a8b
Status update in Readme
fabn Jul 9, 2015
e4d934f
available_locales option in translated_inputs form builder function
raihan2006i Jul 28, 2015
1bffdb9
default localte option in translated_inputs form builder method
raihan2006i Jul 28, 2015
44001c4
Removed auto_sort option from translated_inputs form builder helper
raihan2006i Aug 7, 2015
7be435c
Merge pull request #10 from raihan2006i/develop
fabn Aug 7, 2015
4175d4c
Rename active_admin_globalize.css.sass to active_admin_globalize.sass
JeansReal Oct 6, 2015
72295f3
Rename active_admin_globalize_flags.css.sass to active_admin_globaliz…
JeansReal Oct 6, 2015
9b4d677
Merge pull request #12 from JeansReal/develop
fabn Oct 6, 2015
f126166
Get rid of transparent.gif in favour of a <i>
humancopy Apr 27, 2016
54af859
README
humancopy Apr 27, 2016
60a5b9e
Add Hebrew & Spanish translations
humancopy Apr 27, 2016
815d03d
Add title attribute with the locale's name
humancopy Apr 27, 2016
e1bfacd
Updated travis configuration
fabn Apr 29, 2016
9700934
Fix failing build
fabn Apr 29, 2016
5f23d3d
Merge branch 'develop' of https://github.com/humancopy/activeadmin-gl…
fabn Apr 29, 2016
4ea5a1f
Merge branch 'feature/pull-13' into develop
fabn Apr 29, 2016
50f9562
Pin devise at version 3.x
fabn Apr 29, 2016
034b224
Fixed failing tests
fabn Apr 29, 2016
c5e8d39
Add Arabic
humancopy May 11, 2016
7d7724b
Merge pull request #15 from humancopy/develop
fabn May 11, 2016
afc011c
Removed guard to avoid listen gem issues on travis
fabn May 11, 2016
3477d6a
In translated_row, use gray flags for empty values and transparent fl…
jtomaszewski Nov 20, 2016
49c219d
Merge pull request #18 from jtomaszewski/fix/inactive-flags
fabn Nov 30, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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