para-i18n 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/para/admin/translation.coffee +8 -1
- data/app/views/para/admin/resources/_translations_form.html.haml +2 -0
- data/app/views/para/admin/translations/_target_locale_select.html.haml +5 -0
- data/app/views/para/admin/translations/edit.html.haml +0 -7
- data/lib/generators/para/i18n/form/templates/_translations_form.html.haml +2 -0
- data/lib/para/i18n/engine.rb +2 -1
- data/lib/para/i18n/helpers/translations_form_helper.rb +12 -0
- data/lib/para/i18n/helpers/translations_helper.rb +15 -0
- data/lib/para/i18n/helpers.rb +10 -0
- data/lib/para/i18n/version.rb +1 -1
- data/lib/para/i18n.rb +4 -1
- metadata +7 -4
- data/lib/para/i18n/translations_helper.rb +0 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34b2ce3cde1648cdf50f7a0edf4f16914a3b31d5
|
4
|
+
data.tar.gz: a68844dba0800c59d7009dce60f9567690e9e244
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67188e5b8e71be0ded33f270b2f88cc3fd11674e0394c854c6208da0166b48381a71ace6459895f087697cd7417843c930da1e5e1c07b3ea53bb1f787f44d875
|
7
|
+
data.tar.gz: dad4bd7ded6ee9443a7387116295115053861c8d977cce255237701f3fd54416a472bf8bc0ff17755d131c5ffd462a085f3f5facdd1b02f64e0c906ce8b043d9
|
@@ -1,3 +1,10 @@
|
|
1
|
+
class TranslationLocaleSelect
|
2
|
+
@onChange = ($field) ->
|
3
|
+
targetURL = $field.data('locale-select-target-url')
|
4
|
+
targetLocale = $field.val()
|
5
|
+
targetURL = targetURL.replace('target_locale=_', ['target_locale', targetLocale].join('='))
|
6
|
+
Turbolinks.visit(targetURL.replace(':locale', targetLocale))
|
7
|
+
|
1
8
|
$(document).on 'page:change turbolinks:load', ->
|
2
9
|
$('body').on 'change', '[data-locale-select]', (e) ->
|
3
|
-
$(e.currentTarget)
|
10
|
+
TranslationLocaleSelect.onChange($(e.currentTarget))
|
@@ -0,0 +1,5 @@
|
|
1
|
+
.block.form-inputs
|
2
|
+
.form-group
|
3
|
+
= label :target_locale, t('i18n_admin.translations.choose_locale'), class: 'control-label col-md-3 pull-left'
|
4
|
+
.col-md-9
|
5
|
+
= select_tag :target_locale, options_for_select(locales.map { |locale| [locale, locale] }, target_locale), data: { :'locale-select' => true, selectize: true, multi: false, value: { text: target_locale, value: target_locale }, :'locale-select-target-url' => @component.relation_path(resource, :translation, action: :edit, target_locale: '_') }
|
@@ -1,11 +1,4 @@
|
|
1
1
|
= page_top_bar(title: resource_title_for(resource), type: 'crud/translate')
|
2
2
|
|
3
3
|
.page-content-wrap
|
4
|
-
= form_tag @component.relation_path(resource, :translation, action: :edit), method: :get, class: 'form-horizontal form-group-separated' do
|
5
|
-
.block.form-inputs
|
6
|
-
.form-group
|
7
|
-
= label :target_locale, t('i18n_admin.translations.choose_locale'), class: 'control-label col-md-3 pull-left'
|
8
|
-
.col-md-9
|
9
|
-
= select_tag :target_locale, options_for_select(@locales.map { |locale| [locale, locale] }, @target_locale), data: { :'locale-select' => true, selectize: true, multi: false, value: { text: @target_locale, value: @target_locale } }
|
10
|
-
|
11
4
|
= render find_partial_for(resource, :translations_form)
|
data/lib/para/i18n/engine.rb
CHANGED
@@ -19,7 +19,8 @@ module Para
|
|
19
19
|
|
20
20
|
initializer 'para.i18n.include_view_helpers' do
|
21
21
|
ActiveSupport.on_load(:action_view) do
|
22
|
-
include Para::I18n::TranslationsHelper
|
22
|
+
include Para::I18n::Helpers::TranslationsHelper
|
23
|
+
include Para::I18n::Helpers::TranslationsFormHelper
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Para
|
2
|
+
module I18n
|
3
|
+
module Helpers
|
4
|
+
module TranslationsFormHelper
|
5
|
+
def target_locale_select
|
6
|
+
render partial: 'para/admin/translations/target_locale_select',
|
7
|
+
locals: { locales: @locales, target_locale: @target_locale }
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Para
|
2
|
+
module I18n
|
3
|
+
module Helpers
|
4
|
+
module TranslationsHelper
|
5
|
+
# TODO : Support images & co
|
6
|
+
def translated_model_fields_for(model)
|
7
|
+
model_field_mappings(model).fields.select do |field|
|
8
|
+
model.translated_attribute_names &&
|
9
|
+
model.translated_attribute_names.include?(field.name.to_sym)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/para/i18n/version.rb
CHANGED
data/lib/para/i18n.rb
CHANGED
@@ -6,7 +6,6 @@ require 'para/i18n/fallbacks'
|
|
6
6
|
|
7
7
|
require 'para/i18n/model'
|
8
8
|
require 'para/i18n/resources_table'
|
9
|
-
require 'para/i18n/translations_helper'
|
10
9
|
|
11
10
|
require 'para/i18n/friendly_id'
|
12
11
|
|
@@ -16,6 +15,10 @@ require 'para/i18n/engine'
|
|
16
15
|
|
17
16
|
module Para
|
18
17
|
module I18n
|
18
|
+
extend ActiveSupport::Autoload
|
19
|
+
|
20
|
+
autoload :Helpers
|
21
|
+
|
19
22
|
# Your code goes here...
|
20
23
|
def self.method_missing(method, *args, &block)
|
21
24
|
::I18n.send(method, *args, &block)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: para-i18n
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Valentin Ballestrino
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -70,6 +70,7 @@ files:
|
|
70
70
|
- app/assets/javascripts/para/i18n.coffee
|
71
71
|
- app/controllers/para/admin/translations_controller.rb
|
72
72
|
- app/views/para/admin/resources/_translations_form.html.haml
|
73
|
+
- app/views/para/admin/translations/_target_locale_select.html.haml
|
73
74
|
- app/views/para/admin/translations/edit.html.haml
|
74
75
|
- bin/console
|
75
76
|
- bin/setup
|
@@ -82,10 +83,12 @@ files:
|
|
82
83
|
- lib/para/i18n/engine.rb
|
83
84
|
- lib/para/i18n/fallbacks.rb
|
84
85
|
- lib/para/i18n/friendly_id.rb
|
86
|
+
- lib/para/i18n/helpers.rb
|
87
|
+
- lib/para/i18n/helpers/translations_form_helper.rb
|
88
|
+
- lib/para/i18n/helpers/translations_helper.rb
|
85
89
|
- lib/para/i18n/i18n_input.rb
|
86
90
|
- lib/para/i18n/model.rb
|
87
91
|
- lib/para/i18n/resources_table.rb
|
88
|
-
- lib/para/i18n/translations_helper.rb
|
89
92
|
- lib/para/i18n/version.rb
|
90
93
|
- para-i18n.gemspec
|
91
94
|
homepage: https://github.com/para-cms/para-i18n
|
@@ -108,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
111
|
version: '0'
|
109
112
|
requirements: []
|
110
113
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
114
|
+
rubygems_version: 2.6.7
|
112
115
|
signing_key:
|
113
116
|
specification_version: 4
|
114
117
|
summary: Para CMS I18n admin module for models
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Para
|
2
|
-
module I18n
|
3
|
-
module TranslationsHelper
|
4
|
-
# TODO : Support images & co
|
5
|
-
def translated_model_fields_for(model)
|
6
|
-
model_field_mappings(model).fields.select do |field|
|
7
|
-
model.translated_attribute_names &&
|
8
|
-
model.translated_attribute_names.include?(field.name.to_sym)
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|