decidim-stratified_sortitions 0.0.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/app/commands/decidim/stratified_sortitions/admin/create_stratified_sortition.rb +4 -9
  3. data/app/commands/decidim/stratified_sortitions/admin/update_stratified_sortition.rb +4 -9
  4. data/app/controllers/concerns/decidim/stratified_sortitions/strata_charts_data.rb +2 -1
  5. data/app/helpers/decidim/stratified_sortitions/application_helper.rb +6 -1
  6. data/app/jobs/decidim/stratified_sortitions/admin/import_sample_job.rb +1 -1
  7. data/app/jobs/decidim/stratified_sortitions/admin/sortition_results_export_job.rb +3 -1
  8. data/app/packs/src/decidim/stratified_sortitions/stratum_fields.js +0 -6
  9. data/app/packs/stylesheets/decidim/stratified_sortitions/admin/stratified_sortitions.scss +9 -2
  10. data/app/serializers/decidim/stratified_sortitions/sortition_result_serializer.rb +7 -1
  11. data/app/services/decidim/stratified_sortitions/charts_pdf_generator.rb +9 -13
  12. data/app/services/decidim/stratified_sortitions/fair_sortition_service.rb +1 -1
  13. data/app/services/decidim/stratified_sortitions/leximin/panel_generator.rb +1 -1
  14. data/app/services/decidim/stratified_sortitions/sortition_results_exporter.rb +13 -1
  15. data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_form.html.erb +3 -3
  16. data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_stratum.html.erb +2 -1
  17. data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/_substratum.html.erb +1 -0
  18. data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/execute.html.erb +18 -18
  19. data/app/views/decidim/stratified_sortitions/admin/stratified_sortitions/upload_sample.html.erb +12 -14
  20. data/config/assets.rb +2 -2
  21. data/config/i18n-tasks.yml +196 -0
  22. data/config/locales/ca.yml +169 -216
  23. data/config/locales/en.yml +171 -217
  24. data/config/locales/es.yml +170 -216
  25. data/config/locales/oc.yml +312 -0
  26. data/db/migrate/20251104120000_create_stratified_sortitions_strata_and_substrata.decidim_stratified_sortitions.rb +1 -1
  27. data/lib/decidim/stratified_sortitions/engine.rb +6 -3
  28. data/lib/decidim/stratified_sortitions/version.rb +2 -2
  29. metadata +9 -10
  30. data/app/views/decidim/admin/components/index.html.erb +0 -54
  31. data/app/views/layouts/decidim/admin/_sidebar_menu.html.erb +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1c8a994b63ecef8c9ea023d1874040c7e93fa6867ccec223929c32ad145daf38
4
- data.tar.gz: 265e052e7de51b63b0a9cec6cb7115f13a08c6152fe612fd7db0c705c5383506
3
+ metadata.gz: c45294d39478edb55e83c79c034a1fbcb831d4aca563a1e7befaddfb29c33057
4
+ data.tar.gz: d4ab0a8614ad78fcd2a5a44078b070b018f8741569043f10c04ba0817485d6fa
5
5
  SHA512:
6
- metadata.gz: 9d966ee1b06b76f89f21d7d311d5ec412f449d0825abf56fd2c7133bc4a5c2a9528dedf60b7bd118b63e2348d493fc2481f701b64148c1b74b3f4a3c3b88fb2e
7
- data.tar.gz: f5a642b8b29b003d85ebf03e31d4f68bc22b34724375212d9146b7dc97538d0f3c1f4798e2b4475f4173bd6acafa9988633ff230863912583b45a24bfc5e0976
6
+ metadata.gz: 2444dbf9797a0d3467d9029bf51dd86b8e47f2f52953d6e1e10db649e33dde9aa04aa23a441a4c877a9bfd310463fcb341f318c5019ded0d699936e4025682b4
7
+ data.tar.gz: 9d5b1b64c203b66edb40cb3f7064522bd02f138e1829400935ab89a6b81ebcd3e76ccff7c6cd1c7e2a002e138d38f3fb9fd6016a604c4549b02e23ce4ff3884c
@@ -35,16 +35,11 @@ module Decidim
35
35
  attr_reader :form, :stratified_sortition
