active_i18n 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +105 -0
- data/Rakefile +35 -0
- data/app/assets/images/active_i18n/flags.png +0 -0
- data/app/assets/javascripts/active_i18n.js +1 -0
- data/app/assets/javascripts/active_i18n/layout.js.coffee +31 -0
- data/app/assets/stylesheets/active_i18n.css.sass +5 -0
- data/app/assets/stylesheets/active_i18n/application.css +13 -0
- data/app/assets/stylesheets/active_i18n/flags.css.scss +258 -0
- data/app/assets/stylesheets/active_i18n/list.css.sass +70 -0
- data/app/assets/stylesheets/active_i18n/sidebar.css.sass +60 -0
- data/app/assets/stylesheets/active_i18n/structure.css.sass +4 -0
- data/app/controllers/active_i18n/application_controller.rb +4 -0
- data/app/helpers/active_i18n/view_helper.rb +66 -0
- data/app/views/active_i18n/_content.html.haml +36 -0
- data/app/views/active_i18n/_sidebar.html.haml +5 -0
- data/app/views/layouts/active_i18n/application.html.erb +14 -0
- data/config/locales/en.yml +76 -0
- data/config/routes.rb +2 -0
- data/lib/active_i18n.rb +32 -0
- data/lib/active_i18n/active_admin.rb +28 -0
- data/lib/active_i18n/base_store.rb +42 -0
- data/lib/active_i18n/engine.rb +18 -0
- data/lib/active_i18n/translations_store.rb +26 -0
- data/lib/active_i18n/version.rb +3 -0
- data/lib/tasks/active_i18n_tasks.rake +4 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/admin/admin_users.rb +20 -0
- data/spec/dummy/app/admin/dashboard.rb +33 -0
- data/spec/dummy/app/admin/translation.rb +4 -0
- data/spec/dummy/app/assets/javascripts/active_admin.js +2 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/active_admin.css.scss +32 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/admin_user.rb +17 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +66 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/active_admin.rb +210 -0
- data/spec/dummy/config/initializers/active_i18n.rb +3 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/devise.rb +256 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/devise.en.yml +59 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/locales/en_test.yml +7 -0
- data/spec/dummy/config/locales/pl_test.yml +5 -0
- data/spec/dummy/config/routes.rb +7 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/migrate/20140811102607_devise_create_admin_users.rb +48 -0
- data/spec/dummy/db/migrate/20140811102609_create_admin_notes.rb +17 -0
- data/spec/dummy/db/migrate/20140811102610_move_admin_notes_to_comments.rb +26 -0
- data/spec/dummy/db/schema.rb +49 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +36840 -0
- data/spec/dummy/log/test.log +961 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/dummy/spec/factories/admin_users.rb +6 -0
- data/spec/dummy/spec/models/admin_user_spec.rb +5 -0
- data/spec/dummy/tmp/cache/assets/C58/410/sprockets%2F5c7886d2d5716b050cd38b9121769471 +0 -0
- data/spec/dummy/tmp/cache/assets/C7F/FE0/sprockets%2Fd8b50477b1b153638c7346534a0877da +0 -0
- data/spec/dummy/tmp/cache/assets/C8C/900/sprockets%2F1112043d14fe51296aa033bd024d0b78 +0 -0
- data/spec/dummy/tmp/cache/assets/C9A/D60/sprockets%2Fa62368179337c7154198e2786eeec9a8 +0 -0
- data/spec/dummy/tmp/cache/assets/CAD/C50/sprockets%2F8319a9f588005b0a424b90472c6a9a3f +0 -0
- data/spec/dummy/tmp/cache/assets/CAF/020/sprockets%2F9454bc172681345fa525aff08281b74c +0 -0
- data/spec/dummy/tmp/cache/assets/CB8/1D0/sprockets%2Fb510c0fc9803866436178e77582c7bad +0 -0
- data/spec/dummy/tmp/cache/assets/CBC/0B0/sprockets%2Fc0bba633769759659c7d4f0a2224499d +0 -0
- data/spec/dummy/tmp/cache/assets/CBF/620/sprockets%2F109dfac52e95799730667ba8e11e2765 +0 -0
- data/spec/dummy/tmp/cache/assets/CCD/670/sprockets%2F08edc1d5a073b0625304ba682985a24b +0 -0
- data/spec/dummy/tmp/cache/assets/CDB/040/sprockets%2Fc732474e67003a4eb840eb44c5ca9385 +0 -0
- data/spec/dummy/tmp/cache/assets/CDD/600/sprockets%2F65df7604a9339ce6a3d1923b472ee400 +0 -0
- data/spec/dummy/tmp/cache/assets/CE1/540/sprockets%2F305fa586dc7c7615d59e593120abf353 +0 -0
- data/spec/dummy/tmp/cache/assets/CEA/470/sprockets%2F8303f8f5f77c51100f64ff283ea6757a +0 -0
- data/spec/dummy/tmp/cache/assets/CEC/BA0/sprockets%2F7c5072074b471dff1cbf726f3786e548 +0 -0
- data/spec/dummy/tmp/cache/assets/D10/870/sprockets%2F5e7ab7f11ed7390a5ff8950121c40e49 +0 -0
- data/spec/dummy/tmp/cache/assets/D24/D10/sprockets%2Ff884c60f003f6ce75e3ef9f53891375a +0 -0
- data/spec/dummy/tmp/cache/assets/D28/200/sprockets%2Fb030b1c02160352cc756faec0ef883d5 +0 -0
- data/spec/dummy/tmp/cache/assets/D29/620/sprockets%2F3d664b0b71ca2fb901d77dce24215a32 +0 -0
- data/spec/dummy/tmp/cache/assets/D2D/2F0/sprockets%2Fd8ccd71f1767785f8489039e3d6c8a5b +0 -0
- data/spec/dummy/tmp/cache/assets/D33/CA0/sprockets%2F4dbc63d52f13068b8e72f3dd1107ba27 +0 -0
- data/spec/dummy/tmp/cache/assets/D36/2D0/sprockets%2Fcdfd2af48a61389a0dc7c751025504b7 +0 -0
- data/spec/dummy/tmp/cache/assets/D38/540/sprockets%2F86e1ad844bc9df4491a2a52b870421db +0 -0
- data/spec/dummy/tmp/cache/assets/D41/DE0/sprockets%2F9c89ee33751a67901a0ceead0d82781b +0 -0
- data/spec/dummy/tmp/cache/assets/D43/110/sprockets%2Fd5e364fe2e128443f5250e419af9bbc8 +0 -0
- data/spec/dummy/tmp/cache/assets/D44/3F0/sprockets%2F29e1206c858c89cf5453cf370dc2eca4 +0 -0
- data/spec/dummy/tmp/cache/assets/D45/110/sprockets%2F87892bd05e664b62bdbbc1e3704b67d9 +0 -0
- data/spec/dummy/tmp/cache/assets/D45/240/sprockets%2F5fa87c4a361e5f2866c52e12257c9ead +0 -0
- data/spec/dummy/tmp/cache/assets/D46/EB0/sprockets%2F663efa9a78c238c8a3aaf09a07d74627 +0 -0
- data/spec/dummy/tmp/cache/assets/D48/640/sprockets%2F9f4f18d910b678b1d0777e04cdaf6f24 +0 -0
- data/spec/dummy/tmp/cache/assets/D4B/C50/sprockets%2Ff28e143f4b4887e0f5e8cff05227c55b +0 -0
- data/spec/dummy/tmp/cache/assets/D59/D70/sprockets%2Fed9f0de1b65ae8d7ef89087c83728461 +0 -0
- data/spec/dummy/tmp/cache/assets/D60/F90/sprockets%2F85a232fb35c16bf87279047aa1ccbbb2 +0 -0
- data/spec/dummy/tmp/cache/assets/D62/770/sprockets%2F76a285eb6576ee1f11132bcd07f0eea0 +0 -0
- data/spec/dummy/tmp/cache/assets/D67/0C0/sprockets%2F09eed8ed6f341c0c429007ab0219ee7c +0 -0
- data/spec/dummy/tmp/cache/assets/D68/E10/sprockets%2F36d13da052a68af78a38a6dec93bd900 +0 -0
- data/spec/dummy/tmp/cache/assets/D6C/2F0/sprockets%2F107964995ee0c0bae0b46fdae574fa42 +0 -0
- data/spec/dummy/tmp/cache/assets/D6D/540/sprockets%2Fedbc4e34cd1e2cc70b7428678932aa92 +0 -0
- data/spec/dummy/tmp/cache/assets/D72/C80/sprockets%2Fa1430f4544581c9e76e56fcfdbe41c3e +0 -0
- data/spec/dummy/tmp/cache/assets/D7B/5F0/sprockets%2Fa4b788c26c44568cb71b3c79edc4b7f4 +0 -0
- data/spec/dummy/tmp/cache/assets/D8A/7E0/sprockets%2F2ce302007a5d81840ddc07b7cb1d5ffc +0 -0
- data/spec/dummy/tmp/cache/assets/D8F/670/sprockets%2F810ec022c6fe22bdec817bd7c0d808c1 +0 -0
- data/spec/dummy/tmp/cache/assets/D93/4C0/sprockets%2F857ecd2092cee11f740b3cf2e373ad2a +0 -0
- data/spec/dummy/tmp/cache/assets/D97/F90/sprockets%2Fc016a87d244c59a9a39ca8a90febe10b +0 -0
- data/spec/dummy/tmp/cache/assets/DA4/970/sprockets%2Fa93e382f3ec0e5b8cf765c062b946bcd +0 -0
- data/spec/dummy/tmp/cache/assets/DA8/D80/sprockets%2F0c96c0d9696bd756aad0d36bcf77db47 +0 -0
- data/spec/dummy/tmp/cache/assets/DBB/7C0/sprockets%2F00b6b9b17a4f12bae8eb17ef61abe731 +0 -0
- data/spec/dummy/tmp/cache/assets/DC7/A30/sprockets%2F5c6134fae4cb1a1dc4ae77cf661d42e9 +0 -0
- data/spec/dummy/tmp/cache/assets/DC9/A70/sprockets%2Fa0ca172bddf418f3ccd34a8e77725a8d +0 -0
- data/spec/dummy/tmp/cache/assets/DCE/840/sprockets%2F266fbe1ca258f3ccfec16753dafd4409 +0 -0
- data/spec/dummy/tmp/cache/assets/DDE/420/sprockets%2Ffb8b186d5bf0307f86f65fc787d2adeb +0 -0
- data/spec/dummy/tmp/cache/assets/DEE/CC0/sprockets%2Fa3dbe0de23a16d72f3abc3cd9388b80a +0 -0
- data/spec/dummy/tmp/cache/assets/DF1/BE0/sprockets%2Fcbdfaa7ea4d66d31e20da6754b4534dc +0 -0
- data/spec/dummy/tmp/cache/assets/DFA/E20/sprockets%2Ffe14bdb79b2a9dbf0b539198d3aba6b4 +0 -0
- data/spec/dummy/tmp/cache/assets/E27/B80/sprockets%2Fbced6cfc13bcfab45a1fa5b479d15486 +0 -0
- data/spec/dummy/tmp/cache/assets/E57/9A0/sprockets%2Fdf25986ad4babcf83acc6ac19e2a04fd +0 -0
- data/spec/lib/active_i18n_base_score_spec.rb +21 -0
- data/spec/lib/active_i18n_spec.rb +27 -0
- data/spec/lib/active_i18n_translations_store_spec.rb +34 -0
- data/spec/spec_helper.rb +15 -0
- metadata +471 -0
@@ -0,0 +1,70 @@
|
|
1
|
+
.active-i19n-list > .lang
|
2
|
+
height: 35px
|
3
|
+
|
4
|
+
|
5
|
+
.active-i19n-list > .panel
|
6
|
+
background: transparent
|
7
|
+
& > h3
|
8
|
+
margin-bottom: 0
|
9
|
+
& > *
|
10
|
+
color: #7f8c8d
|
11
|
+
font-weight: 400
|
12
|
+
padding-right: 6px
|
13
|
+
font-size: 14px
|
14
|
+
text-decoration: none
|
15
|
+
i.fa
|
16
|
+
margin-right: 5px
|
17
|
+
color: #2c3e50
|
18
|
+
.panel_contents
|
19
|
+
padding: 0
|
20
|
+
|
21
|
+
|
22
|
+
.active-i19n-list .translation
|
23
|
+
border-bottom: #d3d8dc 1px solid
|
24
|
+
font-size: 14px
|
25
|
+
& > div
|
26
|
+
min-height: 90px
|
27
|
+
border-bottom: #d3d8dc 1px solid
|
28
|
+
text-overflow: ellipsis
|
29
|
+
overflow: hidden
|
30
|
+
&:last-child
|
31
|
+
border: none
|
32
|
+
.original
|
33
|
+
background: #fff
|
34
|
+
overflow: hidden
|
35
|
+
.lang
|
36
|
+
border-color: transparent
|
37
|
+
|
38
|
+
.lang
|
39
|
+
color: #7f8c8d
|
40
|
+
float: left
|
41
|
+
width: 130px
|
42
|
+
height: 90px
|
43
|
+
p
|
44
|
+
padding: 12px 15px
|
45
|
+
margin-bottom: 0
|
46
|
+
.flag
|
47
|
+
margin-right: 8px
|
48
|
+
.content-wrapper
|
49
|
+
border-left: #d3d8dc 1px solid
|
50
|
+
margin-left: 130px
|
51
|
+
min-height: 90px
|
52
|
+
.content
|
53
|
+
padding: 12px 15px
|
54
|
+
&.blank
|
55
|
+
color: #7f8c8d
|
56
|
+
font-style: italic
|
57
|
+
fieldset.inputs
|
58
|
+
padding-top: 0px
|
59
|
+
background: transparent
|
60
|
+
border: none
|
61
|
+
margin-bottom: 0px
|
62
|
+
padding-bottom: 0
|
63
|
+
textarea
|
64
|
+
height: 50px
|
65
|
+
fieldset.actions
|
66
|
+
margin-left: 10px
|
67
|
+
margin-top: 0px
|
68
|
+
padding-top: 0px
|
69
|
+
.translated .content-wrapper .content
|
70
|
+
cursor: pointer
|
@@ -0,0 +1,60 @@
|
|
1
|
+
.admin_translations #sidebar
|
2
|
+
.sidebar_section
|
3
|
+
background: transparent
|
4
|
+
.panel_contents
|
5
|
+
margin: 0
|
6
|
+
padding: 0
|
7
|
+
form.filter_form
|
8
|
+
padding: 15px
|
9
|
+
border-bottom: 1px solid #d3d8dc
|
10
|
+
input
|
11
|
+
padding: 8px
|
12
|
+
.scopes-list
|
13
|
+
padding: 15px
|
14
|
+
color: #7f8c8d
|
15
|
+
font-size: 13px
|
16
|
+
p
|
17
|
+
padding: 0 0 4px 0
|
18
|
+
margin: 0
|
19
|
+
i.fa
|
20
|
+
margin-right: 8px
|
21
|
+
color: #2c3e50
|
22
|
+
ul
|
23
|
+
list-style: none
|
24
|
+
padding: 0
|
25
|
+
margin: 0
|
26
|
+
ul ul
|
27
|
+
border-left: #d3d8dc 1px solid
|
28
|
+
margin-left: 5px
|
29
|
+
li
|
30
|
+
list-style: none
|
31
|
+
padding: 0
|
32
|
+
margin: 0
|
33
|
+
padding: 2px 0 2px 10px
|
34
|
+
|
35
|
+
li li
|
36
|
+
background: image-url("active_i18n/li.png") no-repeat 0 10px
|
37
|
+
&:last-child
|
38
|
+
padding-bottom: 0
|
39
|
+
li.unselected ul
|
40
|
+
display: none
|
41
|
+
li.selected > p
|
42
|
+
a
|
43
|
+
color: #2c3e50
|
44
|
+
font-weight: 600
|
45
|
+
& > i
|
46
|
+
&.close
|
47
|
+
display: none
|
48
|
+
&.open
|
49
|
+
display: inline
|
50
|
+
color: #e74c3c
|
51
|
+
li.unselected > p > i
|
52
|
+
&.close
|
53
|
+
display: inline
|
54
|
+
&.open
|
55
|
+
display: none
|
56
|
+
a
|
57
|
+
color: #7f8c8d
|
58
|
+
text-decoration: none
|
59
|
+
&:hover
|
60
|
+
text-decoration: underline
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module ActiveI18n
|
2
|
+
module ViewHelper
|
3
|
+
def render_scopes
|
4
|
+
capture_haml do
|
5
|
+
ActiveI18n::BaseStore.scopes.each_pair do |key, value|
|
6
|
+
haml_concat li_scope(key, value, key.to_s)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def available_locales
|
12
|
+
capture_haml do
|
13
|
+
haml_tag :select, id: "change_locale" do
|
14
|
+
I18n.available_locales.each do |locale|
|
15
|
+
haml_tag :option,
|
16
|
+
value: locale,
|
17
|
+
selected: locale == ActiveI18n.locale,
|
18
|
+
data: {url: url_for(translation_locale: locale)} do
|
19
|
+
haml_concat [locale.to_s, I18n.t(locale, :scope => "active_i18n.languages", :locale => :en)].join(" - ")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def li_scope(key, value, scope)
|
27
|
+
return unless ActiveI18n::BaseStore.is_scope?(value)
|
28
|
+
capture_haml do
|
29
|
+
haml_tag :li, :class => params[:scope].to_s.match(scope) ? "selected" : "unselected" do
|
30
|
+
haml_tag :p do
|
31
|
+
haml_tag(:i, "", :class => "close fa fa-folder")
|
32
|
+
haml_tag(:i, "", :class => "open fa fa-folder-open")
|
33
|
+
haml_tag :a, :href => admin_translations_path(scope: scope) do
|
34
|
+
haml_concat key
|
35
|
+
end
|
36
|
+
end
|
37
|
+
haml_tag :ul do
|
38
|
+
haml_concat value.collect{|k, v| li_scope(k, v, scope+"."+k.to_s)}.join("").html_safe
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def scope_table(scope)
|
45
|
+
capture_haml do
|
46
|
+
ActiveI18n::BaseStore.translations(scope).each do |e|
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def linkify_scope(scope="")
|
53
|
+
link_scopes = []
|
54
|
+
capture_haml do
|
55
|
+
scope.to_s.split(".").each_with_index do |key, i|
|
56
|
+
haml_tag :span, ">>", :class => "breadcrumb_sep" if i!=0
|
57
|
+
link_scopes.push key
|
58
|
+
haml_tag :a, :href => admin_translations_path(scope: link_scopes.join(".")) do
|
59
|
+
haml_tag :i, :class => "fa fa-folder-open"
|
60
|
+
haml_concat key.to_s
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
.active-i19n-list
|
2
|
+
.lang= available_locales
|
3
|
+
|
4
|
+
.panel
|
5
|
+
%h3=linkify_scope(params[:scope])
|
6
|
+
|
7
|
+
.panel_contents
|
8
|
+
- ActiveI18n::BaseStore.translations(params[:scope]).each do |key_value|
|
9
|
+
.translation
|
10
|
+
.original
|
11
|
+
.lang
|
12
|
+
%p
|
13
|
+
%i.flag{:class => "flag-#{I18n.default_locale.to_s}"}
|
14
|
+
= t(I18n.default_locale, :scope => "active_i18n.languages")
|
15
|
+
.content-wrapper
|
16
|
+
.content
|
17
|
+
= I18n.t(key_value[0], :scope => params[:scope], :locale => I18n.default_locale)
|
18
|
+
.translated
|
19
|
+
.lang
|
20
|
+
%p
|
21
|
+
%i.flag{class: "flag-#{ActiveI18n.locale}"}
|
22
|
+
= t(ActiveI18n.locale, :scope => "active_i18n.languages")
|
23
|
+
- if false
|
24
|
+
%p
|
25
|
+
%b ONE
|
26
|
+
.content-wrapper
|
27
|
+
.content{:class => I18n.t(key_value[0], :scope => params[:scope], :locale => ActiveI18n.locale, :default => "").present? ? "present" : "blank"}
|
28
|
+
= I18n.t(key_value[0], :scope => params[:scope], :locale => ActiveI18n.locale, :default => t(:no_translation, :scope => "active_i18n.labels"))
|
29
|
+
= semantic_form_for "translation", url: url_for(scope: params[:scope], key: key_value[0], :action => "translate") do |f|
|
30
|
+
= f.inputs do
|
31
|
+
= f.input :content, :as => :text, :label => false, :input_html => {:value => I18n.t(key_value[0], :scope => params[:scope], :locale => ActiveI18n.locale, :default => "")}
|
32
|
+
= f.actions do
|
33
|
+
= f.action :submit, :as => :input
|
34
|
+
= f.action :cancel, :as => :link, :wrapper_html => {:class => "cancel"}
|
35
|
+
|
36
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>ActiveI18n</title>
|
5
|
+
<%= stylesheet_link_tag "active_i18n/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "active_i18n/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,76 @@
|
|
1
|
+
en:
|
2
|
+
active_i18n:
|
3
|
+
labels:
|
4
|
+
translations: Translations
|
5
|
+
scopes: "Scopes"
|
6
|
+
search:placecholder: Search translation
|
7
|
+
no_translation: No translation
|
8
|
+
languages:
|
9
|
+
af: Afrikaans
|
10
|
+
sq: Albanian
|
11
|
+
ar: Arabic
|
12
|
+
eu: Basque
|
13
|
+
be: Belarusian
|
14
|
+
bs: Bosnian
|
15
|
+
bg: Bulgarian
|
16
|
+
ca: Catalan
|
17
|
+
hr: Croatian
|
18
|
+
zh_cn: Chinese
|
19
|
+
zh_tw: Chinese
|
20
|
+
cs: Czech
|
21
|
+
da: Danish
|
22
|
+
nl: Dutch
|
23
|
+
en: English
|
24
|
+
en:us: English
|
25
|
+
et: Estonian
|
26
|
+
fa: Farsi
|
27
|
+
fil: Filipino
|
28
|
+
fi: Finnish
|
29
|
+
fr: French
|
30
|
+
ga: Gaelic
|
31
|
+
gl: Gallego
|
32
|
+
ka: Georgian
|
33
|
+
de: German
|
34
|
+
de:du: German
|
35
|
+
el: Greek
|
36
|
+
gu: Gujarati
|
37
|
+
he: Hebrew
|
38
|
+
hi: Hindi
|
39
|
+
hu: Hungarian
|
40
|
+
is: Icelandic
|
41
|
+
id: Indonesian
|
42
|
+
it: Italian
|
43
|
+
ja: Japanese
|
44
|
+
kn: Kannada
|
45
|
+
km: Khmer
|
46
|
+
ko: Korean
|
47
|
+
lo: Lao
|
48
|
+
lt: Lithuanian
|
49
|
+
lv: Latvian
|
50
|
+
ml: Malayalam
|
51
|
+
ms: Malaysian
|
52
|
+
mi:tn: Maori
|
53
|
+
mi:wwow: Maori
|
54
|
+
mn: Mongolian
|
55
|
+
no: Norwegian
|
56
|
+
no:gr: Norwegian
|
57
|
+
nn: Nynorsk
|
58
|
+
pl: Polish
|
59
|
+
pt: Portuguese
|
60
|
+
pt:br: Portuguese
|
61
|
+
ro: Romanian
|
62
|
+
ru: Russian
|
63
|
+
sm: Samoan
|
64
|
+
sr: Serbian
|
65
|
+
sk: Slovak
|
66
|
+
sl: Slovenian
|
67
|
+
so: Somali
|
68
|
+
es: Spanish
|
69
|
+
sv: Swedish
|
70
|
+
tl: Tagalog
|
71
|
+
ta: Tamil
|
72
|
+
th: Thai
|
73
|
+
to: Tongan
|
74
|
+
tr: Turkish
|
75
|
+
uk: Ukrainian
|
76
|
+
vi: Vietnamese
|
data/config/routes.rb
ADDED
data/lib/active_i18n.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require "activeadmin"
|
2
|
+
require "active_i18n/engine"
|
3
|
+
require "active_i18n/base_store"
|
4
|
+
require "active_i18n/translations_store"
|
5
|
+
require "active_i18n/active_admin"
|
6
|
+
|
7
|
+
module ActiveI18n
|
8
|
+
def self.config(config)
|
9
|
+
throw "You have to define store for translations" unless config[:store]
|
10
|
+
translations_store = config[:store]
|
11
|
+
base_store = I18n.backend
|
12
|
+
I18n.backend = I18n::Backend::Chain.new(translations_store, base_store)
|
13
|
+
BaseStore.set_backend(base_store)
|
14
|
+
BaseStore.set_except_filter(config[:except]) if config[:except]
|
15
|
+
TranslationsStore.set_backend(translations_store)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.store_translation(value, scope)
|
19
|
+
TranslationsStore.store_translation(value, scope, locale)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.setLocale(locale)
|
23
|
+
if I18n.available_locales.include?(locale.to_sym)
|
24
|
+
@locale = locale.to_sym
|
25
|
+
return true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.locale
|
30
|
+
@locale ||= I18n.available_locales.sort{|a| a == I18n.default_locale ? 1 : -1}.first
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
ActiveAdmin.module_eval do
|
3
|
+
def self.register_translation name, menu_options = {}
|
4
|
+
|
5
|
+
self.register_page name do
|
6
|
+
menu({:label => proc{ I18n.t("active_i18n.labels.translations") }}.merge(menu_options))
|
7
|
+
|
8
|
+
sidebar "Translations", :class => "active", :partial => "active_i18n/sidebar"
|
9
|
+
|
10
|
+
content do
|
11
|
+
render("active_i18n/content")
|
12
|
+
end
|
13
|
+
|
14
|
+
controller do
|
15
|
+
before_filter :set_locale, :only => :index
|
16
|
+
|
17
|
+
def set_locale
|
18
|
+
ActiveI18n.setLocale(params[:translation_locale]) if params[:translation_locale]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
page_action :translate, :method => :post do
|
23
|
+
ActiveI18n.store_translation(params[:translation], [params[:scope], params[:key]].join("."))
|
24
|
+
render :text => params[:translation]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module ActiveI18n
|
2
|
+
module BaseStore
|
3
|
+
extend(Module.new {
|
4
|
+
def set_backend(backend)
|
5
|
+
@backend = backend
|
6
|
+
end
|
7
|
+
|
8
|
+
def set_except_filter(array)
|
9
|
+
@except_filter = array
|
10
|
+
end
|
11
|
+
|
12
|
+
def scopes
|
13
|
+
translations_hash
|
14
|
+
end
|
15
|
+
|
16
|
+
def translations_hash
|
17
|
+
t = @backend.send(:translations)[I18n.default_locale]
|
18
|
+
t = filter(t) if @except_filter
|
19
|
+
t
|
20
|
+
end
|
21
|
+
|
22
|
+
def translations(scope)
|
23
|
+
return [] unless scope
|
24
|
+
scope.split(".").inject(translations_hash){|m,e| m = m[e.to_sym]}.select{|a| !is_scope?(a)}
|
25
|
+
end
|
26
|
+
|
27
|
+
def is_scope?(value)
|
28
|
+
value.kind_of? Hash
|
29
|
+
end
|
30
|
+
|
31
|
+
def filter(original)
|
32
|
+
@except_filter.each do |except_scope|
|
33
|
+
if except_scope.to_s.split(".").size > 1
|
34
|
+
else
|
35
|
+
original = original.except(except_scope.to_sym)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
original
|
39
|
+
end
|
40
|
+
})
|
41
|
+
end
|
42
|
+
end
|