Skip to content

Feature translation status country flags #15

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file added app/assets/images/ad.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ae.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/af.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ag.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ai.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/al.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/am.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/an.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ao.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ar.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/as.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/at.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/au.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/aw.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ax.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/az.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/ba.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bb.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bd.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/be.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bf.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bg.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bh.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bi.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bj.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/bm.gif
Binary file added app/assets/images/bn.gif
Binary file added app/assets/images/bo.gif
Binary file added app/assets/images/br.gif
Binary file added app/assets/images/bs.gif
Binary file added app/assets/images/bt.gif
Binary file added app/assets/images/bv.gif
Binary file added app/assets/images/bw.gif
Binary file added app/assets/images/by.gif
Binary file added app/assets/images/bz.gif
Binary file added app/assets/images/ca.gif
Binary file added app/assets/images/cc.gif
Binary file added app/assets/images/cd.gif
Binary file added app/assets/images/cf.gif
Binary file added app/assets/images/cg.gif
Binary file added app/assets/images/ch.gif
Binary file added app/assets/images/ci.gif
Binary file added app/assets/images/ck.gif
Binary file added app/assets/images/cl.gif
Binary file added app/assets/images/cm.gif
Binary file added app/assets/images/cn.gif
Binary file added app/assets/images/co.gif
Binary file added app/assets/images/cr.gif
Binary file added app/assets/images/cs.gif
Binary file added app/assets/images/cu.gif
Binary file added app/assets/images/cv.gif
Binary file added app/assets/images/cx.gif
Binary file added app/assets/images/cy.gif
Binary file added app/assets/images/cz.gif
Binary file added app/assets/images/de.gif
Binary file added app/assets/images/dj.gif
Binary file added app/assets/images/dk.gif
Binary file added app/assets/images/dm.gif
Binary file added app/assets/images/do.gif
Binary file added app/assets/images/dz.gif
Binary file added app/assets/images/ec.gif
Binary file added app/assets/images/ee.gif
Binary file added app/assets/images/eg.gif
Binary file added app/assets/images/eh.gif
Binary file added app/assets/images/en.gif
Binary file added app/assets/images/er.gif
Binary file added app/assets/images/es.gif
Binary file added app/assets/images/et.gif
Binary file added app/assets/images/fi.gif
Binary file added app/assets/images/fj.gif
Binary file added app/assets/images/fk.gif
Binary file added app/assets/images/fm.gif
Binary file added app/assets/images/fo.gif
Binary file added app/assets/images/fr.gif
Binary file added app/assets/images/ga.gif
Binary file added app/assets/images/gb.gif
Binary file added app/assets/images/gd.gif
Binary file added app/assets/images/ge.gif
Binary file added app/assets/images/gf.gif
Binary file added app/assets/images/gh.gif
Binary file added app/assets/images/gi.gif
Binary file added app/assets/images/gl.gif
Binary file added app/assets/images/gm.gif
Binary file added app/assets/images/gn.gif
Binary file added app/assets/images/gp.gif
Binary file added app/assets/images/gq.gif
Binary file added app/assets/images/gr.gif
Binary file added app/assets/images/gs.gif
Binary file added app/assets/images/gt.gif
Binary file added app/assets/images/gu.gif
Binary file added app/assets/images/gw.gif
Binary file added app/assets/images/gy.gif
Binary file added app/assets/images/hk.gif
Binary file added app/assets/images/hm.gif
Binary file added app/assets/images/hn.gif
Binary file added app/assets/images/hr.gif
Binary file added app/assets/images/ht.gif
Binary file added app/assets/images/hu.gif
Binary file added app/assets/images/id.gif
Binary file added app/assets/images/ie.gif
Binary file added app/assets/images/il.gif
Binary file added app/assets/images/in.gif
Binary file added app/assets/images/io.gif
Binary file added app/assets/images/iq.gif
Binary file added app/assets/images/ir.gif
Binary file added app/assets/images/is.gif
Binary file added app/assets/images/it.gif
Binary file added app/assets/images/jm.gif
Binary file added app/assets/images/jo.gif
Binary file added app/assets/images/jp.gif
Binary file added app/assets/images/ke.gif
Binary file added app/assets/images/kg.gif
Binary file added app/assets/images/kh.gif
Binary file added app/assets/images/ki.gif
Binary file added app/assets/images/km.gif
Binary file added app/assets/images/kn.gif
Binary file added app/assets/images/kp.gif
Binary file added app/assets/images/kr.gif
Binary file added app/assets/images/kw.gif
Binary file added app/assets/images/ky.gif
Binary file added app/assets/images/kz.gif
Binary file added app/assets/images/la.gif
Binary file added app/assets/images/lb.gif
Binary file added app/assets/images/lc.gif
Binary file added app/assets/images/li.gif
Binary file added app/assets/images/lk.gif
Binary file added app/assets/images/lr.gif
Binary file added app/assets/images/ls.gif
Binary file added app/assets/images/lt.gif
Binary file added app/assets/images/lu.gif
Binary file added app/assets/images/lv.gif
Binary file added app/assets/images/ly.gif
Binary file added app/assets/images/ma.gif
Binary file added app/assets/images/mc.gif
Binary file added app/assets/images/md.gif
Binary file added app/assets/images/me.gif
Binary file added app/assets/images/mg.gif
Binary file added app/assets/images/mh.gif
Binary file added app/assets/images/mk.gif
Binary file added app/assets/images/ml.gif
Binary file added app/assets/images/mm.gif
Binary file added app/assets/images/mn.gif
Binary file added app/assets/images/mo.gif
Binary file added app/assets/images/mp.gif
Binary file added app/assets/images/mq.gif
Binary file added app/assets/images/mr.gif
Binary file added app/assets/images/ms.gif
Binary file added app/assets/images/mt.gif
Binary file added app/assets/images/mu.gif
Binary file added app/assets/images/mv.gif
Binary file added app/assets/images/mw.gif
Binary file added app/assets/images/mx.gif
Binary file added app/assets/images/my.gif
Binary file added app/assets/images/mz.gif
Binary file added app/assets/images/na.gif
Binary file added app/assets/images/nc.gif
Binary file added app/assets/images/ne.gif
Binary file added app/assets/images/nf.gif
Binary file added app/assets/images/ng.gif
Binary file added app/assets/images/ni.gif
Binary file added app/assets/images/nl.gif
Binary file added app/assets/images/no.gif
Binary file added app/assets/images/np.gif
Binary file added app/assets/images/nr.gif
Binary file added app/assets/images/nu.gif
Binary file added app/assets/images/nz.gif
Binary file added app/assets/images/om.gif
Binary file added app/assets/images/pa.gif
Binary file added app/assets/images/pe.gif
Binary file added app/assets/images/pf.gif
Binary file added app/assets/images/pg.gif
Binary file added app/assets/images/ph.gif
Binary file added app/assets/images/pk.gif
Binary file added app/assets/images/pl.gif
Binary file added app/assets/images/pm.gif
Binary file added app/assets/images/pn.gif
Binary file added app/assets/images/pr.gif
Binary file added app/assets/images/ps.gif
Binary file added app/assets/images/pt.gif
Binary file added app/assets/images/pw.gif
Binary file added app/assets/images/py.gif
Binary file added app/assets/images/qa.gif
Binary file added app/assets/images/re.gif
Binary file added app/assets/images/ro.gif
Binary file added app/assets/images/rs.gif
Binary file added app/assets/images/ru.gif
Binary file added app/assets/images/rw.gif
Binary file added app/assets/images/sa.gif
Binary file added app/assets/images/sb.gif
Binary file added app/assets/images/sc.gif
Binary file added app/assets/images/sd.gif
Binary file added app/assets/images/se.gif
Binary file added app/assets/images/sg.gif
Binary file added app/assets/images/sh.gif
Binary file added app/assets/images/si.gif
Binary file added app/assets/images/sj.gif
Binary file added app/assets/images/sk.gif
Binary file added app/assets/images/sl.gif
Binary file added app/assets/images/sm.gif
Binary file added app/assets/images/sn.gif
Binary file added app/assets/images/so.gif
Binary file added app/assets/images/sr.gif
Binary file added app/assets/images/st.gif
Binary file added app/assets/images/sv.gif
Binary file added app/assets/images/sy.gif
Binary file added app/assets/images/sz.gif
Binary file added app/assets/images/tc.gif
Binary file added app/assets/images/td.gif
Binary file added app/assets/images/tf.gif
Binary file added app/assets/images/tg.gif
Binary file added app/assets/images/th.gif
Binary file added app/assets/images/tj.gif
Binary file added app/assets/images/tk.gif
Binary file added app/assets/images/tl.gif
Binary file added app/assets/images/tm.gif
Binary file added app/assets/images/tn.gif
Binary file added app/assets/images/to.gif
Binary file added app/assets/images/tr.gif
Binary file added app/assets/images/tt.gif
Binary file added app/assets/images/tv.gif
Binary file added app/assets/images/tw.gif
Binary file added app/assets/images/tz.gif
Binary file added app/assets/images/ua.gif
Binary file added app/assets/images/ug.gif
Binary file added app/assets/images/um.gif
Binary file added app/assets/images/us.gif
Binary file added app/assets/images/uy.gif
Binary file added app/assets/images/uz.gif
Binary file added app/assets/images/va.gif
Binary file added app/assets/images/vc.gif
Binary file added app/assets/images/ve.gif
Binary file added app/assets/images/vg.gif
Binary file added app/assets/images/vi.gif
Binary file added app/assets/images/vn.gif
Binary file added app/assets/images/vu.gif
Binary file added app/assets/images/wf.gif
Binary file added app/assets/images/ws.gif
Binary file added app/assets/images/ye.gif
Binary file added app/assets/images/yt.gif
Binary file added app/assets/images/za.gif
Binary file added app/assets/images/zm.gif
Binary file added app/assets/images/zw.gif
10 changes: 10 additions & 0 deletions lib/active_admin/globalize3/engine.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'active_admin/globalize3/filter_empty_translations'

