decidim-term_customizer 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE-AGPLv3.txt +661 -0
- data/README.md +180 -0
- data/Rakefile +48 -0
- data/app/assets/config/translation_sets_admin_manifest.js +2 -0
- data/app/assets/javascripts/decidim/term_customizer/admin/constraint_fields.js.es6 +45 -0
- data/app/assets/javascripts/decidim/term_customizer/admin/multifield/component.js.es6 +103 -0
- data/app/assets/javascripts/decidim/term_customizer/admin/multifield.js.es6 +5 -0
- data/app/assets/javascripts/decidim/term_customizer/admin/translation_sets_admin.js.es6 +19 -0
- data/app/assets/javascripts/decidim/term_customizer/admin/translations_admin.js.es6 +72 -0
- data/app/commands/decidim/term_customizer/admin/create_translation.rb +53 -0
- data/app/commands/decidim/term_customizer/admin/create_translation_set.rb +68 -0
- data/app/commands/decidim/term_customizer/admin/import_translation_keys.rb +59 -0
- data/app/commands/decidim/term_customizer/admin/update_translation.rb +65 -0
- data/app/commands/decidim/term_customizer/admin/update_translation_set.rb +61 -0
- data/app/controllers/decidim/term_customizer/admin/add_translations_controller.rb +72 -0
- data/app/controllers/decidim/term_customizer/admin/application_controller.rb +15 -0
- data/app/controllers/decidim/term_customizer/admin/translation_sets_controller.rb +107 -0
- data/app/controllers/decidim/term_customizer/admin/translations_controller.rb +102 -0
- data/app/forms/decidim/term_customizer/admin/translation_form.rb +39 -0
- data/app/forms/decidim/term_customizer/admin/translation_key_import_form.rb +15 -0
- data/app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb +58 -0
- data/app/forms/decidim/term_customizer/admin/translation_set_form.rb +18 -0
- data/app/forms/decidim/term_customizer/admin/translation_set_subject_component_form.rb +12 -0
- data/app/forms/decidim/term_customizer/admin/translation_set_subject_form.rb +61 -0
- data/app/helpers/decidim/term_customizer/admin/application_helper.rb +13 -0
- data/app/models/decidim/term_customizer/application_record.rb +10 -0
- data/app/models/decidim/term_customizer/constraint.rb +36 -0
- data/app/models/decidim/term_customizer/translation.rb +23 -0
- data/app/models/decidim/term_customizer/translation_set.rb +19 -0
- data/app/permissions/decidim/term_customizer/admin/permissions.rb +66 -0
- data/app/queries/decidim/term_customizer/organization_translation_sets.rb +37 -0
- data/app/queries/decidim/term_customizer/set_translations.rb +21 -0
- data/app/views/decidim/term_customizer/admin/add_translations/index.html.erb +59 -0
- data/app/views/decidim/term_customizer/admin/translation_sets/_constraint_fields.html.erb +58 -0
- data/app/views/decidim/term_customizer/admin/translation_sets/_form.html.erb +29 -0
- data/app/views/decidim/term_customizer/admin/translation_sets/edit.html.erb +9 -0
- data/app/views/decidim/term_customizer/admin/translation_sets/index.html.erb +44 -0
- data/app/views/decidim/term_customizer/admin/translation_sets/new.html.erb +9 -0
- data/app/views/decidim/term_customizer/admin/translations/_form.html.erb +15 -0
- data/app/views/decidim/term_customizer/admin/translations/edit.html.erb +7 -0
- data/app/views/decidim/term_customizer/admin/translations/index.html.erb +52 -0
- data/app/views/decidim/term_customizer/admin/translations/new.html.erb +7 -0
- data/config/locales/en.yml +65 -0
- data/config/locales/fi.yml +65 -0
- data/config/locales/sv.yml +65 -0
- data/lib/decidim/term_customizer/admin.rb +10 -0
- data/lib/decidim/term_customizer/admin_engine.rb +46 -0
- data/lib/decidim/term_customizer/engine.rb +35 -0
- data/lib/decidim/term_customizer/i18n_backend.rb +82 -0
- data/lib/decidim/term_customizer/resolver.rb +108 -0
- data/lib/decidim/term_customizer/test/factories.rb +43 -0
- data/lib/decidim/term_customizer/translation_directory.rb +50 -0
- data/lib/decidim/term_customizer/translation_store.rb +67 -0
- data/lib/decidim/term_customizer/version.rb +8 -0
- data/lib/decidim/term_customizer.rb +21 -0
- metadata +170 -0
@@ -0,0 +1,67 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Decidim
|
4
|
+
module TermCustomizer
|
5
|
+
class TranslationStore
|
6
|
+
def initialize(hash)
|
7
|
+
@values = flat_hash(hash || {})
|
8
|
+
end
|
9
|
+
|
10
|
+
def by_key(search)
|
11
|
+
@values.select do |key|
|
12
|
+
includes_string?(key, search, case_sensitive: true)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def by_term(search, case_sensitive: false)
|
17
|
+
@values.select do |_key, term|
|
18
|
+
includes_string?(term, search, case_sensitive: case_sensitive)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def includes_string?(source, search, case_sensitive: false)
|
25
|
+
return source.include?(search) if case_sensitive
|
26
|
+
|
27
|
+
source.downcase.include?(search.downcase)
|
28
|
+
end
|
29
|
+
|
30
|
+
def flat_hash(hash)
|
31
|
+
hash.each_with_object({}) do |(k, v), h|
|
32
|
+
if v.is_a? Hash
|
33
|
+
flat_hash(v).map do |h_k, h_v|
|
34
|
+
append_to_hash(h, "#{k}.#{h_k}", h_v)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
append_to_hash(h, k.to_s, v)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def append_to_hash(hash, key, value)
|
43
|
+
# Specific translations have a proc value but in our context these
|
44
|
+
# translations are not interesting. An example of such translation is
|
45
|
+
# `i18n.plural.rule` which takes in an integer when called and returns
|
46
|
+
# either `:one` or `:other` depending on the integer's value.
|
47
|
+
return if value.is_a?(Proc)
|
48
|
+
|
49
|
+
# Some translation values are symbols which are also not interesting in
|
50
|
+
# our context. Example of such translation is `i18n.plural.rule` which
|
51
|
+
# has a value of `[:one, :other]`.
|
52
|
+
return if value.is_a?(Symbol)
|
53
|
+
|
54
|
+
# Exclude the faker translations.
|
55
|
+
return if key =~ /^faker\./
|
56
|
+
|
57
|
+
if value.is_a?(Array)
|
58
|
+
value.each_with_index do |v, i|
|
59
|
+
append_to_hash(hash, "#{key}.#{i}", v)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
hash[key] = value.to_s
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "term_customizer/version"
|
4
|
+
require_relative "term_customizer/engine"
|
5
|
+
require_relative "term_customizer/admin"
|
6
|
+
require_relative "term_customizer/admin_engine"
|
7
|
+
|
8
|
+
module Decidim
|
9
|
+
module TermCustomizer
|
10
|
+
autoload :I18nBackend, "decidim/term_customizer/i18n_backend"
|
11
|
+
autoload :Resolver, "decidim/term_customizer/resolver"
|
12
|
+
autoload :TranslationDirectory, "decidim/term_customizer/translation_directory"
|
13
|
+
autoload :TranslationStore, "decidim/term_customizer/translation_store"
|
14
|
+
|
15
|
+
EMPTY_HASH = {}.freeze
|
16
|
+
|
17
|
+
class << self
|
18
|
+
attr_accessor :resolver
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: decidim-term_customizer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.16.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Antti Hukkanen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: decidim-admin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.16.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.16.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: decidim-core
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.16.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.16.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: decidim-dev
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.16.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.16.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: decidim-participatory_processes
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.16.0
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.16.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: decidim-proposals
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.16.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.16.0
|
83
|
+
description: Adds a UI to customize the terms and limit the customizations to specific
|
84
|
+
places.
|
85
|
+
email:
|
86
|
+
- antti.hukkanen@mainiotech.fi
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- LICENSE-AGPLv3.txt
|
92
|
+
- README.md
|
93
|
+
- Rakefile
|
94
|
+
- app/assets/config/translation_sets_admin_manifest.js
|
95
|
+
- app/assets/javascripts/decidim/term_customizer/admin/constraint_fields.js.es6
|
96
|
+
- app/assets/javascripts/decidim/term_customizer/admin/multifield.js.es6
|
97
|
+
- app/assets/javascripts/decidim/term_customizer/admin/multifield/component.js.es6
|
98
|
+
- app/assets/javascripts/decidim/term_customizer/admin/translation_sets_admin.js.es6
|
99
|
+
- app/assets/javascripts/decidim/term_customizer/admin/translations_admin.js.es6
|
100
|
+
- app/commands/decidim/term_customizer/admin/create_translation.rb
|
101
|
+
- app/commands/decidim/term_customizer/admin/create_translation_set.rb
|
102
|
+
- app/commands/decidim/term_customizer/admin/import_translation_keys.rb
|
103
|
+
- app/commands/decidim/term_customizer/admin/update_translation.rb
|
104
|
+
- app/commands/decidim/term_customizer/admin/update_translation_set.rb
|
105
|
+
- app/controllers/decidim/term_customizer/admin/add_translations_controller.rb
|
106
|
+
- app/controllers/decidim/term_customizer/admin/application_controller.rb
|
107
|
+
- app/controllers/decidim/term_customizer/admin/translation_sets_controller.rb
|
108
|
+
- app/controllers/decidim/term_customizer/admin/translations_controller.rb
|
109
|
+
- app/forms/decidim/term_customizer/admin/translation_form.rb
|
110
|
+
- app/forms/decidim/term_customizer/admin/translation_key_import_form.rb
|
111
|
+
- app/forms/decidim/term_customizer/admin/translation_set_constraint_form.rb
|
112
|
+
- app/forms/decidim/term_customizer/admin/translation_set_form.rb
|
113
|
+
- app/forms/decidim/term_customizer/admin/translation_set_subject_component_form.rb
|
114
|
+
- app/forms/decidim/term_customizer/admin/translation_set_subject_form.rb
|
115
|
+
- app/helpers/decidim/term_customizer/admin/application_helper.rb
|
116
|
+
- app/models/decidim/term_customizer/application_record.rb
|
117
|
+
- app/models/decidim/term_customizer/constraint.rb
|
118
|
+
- app/models/decidim/term_customizer/translation.rb
|
119
|
+
- app/models/decidim/term_customizer/translation_set.rb
|
120
|
+
- app/permissions/decidim/term_customizer/admin/permissions.rb
|
121
|
+
- app/queries/decidim/term_customizer/organization_translation_sets.rb
|
122
|
+
- app/queries/decidim/term_customizer/set_translations.rb
|
123
|
+
- app/views/decidim/term_customizer/admin/add_translations/index.html.erb
|
124
|
+
- app/views/decidim/term_customizer/admin/translation_sets/_constraint_fields.html.erb
|
125
|
+
- app/views/decidim/term_customizer/admin/translation_sets/_form.html.erb
|
126
|
+
- app/views/decidim/term_customizer/admin/translation_sets/edit.html.erb
|
127
|
+
- app/views/decidim/term_customizer/admin/translation_sets/index.html.erb
|
128
|
+
- app/views/decidim/term_customizer/admin/translation_sets/new.html.erb
|
129
|
+
- app/views/decidim/term_customizer/admin/translations/_form.html.erb
|
130
|
+
- app/views/decidim/term_customizer/admin/translations/edit.html.erb
|
131
|
+
- app/views/decidim/term_customizer/admin/translations/index.html.erb
|
132
|
+
- app/views/decidim/term_customizer/admin/translations/new.html.erb
|
133
|
+
- config/locales/en.yml
|
134
|
+
- config/locales/fi.yml
|
135
|
+
- config/locales/sv.yml
|
136
|
+
- lib/decidim/term_customizer.rb
|
137
|
+
- lib/decidim/term_customizer/admin.rb
|
138
|
+
- lib/decidim/term_customizer/admin_engine.rb
|
139
|
+
- lib/decidim/term_customizer/engine.rb
|
140
|
+
- lib/decidim/term_customizer/i18n_backend.rb
|
141
|
+
- lib/decidim/term_customizer/resolver.rb
|
142
|
+
- lib/decidim/term_customizer/test/factories.rb
|
143
|
+
- lib/decidim/term_customizer/translation_directory.rb
|
144
|
+
- lib/decidim/term_customizer/translation_store.rb
|
145
|
+
- lib/decidim/term_customizer/version.rb
|
146
|
+
homepage: https://github.com/mainio/decidim-module-term_customizer
|
147
|
+
licenses:
|
148
|
+
- AGPL-3.0
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - ">="
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.7.6
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: Provides possibility to customize Decidim's localized terms.
|
170
|
+
test_files: []
|