36
36
 
37
37
  def create_stratified_sortition!
38
- parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
39
- parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
40
- parsed_selection_criteria = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.selection_criteria, current_organization: form.current_organization).rewrite
41
- parsed_selected_profiles_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.selected_profiles_description,
42
- current_organization: form.current_organization).rewrite
43
38
  params = {
44
- title: parsed_title,
45
- description: parsed_description,
46
- selection_criteria: parsed_selection_criteria,
47
- selected_profiles_description: parsed_selected_profiles_description,
39
+ title: form.title,
40
+ description: form.description,
41
+ selection_criteria: form.selection_criteria,
42
+ selected_profiles_description: form.selected_profiles_description,
48
43
  component: form.current_component,
49
44
  num_candidates: form.num_candidates,
50
45
  }
@@ -47,16 +47,11 @@ module Decidim
47
47
  end
48
48
 
49
49
  def attributes
50
- parsed_title = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.title, current_organization: form.current_organization).rewrite
51
- parsed_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.description, current_organization: form.current_organization).rewrite
52
- parsed_selection_criteria = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.selection_criteria, current_organization: form.current_organization).rewrite
53
- parsed_selected_profiles_description = Decidim::ContentProcessor.parse_with_processor(:hashtag, form.selected_profiles_description,
54
- current_organization: form.current_organization).rewrite
55
50
  {
56
- title: parsed_title,
57
- description: parsed_description,
58
- selection_criteria: parsed_selection_criteria,
59
- selected_profiles_description: parsed_selected_profiles_description,
51
+ title: form.title,
52
+ description: form.description,
53
+ selection_criteria: form.selection_criteria,
54
+ selected_profiles_description: form.selected_profiles_description,
60
55
  component: form.current_component,
61
56
  num_candidates: form.num_candidates,
62
57
  }
@@ -70,7 +70,8 @@ module Decidim
70
70
 
71
71
  def build_stratum_chart(stratum, by_stratum, by_stratum_and_substratum)
72
72
  substrata = stratum.substrata.order(:position)
73
- total = by_stratum[stratum.id]&.map(&:decidim_stratified_sortitions_sample_participant_id)&.uniq&.count || 0
73
+ participant_strata = by_stratum[stratum.id] || []
74
+ total = participant_strata.map(&:decidim_stratified_sortitions_sample_participant_id).uniq.count
74
75
  chart_data = substrata.map do |substratum|
75
76
  build_substratum_chart_row(stratum, substratum, by_stratum_and_substratum, total)
76
77
  end
@@ -69,7 +69,12 @@ module Decidim
69
69
  end
70
70
 
71
71
  def filter_sections_stratified_sortitions
72
- sections = [{ method: :with_any_state, collection: filter_state_values, label_scope: "decidim.stratified_sortitions.stratified_sortitions.filters", id: "state" }]
72
+ sections = [{
73
+ method: :with_any_state,
74
+ collection: filter_state_values,
75
+ label: t("state", scope: "decidim.stratified_sortitions.stratified_sortitions.filters"),
76
+ id: "state",
77
+ }]
73
78
  sections.reject { |item| item[:collection].blank? }
74
79
  end
75
80
 
@@ -160,7 +160,7 @@ module Decidim
160
160
  min_value = range_parts[0].to_f
161
161
  max_value = range_parts[1].to_f
162
162
 
163
- numeric_value >= min_value && numeric_value <= max_value
163
+ numeric_value.between?(min_value, max_value)
164
164
  end
165
165
  end
166
166
  end
@@ -7,6 +7,7 @@ module Decidim
7
7
  # to the requesting user as a zipped email attachment.
8
8
  # Follows the same pattern as Decidim::ExportJob in decidim-core.
9
9
  class SortitionResultsExportJob < ApplicationJob
10
+ include Decidim::PrivateDownloadHelper
10
11
  queue_as :stratified_sortitions
11
12
 
12
13
  def perform(user, stratified_sortition, format)
@@ -19,8 +20,9 @@ module Decidim
19
20
  end
20
21
 
21
22
  export_name = "sortition_results_#{stratified_sortition.id}"
23
+ private_export = attach_archive(export_data, export_name, user, "sortition_results")
22
24
 