module ActiveAdmin
module Globalize3
class Engine < ::Rails::Engine
Expand All @@ -13,6 +15,14 @@ class Engine < ::Rails::Engine
ActiveAdmin.application.register_javascript "active_admin/active_admin_globalize3.js"
end

# Register a before_filter in ActionController that will filter out
# empty translations submitted by activeadmin-globalize3.
# See ActiveAdmin::Globalize3::FilterEmptyTranslations#filter_empty_translations
initializer "activeadmin-globalize3.load_helpers" do |app|
ActionController::Base.send :include, ActiveAdmin::Globalize3::FilterEmptyTranslations
ActionController::Base.send :before_filter, :filter_empty_translations, only: [:create, :update]
end

end
end
end
48 changes: 48 additions & 0 deletions lib/active_admin/globalize3/filter_empty_translations.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
module ActiveAdmin
module Globalize3
module FilterEmptyTranslations
private
# Activeadmin-globalize3 renders inputs for all translations,
# resulting in many empty translations being created by globalize.
#
# For instance, given the available locales L1, L2 and L2, the
# following params would be submitted on 'create':
#
# {
# :
# MODEL => {
# "translations_attributes" => {
# "0" => {
# "locale"=>"L1", "id" => "", ATTR1 => "", ATTR2 => "", ...
# }
# "1" => {
# "locale"=>"L2", "id" => "", ATTR1 => "", ATTR2 => "", ...
# }
# "2" => {
# "locale"=>"L3", "id" => "", ATTR1 => "", ATTR2 => "", ...
# }
# }
# }
# :
# }
#
# Given these parameters, globalize3 would create a record for every
# possible translation - even empty ones.
#
# This filter removes all empty and unsaved translations from params
# and marks empty and saved translation for deletion.
def filter_empty_translations
model = controller_name.singularize.to_sym
params[model][:translations_attributes].each do |t|
if !(t.last.map { |_, v| v.empty? ? true : false }[2..-1]).include?(false)
if t.last[:id].empty?
params[model][:translations_attributes].delete(t.first)
else
params[model][:translations_attributes][t.first]['_destroy'] = '1'
end
end
end
end
end
end
end
7 changes: 7 additions & 0 deletions lib/active_admin/globalize3/index_table_for_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ def translation_status
end.join(" ").html_safe
end
end
def translation_status_flags
column I18n.t("active_admin.globalize3.translations") do |obj|
obj.translated_locales.map do |l|
image_tag '%s.gif' % [ l.to_s ]
end.join(" ").html_safe
end
end
end
end
end
Expand Down