23
- Decidim::ExportMailer.export(user, export_name, export_data).deliver_now
25
+ Decidim::ExportMailer.export(user, private_export).deliver_now
24
26
  end
25
27
  end
26
28
  end
@@ -3,7 +3,6 @@ import AutoLabelByPositionComponent from "src/decidim/admin/auto_label_by_positi
3
3
  import createLiveTextUpdateComponent from "src/decidim/forms/admin/live_text_update.component"
4
4
  import createSortList from "src/decidim/admin/sort_list.component"
5
5
  import { initializeSubstrataWrapper } from "src/decidim/stratified_sortitions/substratum_fields"
6
- import { createAccordion } from "src/decidim/a11y"
7
6
 
8
7
  $(() => {
9
8
  const wrapperSelector = ".stratified-sortition-strata";
@@ -147,11 +146,6 @@ $(() => {
147
146
  createSortableList();
148
147
  runComponents();
149
148
 
150
- const newAccordion = $newField[0].querySelector('[data-component="accordion"]');
151
- if (newAccordion) {
152
- try { createAccordion(newAccordion); } catch (_e) {}
153
- }
154
-
155
149
  if (document && typeof document.dispatchEvent === "function") {
156
150
  try {
157
151
  document.dispatchEvent(new CustomEvent("ajax:loaded", { detail: $newField[0] }));
@@ -50,14 +50,21 @@
50
50
  .substratum-fields {
51
51
  display: flex;
52
52
  gap: 1rem;
53
- align-items: center;
53
+ align-items: flex-start;
54
54
  justify-content: space-between;
55
-
55
+ margin-bottom: 1rem;
56
+
56
57
  .translated-field {
57
58
  width: 100%;
58
59
  }
59
60
  }
60
61
 
62
+ .stratified-sortition-substrata-list {
63
+ display: flex;
64
+ flex-direction: column;
65
+ gap: 1rem;
66
+ }
67
+
61
68
 
62
69
  .example-file-census-container {
63
70
  padding:1em;
@@ -102,7 +102,13 @@ module Decidim
102
102
  end
103
103
 
104
104
  def substratum_name_for(participant_stratum)
105
- participant_stratum&.decidim_stratified_sortitions_substratum&.name&.values&.compact&.first || "-"
105
+ substratum = participant_stratum&.decidim_stratified_sortitions_substratum
106
+ return "-" unless substratum
107
+
108
+ name = substratum.name
109
+ return "-" unless name
110
+
111
+ name.values.compact.first || "-"
106
112
  end
107
113
 
108
114
  def add_fairness_metrics(data, participant)
@@ -31,15 +31,15 @@ module Decidim
31
31
 
32
32
  def template_assigns
33
33
  {
34
- title: t("pdf_title", name: translated_name(@stratified_sortition.title)),
35
- subtitle: t("pdf_subtitle"),
36
- belongs_to: t("pdf_belongs_to", space_name: participatory_space_name),
37
- algorithm: t("pdf_algorithm", algorithm: algorithm_info),
38
- executed_at: t("pdf_executed_at", date: execution_date),
39
- no_data_text: t("pdf_no_data"),
40
- col_target: t("target"),
41
- col_candidates: t("candidates"),
42
- col_results: t("results"),
34
+ title: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_title", name: translated_name(@stratified_sortition.title)),
35
+ subtitle: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_subtitle"),
36
+ belongs_to: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_belongs_to", space_name: participatory_space_name),
37
+ algorithm: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_algorithm", algorithm: algorithm_info),
38
+ executed_at: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_executed_at", date: execution_date),
39
+ no_data_text: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.pdf_no_data"),
40
+ col_target: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.target"),
41
+ col_candidates: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.candidates"),
42
+ col_results: I18n.t("decidim.stratified_sortitions.admin.stratified_sortitions.execute.results"),
43
43
  strata_chart_data: build_strata_chart_data,
44
44
  }
45
45
  end
@@ -84,10 +84,6 @@ module Decidim
84
84
  portfolio.selected_at.to_s
85
85
  end
86
86
 
87
- def t(key, **opts)
88
- I18n.t(key, scope: "decidim.stratified_sortitions.admin.stratified_sortitions.execute", **opts)
89
- end
90
-
91
87
  def controller
92
88
  @controller ||= ChartsPdfControllerHelper.new
93
89
  end
@@ -162,7 +162,7 @@ module Decidim
162
162
  # @param expected_ids [Array<Integer>] expected selected participant IDs
163
163
  # @param verification_seed [String] the seed used in the original draw
164
164
  # @return [Boolean] true if verification passes
165
- def verify(expected_ids, verification_seed:)
165
+ def verify(expected_ids, verification_seed:) # rubocop:disable Naming/PredicateMethod
166
166
  portfolio = existing_portfolio
167
167
  return false unless portfolio&.sampled?
168
168
 
@@ -100,7 +100,7 @@ module Decidim
100
100
  cat_sum = sum_vars(cat_vars)
101
101
 
102
102
  # min <= sum <= max
103
- model.enforce(cat_sum >= quota[:min]) if (quota[:min]).positive?
103
+ model.enforce(cat_sum >= quota[:min]) if quota[:min].positive?
104
104
  model.enforce(cat_sum <= quota[:max]) if quota[:max] < @cb.panel_size
105
105
  end
106
106
 
@@ -140,12 +140,24 @@ module Decidim
140
140
  ]
141
141
  @strata.each do |stratum|
142
142
  ps = participant.sample_participant_strata.find { |s| s.decidim_stratified_sortitions_stratum_id == stratum.id }
143
- substratum_name = ps&.decidim_stratified_sortitions_substratum&.name&.values&.compact&.first
143
+ substratum_name = substratum_name_for(ps)
144
144
  row << (substratum_name || "-")
145
145
  end
146
146
  row
147
147
  end
148
148
 
149
+ def substratum_name_for(participant_stratum)
150
+ return unless participant_stratum
151
+
152
+ substratum = participant_stratum.decidim_stratified_sortitions_substratum
153
+ return unless substratum
154
+
155
+ name = substratum.name
156
+ return unless name
157
+
158
+ name.values.compact.first
159
+ end
160
+
149
161
  def style_header_row(worksheet, row_index, _col_count)
150
162
  worksheet.change_row_fill(row_index, "c0c0c0")
151
163
  worksheet.change_row_bold(row_index, true)
@@ -1,5 +1,5 @@
1
1
  <div class="form__wrapper">
2
- <div class="card" data-component="accordion" id="accordion-data">
2
+ <div class="card" data-controller="accordion" id="accordion-data">
3
3
  <div class="card-divider">
4
4
  <button class="card-divider-button" data-open="true" data-controls="panel-data" type="button">
5
5
  <%= icon "arrow-right-s-line" %>
@@ -10,7 +10,7 @@
10
10
  </div>
11
11
  <div id="panel-data" class="card-section">
12
12
  <div class="row columns">
13
- <%= form.translated :text_field, :title, autofocus: true, aria: { label: :title } %>
13
+ <%= form.translated :text_field, :title, autofocus: true, aria: { label: :title }, data: { controller: "character-counter" } %>
14
14
  </div>
15
15
 
16
16
  <div class="row column mt-4">
@@ -31,7 +31,7 @@
31
31
  </div>
32
32
  </div>
33
33
 
34
- <div class="card" data-component="accordion" id="accordion-strata">
34
+ <div class="card" data-controller="accordion" id="accordion-strata">
35
35
  <div class="card-divider">
36
36
  <button class="card-divider-button" data-open="true" data-controls="panel-strata" type="button">
37
37
  <svg viewBox="0 0 24 24" id="ri-arrow-right-s-line">
@@ -1,6 +1,6 @@
1
1
  <% stratum = form.object %>
2
2
 
3
- <div class="card stratified-sortition-stratum" data-component="accordion" id="accordion-<%= id %>-field">
3
+ <div class="card stratified-sortition-stratum" data-controller="accordion" id="accordion-<%= id %>-field">
4
4
  <div class="card-divider stratum-divider">
5
5
  <h2 class="card-title flex items-center">
6
6
  <span>
@@ -51,6 +51,7 @@
51
51
  tabs_id: id,
52
52
  label: t(".name"),
53
53
  maxlength: 100,
54
+ data: { controller: "character-counter" },
54
55
  readonly: @stratified_sortition&.sample_participants&.any?) %>
55
56
  </div>
56
57
  <div>
@@ -25,6 +25,7 @@
25
25
  tabs_id: id,
26
26
  label: t(".name"),
27
27
  maxlength: 100,
28
+ data: { controller: "character-counter" },
28
29
  readonly: @stratified_sortition&.sample_participants&.any?) %>
29
30
  </div>
30
31
  <div class="substratum-value-field">
@@ -25,24 +25,24 @@
25
25
  <%= t('.execute_stratified_sortition') %>
26
26
  </button>
27
27
  <% if stratified_sortition.panel_portfolio&.sampled? %>
28
- <span class="exports button button__sm button__secondary" data-toggle="export-dropdown">
29
- <%= t(".export") %>
30
- <%= icon "arrow-down-s-line", class: "dropdown-filter-icon" %>
31
- </span>
32
- <div class="dropdown-pane" id="export-dropdown" data-dropdown data-position="bottom" data-alignment="right" data-auto-focus="true" data-close-on-click="true">
33
- <ul class="vertical menu add-components">
34
- <%= link_to export_results_stratified_sortition_path(stratified_sortition, format: "csv"), method: :post do %>
35
- <li class="exports--format--csv"><%= t(".export_csv") %></li>
36
- <% end %>
37
- <%= link_to export_results_stratified_sortition_path(stratified_sortition, format: "excel"), method: :post do %>
38
- <li class="exports--format--excel"><%= t(".export_excel") %></li>
39
- <% end %>
40
- <%= link_to export_results_stratified_sortition_path(stratified_sortition, format: "json"), method: :post do %>
41
- <li class="exports--format--json"><%= t(".export_json") %></li>
42
- <% end %>
43
- <%= link_to export_charts_pdf_stratified_sortition_path(stratified_sortition), method: :post do %>
44
- <li class="exports--format--pdf"><%= t(".export_charts_pdf") %></li>
45
- <% end %>
28
+ <div class="relative">
29
+ <button type="button" class="exports button button__sm button__secondary" data-controller="dropdown" data-target="export-dropdown">
30
+ <%= t(".export") %>
31
+ <%= icon "arrow-down-s-line", class: "!fill-white" %>
32
+ </button>
33
+ <ul id="export-dropdown" class="dropdown dropdown__bottom" aria-hidden="true">
34
+ <li class="dropdown__item exports--format--csv">
35
+ <%= link_to t(".export_csv"), export_results_stratified_sortition_path(stratified_sortition, format: "csv"), method: :post, class: "dropdown__button" %>
36
+ </li>
37
+ <li class="dropdown__item exports--format--excel">
38
+ <%= link_to t(".export_excel"), export_results_stratified_sortition_path(stratified_sortition, format: "excel"), method: :post, class: "dropdown__button" %>
39
+ </li>
40
+ <li class="dropdown__item exports--format--json">
41
+ <%= link_to t(".export_json"), export_results_stratified_sortition_path(stratified_sortition, format: "json"), method: :post, class: "dropdown__button" %>
42
+ </li>
43
+ <li class="dropdown__item exports--format--pdf">
44
+ <%= link_to t(".export_charts_pdf"), export_charts_pdf_stratified_sortition_path(stratified_sortition), method: :post, class: "dropdown__button" %>
45
+ </li>
46
46
  </ul>
47
47
  </div>
48
48
  <% end %>
@@ -34,21 +34,19 @@
34
34
  </tr>
35
35
  <% end %>
36
36
  </table>
37
- <div class="mt-12">
38
- <button type="button" class="button button__sm button__secondary" data-toggle="sample-template-dropdown">
39
- <%= t(".download_template") %>
40
- <%= icon "arrow-down-s-line", class: "dropdown-filter-icon" %>
37
+ <div class="mt-12 relative inline-block">
38
+ <button type="button" class="button button__sm button__secondary" data-controller="dropdown" data-target="sample-template-dropdown">
39
+ <%= t(".download_template") %>
40
+ <%= icon "arrow-down-s-line", class: "!fill-white" %>
41
41
  </button>
42
- <div class="dropdown-pane" id="sample-template-dropdown" data-dropdown data-position="bottom" data-alignment="left" data-auto-focus="true" data-close-on-click="true">
43
- <ul class="vertical menu add-components">
44
- <%= link_to download_template_samples_path(id: @stratified_sortition.id, format: :csv) do %>
45
- <li><%= t(".download_template_csv") %></li>
46
- <% end %>
47
- <%= link_to download_template_samples_path(id: @stratified_sortition.id, format: :xlsx) do %>
48
- <li><%= t(".download_template_xlsx") %></li>
49
- <% end %>
50
- </ul>
51
- </div>
42
+ <ul id="sample-template-dropdown" class="dropdown dropdown__bottom" aria-hidden="true">
43
+ <li class="dropdown__item">
44
+ <%= link_to t(".download_template_csv"), download_template_samples_path(id: @stratified_sortition.id, format: :csv), class: "dropdown__button" %>
45
+ </li>
46
+ <li class="dropdown__item">
47
+ <%= link_to t(".download_template_xlsx"), download_template_samples_path(id: @stratified_sortition.id, format: :xlsx), class: "dropdown__button" %>
48
+ </li>
49
+ </ul>
52
50
  </div>
53
51
  </div>
54
52
  <div class="row mt-4 <%= 'upload-disabled-wrapper' if @stratified_sortition.executed? %>">
data/config/assets.rb CHANGED
@@ -12,13 +12,13 @@ base_path = File.expand_path("..", __dir__)
12
12
  # in your JavaScript entrypoints (or other JavaScript files within Decidim)
13
13
  # using `import "src/decidim/foo"` after you have registered the additional path
14
14
  # as follows.
15
- Decidim::Webpacker.register_path("#{base_path}/app/packs")
15
+ Decidim::Shakapacker.register_path("#{base_path}/app/packs")
16
16
 
17
17
  # Register the entrypoints for your module. These entrypoints can be included
18
18
  # within your application using `javascript_pack_tag` and if you include any
19
19
  # SCSS files within the entrypoints, they become available for inclusion using
20
20
  # `stylesheet_pack_tag`.
21
- Decidim::Webpacker.register_entrypoints(
21
+ Decidim::Shakapacker.register_entrypoints(
22
22
  decidim_stratified_sortitions: "#{base_path}/app/packs/entrypoints/decidim_stratified_sortitions.js",
23
23
  decidim_stratified_sortitions_admin: "#{base_path}/app/packs/entrypoints/decidim_stratified_sortitions_admin.js",
24
24
  )
@@ -0,0 +1,196 @@
1
+ # i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
2
+
3
+ # The "main" locale.
4
+ base_locale: en
5
+ ## All available locales are inferred from the data by default. Alternatively, specify them explicitly:
6
+ # locales: [es, fr]
7
+ ## Reporting locale, default: en. Available: en, ru.
8
+ # internal_locale: en
9
+
10
+ # Read and write translations.
11
+ data:
12
+ ## Translations are read from the file system. Supported format: YAML, JSON.
13
+ ## Provide a custom adapter:
14
+ # adapter: I18n::Tasks::Data::FileSystem
15
+
16
+ # Locale files or `Dir.glob` patterns where translations are read from:
17
+ read:
18
+ ## Default:
19
+ # - config/locales/%{locale}.yml
20
+ ## More files:
21
+ # - config/locales/**/*.%{locale}.yml
22
+
23
+ # Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
24
+ # `i18n-tasks normalize -p` will force move the keys according to these rules
25
+ write:
26
+ ## For example, write devise and simple form keys to their respective files:
27
+ # - ['{devise, simple_form}.*', 'config/locales/\1.%{locale}.yml']
28
+ ## Catch-all default:
29
+ # - config/locales/%{locale}.yml
30
+
31
+ # External locale data (e.g. gems).
32
+ # This data is not considered unused and is never written to.
33
+ external:
34
+ ## Example (replace %#= with %=):
35
+ # - "<%#= %x[bundle info vagrant --path].chomp %>/templates/locales/%{locale}.yml"
36
+
37
+ ## Specify the router (see Readme for details). Valid values: conservative_router, pattern_router, isolating_router, or a custom class.
38
+ # router: conservative_router
39
+
40
+ yaml:
41
+ write:
42
+ # do not wrap lines at 80 characters
43
+ line_width: -1
44
+
45
+ ## Pretty-print JSON:
46
+ # json:
47
+ # write:
48
+ # indent: ' '
49
+ # space: ' '
50
+ # object_nl: "\n"
51
+ # array_nl: "\n"
52
+
53
+ # Find translate calls
54
+ search:
55
+ ## Paths or `Find.find` patterns to search in:
56
+ # paths:
57
+ # - app/
58
+
59
+ ## Root directories for relative keys resolution.
60
+ # relative_roots:
61
+ # - app/controllers
62
+ # - app/helpers
63
+ # - app/mailers
64
+ # - app/presenters
65
+ # - app/views
66
+
67
+ ## Directories where method names which should not be part of a relative key resolution.
68
+ # By default, if a relative translation is used inside a method, the name of the method will be considered part of the resolved key.
69
+ # Directories listed here will not consider the name of the method part of the resolved key
70
+ #
71
+ # relative_exclude_method_name_paths:
72
+ # -
73
+
74
+ ## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
75
+ ## *.jpg *.jpeg *.png *.gif *.svg *.ico *.eot *.otf *.ttf *.woff *.woff2 *.pdf *.css *.sass *.scss *.less
76
+ ## *.yml *.json *.zip *.tar.gz *.swf *.flv *.mp3 *.wav *.flac *.webm *.mp4 *.ogg *.opus *.webp *.map *.xlsx
77
+ exclude:
78
+ - app/assets/images
79
+ - app/assets/fonts
80
+ - app/assets/videos
81
+ - app/assets/builds
82
+
83
+ ## Alternatively, the only files or `File.fnmatch patterns` to search in `paths`:
84
+ ## If specified, this settings takes priority over `exclude`, but `exclude` still applies.
85
+ # only: ["*.rb", "*.html.slim"]
86
+
87
+ ## If `strict` is `false`, guess usages such as t("categories.#{category}.title"). The default is `true`.
88
+ # strict: true
89
+
90
+ ## Allows adding ast_matchers for finding translations using the AST-scanners
91
+ ## The available matchers are:
92
+ ## - RailsModelMatcher
93
+ ## Matches ActiveRecord translations like
94
+ ## User.human_attribute_name(:email) and User.model_name.human
95
+ ## - DefaultI18nSubjectMatcher
96
+ ## Matches ActionMailer's default_i18n_subject method
97
+ ##
98
+ ## To implement your own, please see `I18n::Tasks::Scanners::AstMatchers::BaseMatcher`.
99
+ # ast_matchers:
100
+ # - 'I18n::Tasks::Scanners::AstMatchers::RailsModelMatcher'
101
+ # - 'I18n::Tasks::Scanners::AstMatchers::DefaultI18nSubjectMatcher'
102
+
103
+ ## Multiple scanners can be used. Their results are merged.
104
+ ## The options specified above are passed down to each scanner. Per-scanner options can be specified as well.
105
+ ## See this example of a custom scanner: https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example
106
+
107
+ ## Translation Services
108
+ # translation:
109
+ # # Google Translate
110
+ # # Get an API key and set billing info at https://code.google.com/apis/console to use Google Translate
111
+ # google_translate_api_key: "AbC-dEf5"
112
+ # # DeepL Pro Translate
113
+ # # Get an API key and subscription at https://www.deepl.com/pro to use DeepL Pro
114
+ # deepl_api_key: "48E92789-57A3-466A-9959-1A1A1A1A1A1A"
115
+ # # deepl_host: "https://api.deepl.com"
116
+ # # deepl_version: "v2"
117
+ # # deepl_glossary_ids:
118
+ # # - f28106eb-0e06-489e-82c6-8215d6f95089
119
+ # # - 2c6415be-1852-4f54-9e1b-d800463496b4
120
+ # # add additional options to the DeepL.translate call: https://www.deepl.com/docs-api/translate-text/translate-text/
121
+ # deepl_options:
122
+ # formality: prefer_less
123
+ # # OpenAI
124
+ # openai_api_key: "sk-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
125
+ # # openai_model: "gpt-4o-mini" # see https://platform.openai.com/docs/models
126
+ # # may contain `%{from}` and `%{to}`, which will be replaced by source and target locale codes, respectively (using `Kernel.format`)
127
+ # # openai_system_prompt: >-
128
+ # # You are a professional translator that translates content from the %{from} locale
129
+ # # to the %{to} locale in an i18n locale array.
130
+ # #
131
+ # # The array has a structured format and contains multiple strings. Your task is to translate
132
+ # # each of these strings and create a new array with the translated strings.
133
+ # #
134
+ # # HTML markups (enclosed in < and > characters) must not be changed under any circumstance.
135
+ # # Variables (starting with %%{ and ending with }) must not be changed under any circumstance.
136
+ # #
137
+ # # Keep in mind the context of all the strings for a more accurate translation.
138
+
139
+ ## Do not consider these keys missing:
140
+ ignore_missing:
141
+ - 'decidim.admin.actions.view_deleted_components'
142
+ - 'decidim.admin.components.index.add'
143
+ - 'decidim.admin.components.title'
144
+ - 'decidim.admin.exports.notice'
145
+ - 'decidim.admin.titles.menu'
146
+ - 'decidim.admin.tooltips.deleted_component_info'
147
+ - 'decidim.components.pagination.page_title'
148
+ # - 'errors.messages.{accepted,blank,invalid,too_short,too_long}'
149
+ # - '{devise,simple_form}.*'
150
+
151
+ ## Consider these keys used:
152
+ ignore_unused:
153
+ - 'activemodel.attributes.sample_upload.*'
154
+ - 'activemodel.attributes.stratified_sortition.*'
155
+ - 'activemodel.errors.messages.cannot_{add,change,delete}_*'
156
+ - 'decidim.components.stratified_sortitions.name'
157
+ - 'decidim.components.stratified_sortitions.settings.global.publish_sortitions'
158
+ - 'decidim.components.stratified_sortitions.settings.step.announcement'
159
+ - 'decidim.stratified_sortitions.admin_log.stratified_sortition.*'
160
+ - 'decidim.stratified_sortitions.admin.stratified_sortitions.upload_sample.*'
161
+ - 'decidim.stratified_sortitions.stratified_sortitions.filters.{executing,failed}'
162
+ - 'decidim.stratified_sortitions.stratified_sortitions.orders.*'
163
+ - 'decidim.stratified_sortitions.stratified_sortitions.show.statuses.*'
164
+ # - 'activerecord.attributes.*'
165
+ # - '{devise,kaminari,will_paginate}.*'
166
+ # - 'simple_form.{yes,no}'
167
+ # - 'simple_form.{placeholders,hints,labels}.*'
168
+ # - 'simple_form.{error_notification,required}.:'
169
+
170
+ ## Exclude these keys from the `i18n-tasks eq-base' report:
171
+ # ignore_eq_base:
172
+ # all:
173
+ # - common.ok
174
+ # fr,es:
175
+ # - common.brand
176
+
177
+ ## Exclude these keys from the `i18n-tasks check-consistent-interpolations` report:
178
+ # ignore_inconsistent_interpolations:
179
+ # - 'activerecord.attributes.*'
180
+
181
+ ## Ignore these keys completely:
182
+ # ignore:
183
+ # - kaminari.*
184
+
185
+ ## Sometimes, it isn't possible for i18n-tasks to match the key correctly,
186
+ ## e.g. in case of a relative key defined in a helper method.
187
+ ## In these cases you can use the built-in PatternMapper to map patterns to keys, e.g.:
188
+ #
189
+ # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
190
+ # only: %w(*.html.haml *.html.slim),
191
+ # patterns: [['= title\b', '.page_title']] %>
192
+ #
193
+ # The PatternMapper can also match key literals via a special %{key} interpolation, e.g.:
194
+ #
195
+ # <%# I18n::Tasks.add_scanner 'I18n::Tasks::Scanners::PatternMapper',
196
+ # patterns: [['\bSpree\.t[( ]\s*%{key}', 'spree.%{key}']] %>