decidim-voca 0.0.6 → 0.1.2

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 (190) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.md +161 -161
  3. data/README.md +42 -133
  4. data/Rakefile +46 -39
  5. data/app/cells/decidim/footer_topics/show_overrides.erb +8 -0
  6. data/app/cells/decidim/meetings/dates_and_map/show_overrides.erb +23 -0
  7. data/app/commands/decidim/voca/admin/code_census/save_code_list.rb +34 -0
  8. data/app/commands/decidim/voca/code_census/confirm_code_authorization.rb +16 -0
  9. data/app/commands/decidim/voca/create_editor_file.rb +36 -0
  10. data/app/commands/decidim/voca/rack_attack_configurator.rb +244 -0
  11. data/app/commands/decidim/voca/sync_redis_routing.rb +120 -0
  12. data/app/commands/decidim/voca/user_fields_configurator.rb +40 -0
  13. data/app/controllers/decidim/voca/admin/application_controller.rb +4 -6
  14. data/app/controllers/decidim/voca/admin/code_census/code_lists_controller.rb +40 -0
  15. data/app/controllers/decidim/voca/application_controller.rb +4 -6
  16. data/app/controllers/decidim/voca/code_census/authorizations_controller.rb +53 -0
  17. data/app/controllers/decidim/voca/editor_files_controller.rb +47 -0
  18. data/app/controllers/decidim/voca/geolocation_controller.rb +32 -0
  19. data/app/forms/decidim/voca/admin/code_census/code_list_form.rb +21 -0
  20. data/app/forms/decidim/voca/admin/organization_config_form.rb +24 -0
  21. data/app/forms/decidim/voca/code_census/code_form.rb +41 -0
  22. data/app/forms/decidim/voca/editor_file_form.rb +18 -0
  23. data/app/jobs/decidim/voca/machine_translate_awesome_menu_label_job.rb +63 -0
  24. data/app/jobs/decidim/voca/machine_translate_component_setting_job.rb +58 -0
  25. data/app/jobs/decidim/voca/machine_translate_content_block_setting_job.rb +85 -0
  26. data/app/models/decidim/voca/conversation_uuid.rb +18 -0
  27. data/app/models/decidim/voca/editor_file.rb +18 -0
  28. data/app/models/decidim/voca/validation_code.rb +13 -0
  29. data/app/overrides/admin_add_machine_translation_flag.rb +36 -0
  30. data/app/overrides/insert_assets.rb +26 -0
  31. data/app/overrides/insert_weglot_scripts.rb +36 -0
  32. data/app/overrides/proposal_camera.rb +18 -0
  33. data/app/overrides/show_votes.rb +27 -0
  34. data/app/overrides/voca_footer.rb +52 -0
  35. data/app/packs/entrypoints/admin-decidim-voca.js +2 -0
  36. data/app/packs/entrypoints/admin-decidim-voca.scss +1 -0
  37. data/app/packs/entrypoints/decidim-voca-fixes.scss +1 -0
  38. data/app/packs/entrypoints/decidim-voca.js +1 -0
  39. data/app/packs/entrypoints/decidim-voca.scss +1 -0
  40. data/app/packs/images/voca-logo-primary-x3.png +0 -0
  41. data/app/packs/src/decidim/direct_uploads/upload_field.js +150 -0
  42. data/app/packs/src/decidim/voca/admin/voca.js +16 -0
  43. data/app/packs/src/decidim/voca/proposal_better_ux/use_camera_button.js +39 -0
  44. data/app/packs/src/decidim/voca/proposal_better_ux/utils/get_current_position.js +21 -0
  45. data/app/packs/src/decidim/voca/proposal_better_ux/utils/get_proposal_form.js +13 -0
  46. data/app/packs/src/decidim/voca/proposal_better_ux/utils/loading.js +23 -0
  47. data/app/packs/src/decidim/voca/proposal_better_ux/utils/locate_coordinates.js +23 -0
  48. data/app/packs/src/decidim/voca/proposal_custom_fields/custom_field_renderer_override.js +152 -0
  49. data/app/packs/src/decidim/voca/proposal_custom_fields/editor_budget_field.js +329 -0
  50. data/app/packs/src/decidim/voca/proposal_custom_fields/editor_upload_field.js +85 -0
  51. data/app/packs/src/decidim/voca/proposal_custom_fields/proposal_custom_fields.js +96 -0
  52. data/app/packs/src/decidim/voca/proposal_custom_fields/render_budget_field.js +76 -0
  53. data/app/packs/src/decidim/voca/proposal_fields/render_budget_field.js +76 -0
  54. data/app/packs/src/decidim/voca/questionnaire/scroll_questionnaire_steps_to_top.js +18 -0
  55. data/app/packs/src/decidim/voca/voca.js +4 -0
  56. data/app/packs/src/decidim/voca/weglot/index.js +13 -0
  57. data/app/packs/src/decidim/voca/weglot/start_weglot.js +112 -0
  58. data/app/packs/src/decidim/voca/weglot/switcher.js +92 -0
  59. data/app/packs/src/decidim/voca/weglot/wait_for_weglot.js +10 -0
  60. data/app/packs/stylesheets/decidim/voca/_custom_proposal_fields.scss +111 -0
  61. data/app/packs/stylesheets/decidim/voca/_decidim_voca.scss +5 -0
  62. data/app/packs/stylesheets/decidim/voca/_decidim_voca_fixes.scss +25 -0
  63. data/app/packs/stylesheets/decidim/voca/_primary_footer.scss +77 -0
  64. data/app/packs/stylesheets/decidim/voca/_proposal_camera.scss +14 -0
  65. data/app/packs/stylesheets/decidim/voca/_weglot.scss +61 -0
  66. data/app/packs/stylesheets/decidim/voca/admin/_decidim_voca.scss +5 -0
  67. data/app/packs/stylesheets/decidim/voca/admin/_full_machine_translation.scss +34 -0
  68. data/app/permissions/decidim/voca/admin/permissions.rb +31 -0
  69. data/app/permissions/decidim/voca/permissions.rb +17 -0
  70. data/app/views/decidim/voca/admin/code_census/authorizations/new.html.erb +33 -0
  71. data/app/views/decidim/voca/admin/code_census/code_lists/edit.html.erb +27 -0
  72. data/app/views/decidim/voca/code_census/authorizations/new.html.erb +24 -0
  73. data/app/views/decidim/voca/deepl/overrides/_admin_machine_translation_alert.html.erb +14 -0
  74. data/app/views/decidim/voca/rack_attack/_blocked.html.erb +151 -0
  75. data/app/views/decidim/voca/weglot/_js_configuration.html.erb +14 -0
  76. data/app/views/decidim/voca/weglot/_locale_switcher.html.erb +14 -0
  77. data/app/views/decidim/voca/weglot/_locale_switcher_mobile.erb +14 -0
  78. data/app/views/decidim/voca/weglot/_topbar_locale_switcher.html.erb +14 -0
  79. data/config/assets.rb +12 -0
  80. data/config/i18n-tasks.yml +14 -5
  81. data/config/locales/cs.yml +94 -0
  82. data/config/locales/custom_fields.cs.yml +30 -0
  83. data/config/locales/custom_fields.en.yml +41 -0
  84. data/config/locales/custom_fields.fr.yml +30 -0
  85. data/config/locales/custom_fields.it.yml +30 -0
  86. data/config/locales/en.yml +97 -4
  87. data/config/locales/fr.yml +102 -0
  88. data/config/locales/it.yml +94 -0
  89. data/lib/decidim/voca/awesome_menu_label_machine_translation.rb +73 -0
  90. data/lib/decidim/voca/awesome_menu_labels.rb +28 -0
  91. data/lib/decidim/voca/cache_namespace.rb +21 -0
  92. data/lib/decidim/voca/code_census/admin_engine.rb +22 -0
  93. data/lib/decidim/voca/code_census/engine.rb +29 -0
  94. data/lib/decidim/voca/code_census/workflow.rb +7 -0
  95. data/lib/decidim/voca/code_census.rb +4 -0
  96. data/lib/decidim/voca/component_setting_manifest.rb +27 -0
  97. data/lib/decidim/voca/component_setting_pending_locales.rb +33 -0
  98. data/lib/decidim/voca/component_translated_settings_machine_translation.rb +86 -0
  99. data/lib/decidim/voca/configuration.rb +23 -0
  100. data/lib/decidim/voca/content_block_setting_manifest.rb +67 -0
  101. data/lib/decidim/voca/content_block_translated_settings_machine_translation.rb +100 -0
  102. data/lib/decidim/voca/deepl/deepl_active_job_context.rb +27 -0
  103. data/lib/decidim/voca/deepl/deepl_context.rb +78 -0
  104. data/lib/decidim/voca/deepl/deepl_form_builder_overrides.rb +82 -0
  105. data/lib/decidim/voca/deepl/deepl_machine_translator.rb +61 -0
  106. data/lib/decidim/voca/deepl/deepl_middleware.rb +83 -0
  107. data/lib/decidim/voca/deepl/engine_config.rb +179 -0
  108. data/lib/decidim/voca/deepl/translation_bar_overrides.rb +20 -0
  109. data/lib/decidim/voca/deepl.rb +9 -0
  110. data/lib/decidim/voca/engine.rb +318 -11
  111. data/lib/decidim/voca/export/comment_serializer_localized_csv.rb +34 -0
  112. data/lib/decidim/voca/export/csv_with_locale_transformer.rb +53 -0
  113. data/lib/decidim/voca/export/proposal_serializer_localized_csv.rb +45 -0
  114. data/lib/decidim/voca/export/user_answers_serializer_localized_csv.rb +54 -0
  115. data/lib/decidim/voca/good_job_settings.rb +74 -0
  116. data/lib/decidim/voca/installation.rb +33 -0
  117. data/lib/decidim/voca/machine_translation/translate_string.rb +121 -0
  118. data/lib/decidim/voca/machine_translation_human_source.rb +29 -0
  119. data/lib/decidim/voca/machine_translation_resource_job_voca.rb +65 -0
  120. data/lib/decidim/voca/organization_voca_extensions.rb +31 -0
  121. data/lib/decidim/voca/overrides/csv_export_serializers.rb +51 -0
  122. data/lib/decidim/voca/overrides/meetings/dates_and_map_cell_overrides.rb +20 -0
  123. data/lib/decidim/voca/overrides/menu_breadcrumb_last_activity_cache.rb +31 -0
  124. data/lib/decidim/voca/overrides/mod_secure/conversation_controller_overrides.rb +19 -0
  125. data/lib/decidim/voca/overrides/mod_secure/conversation_sanitize.rb +29 -0
  126. data/lib/decidim/voca/overrides/mod_secure/conversation_uuid.rb +34 -0
  127. data/lib/decidim/voca/overrides/mod_secure/user_conversations_redirect_overrides.rb +53 -0
  128. data/lib/decidim/voca/overrides/mod_secure/user_profile_verification_override.rb +31 -0
  129. data/lib/decidim/voca/overrides/newsletter_helper_overrides.rb +30 -0
  130. data/lib/decidim/voca/overrides/resource_presenter_overrides.rb +30 -0
  131. data/lib/decidim/voca/overrides/sanitize_helper_overrides.rb +39 -0
  132. data/lib/decidim/voca/sync_locales/README.md +13 -0
  133. data/lib/decidim/voca/sync_locales/awesome_menu_label_sync.rb +89 -0
  134. data/lib/decidim/voca/sync_locales/command.rb +54 -0
  135. data/lib/decidim/voca/sync_locales/component_setting_sync.rb +72 -0
  136. data/lib/decidim/voca/sync_locales/content_block_setting_sync.rb +86 -0
  137. data/lib/decidim/voca/sync_locales/field_hash_normalizer.rb +98 -0
  138. data/lib/decidim/voca/sync_locales/locale_context.rb +589 -0
  139. data/lib/decidim/voca/sync_locales/machine_translation_enqueuer.rb +60 -0
  140. data/lib/decidim/voca/sync_locales/relation_lint_runner.rb +55 -0
  141. data/lib/decidim/voca/sync_locales/runner.rb +352 -0
  142. data/lib/decidim/voca/sync_locales.rb +11 -0
  143. data/lib/decidim/voca/update_column_without_callbacks.rb +21 -0
  144. data/lib/decidim/voca/version.rb +13 -3
  145. data/lib/decidim/voca.rb +42 -13
  146. data/lib/decidim-voca.rb +5 -0
  147. data/lib/tasks/decidim/voca/voca_anonymize.rake +41 -0
  148. data/lib/tasks/decidim/voca/voca_clean_machine_translations.rake +22 -0
  149. data/lib/tasks/decidim/voca/voca_enhanced_invalid_record.rake +141 -0
  150. data/lib/tasks/decidim/voca/voca_install_migration.rake +45 -0
  151. data/lib/tasks/decidim/voca/voca_relation_lint.rake +12 -0
  152. data/lib/tasks/decidim/voca/voca_sync_locales.rake +10 -0
  153. data/lib/tasks/decidim/voca/voca_upgrade.rake +13 -0
  154. data/lib/tasks/decidim/voca/voca_webpacker.rake +58 -0
  155. metadata +248 -55
  156. data/app/assets/config/voca_manifest.js +0 -0
  157. data/app/assets/images/decidim/voca/icon.svg +0 -1
  158. data/app/commands/decidim/voca/organization/command.rb +0 -16
  159. data/app/commands/decidim/voca/organization/organization_command.rb +0 -17
  160. data/app/commands/decidim/voca/organization/update_color_command.rb +0 -35
  161. data/app/commands/decidim/voca/organization/update_environment_command.rb +0 -23
  162. data/app/commands/decidim/voca/organization/update_feature_command.rb +0 -32
  163. data/app/commands/decidim/voca/organization/update_file_upload_command.rb +0 -45
  164. data/app/commands/decidim/voca/organization/update_locale_command.rb +0 -53
  165. data/app/commands/decidim/voca/organization/update_naming_command.rb +0 -30
  166. data/app/commands/decidim/voca/organization/update_permission_command.rb +0 -31
  167. data/app/commands/decidim/voca/organization/update_smtp_command.rb +0 -51
  168. data/app/jobs/decidim/voca/command_job.rb +0 -36
  169. data/app/jobs/decidim/voca/webhook_notifier_job.rb +0 -57
  170. data/app/rpc/decidim/voca/decidim_service_controller.rb +0 -68
  171. data/app/rpc/decidim/voca/rpc/enum_casting.rb +0 -58
  172. data/app/rpc/decidim/voca/rpc/get_settings.rb +0 -144
  173. data/app/rpc/decidim/voca/rpc/health.rb +0 -18
  174. data/app/rpc/decidim/voca/rpc/seed_admin.rb +0 -75
  175. data/app/rpc/decidim/voca/rpc/set_settings.rb +0 -56
  176. data/app/rpc/decidim/voca/rpc/setup_db.rb +0 -38
  177. data/config/environments/development.rb +0 -6
  178. data/config/spring.rb +0 -2
  179. data/lib/decidim/voca/admin.rb +0 -10
  180. data/lib/decidim/voca/admin_engine.rb +0 -27
  181. data/lib/decidim/voca/backup/app_backup.rb +0 -169
  182. data/lib/decidim/voca/backup/app_decrypt_backup_file.rb +0 -50
  183. data/lib/decidim/voca/backup/app_encrypt_backup_file.rb +0 -49
  184. data/lib/decidim/voca/backup/app_upload_to_s3.rb +0 -49
  185. data/lib/decidim/voca/middleware/dynamic_config_middleware.rb +0 -42
  186. data/lib/decidim/voca/rpc/decidim_pb.rb +0 -134
  187. data/lib/decidim/voca/rpc/decidim_services_pb.rb +0 -30
  188. data/lib/decidim/voca/test/factories.rb +0 -9
  189. data/lib/decidim/voca/updater.rb +0 -50
  190. data/lib/tasks/voca.rake +0 -88
@@ -0,0 +1,102 @@
1
+ ---
2
+ fr:
3
+ time:
4
+ formats:
5
+ 12h_24h: "%H:%M"
6
+ decidim:
7
+ core:
8
+ actions:
9
+ unauthorized: "Vous n'êtes pas autorisé à effectuer cette action."
10
+ wizard_step_form:
11
+ wizard_aside:
12
+ back: "Retour"
13
+ authorization_handlers:
14
+ code_census:
15
+ name: "Code"
16
+ explanation: "Vérifiez votre identité en utilisant un code d'accès fourni par l'organisation."
17
+ application:
18
+ geocoding:
19
+ unconfigured: "La géocodification n'est pas configurée pour cette organisation."
20
+ events:
21
+ proposals:
22
+ proposal_state_changed_for_authors:
23
+ affected_user:
24
+ email_intro: 'La proposition "%{resource_title}" est passée à l''état "%{state}". Vous pouvez lire la réponse sur cette page :'
25
+ email_outro: Vous avez reçu cette notification parce que vous êtes un(e) auteur(e) de "%{resource_title}".
26
+ email_subject: Votre proposition a changé d'état (%{state})
27
+ notification_title: L'état de votre proposition <a href="%{resource_path}">%{resource_title}</a> est passé à %{state}.
28
+ email_intro: 'La proposition "%{resource_title}" a changé d''état pour devenir "%{state}". Tu peux lire la réponse dans cette page :'
29
+ email_outro: Tu as reçu cette notification car tu es un auteur de "%{resource_title}".
30
+ email_subject: Ta proposition a changé d'état (%{state})
31
+ notification_title: Ta proposition <a href="%{resource_path}">%{resource_title}</a> a changé d'état et est devenue "%{state}".
32
+ proposals:
33
+ models:
34
+ proposal:
35
+ fields:
36
+ votes_on_going: Votes (en cours)
37
+ voca:
38
+ code_census:
39
+ create:
40
+ success: "Votre code d'accès a été créé."
41
+ authorizations:
42
+ new:
43
+ title: Vérifier avec le code
44
+ code: Code d'accès
45
+ submit: Vérifier
46
+ create:
47
+ success: Vous êtes maintenant autorisé.
48
+ error: Le code fourni n'est pas valide.
49
+ admin:
50
+ code_census:
51
+ authorizations:
52
+ new:
53
+ title: Générer des codes d'autorisation
54
+ intro: Utilisez cette page pour créer des codes d'autorisation pour vos utilisateurs.
55
+ info: Entrez les détails de l'utilisateur ci-dessous. Le système générera un code d'accès unique qui peut être partagé avec l'utilisateur pour vérification.
56
+ example: "Exemple : Entrez l'email ou l'identifiant de l'utilisateur"
57
+ code_lists:
58
+ edit:
59
+ title: Code (%{count})
60
+ form:
61
+ label: Codes
62
+ help: Collez ou tapez tous les codes autorisés, un par ligne.
63
+ submit: Enregistrer les codes
64
+ update:
65
+ success: Codes enregistrés.
66
+ error: Les codes n'ont pas pu être enregistrés.
67
+ machine_translation_alert:
68
+ button: Change de langue
69
+ description_html: '<p>La langue "%{current_locale}" est entièrement traduite par la machine, tu dois passer à "%{default_locale}".</p>
70
+
71
+ '
72
+ title: 'Change de langue
73
+
74
+ '
75
+ footer_text: Un espace démocratique pour vos communautés
76
+ proposals:
77
+ find_my_location: Ma position
78
+ take_photo: Prendre une photo
79
+ editor_files:
80
+ create:
81
+ success: "Fichier téléchargé avec succès."
82
+ error: "Le fichier n'a pas pu être téléchargé."
83
+ rack_attack:
84
+ blocked:
85
+ description: Trop de requêtes détectées. Veuillez patienter quelques minutes avant de réessayer. Contactez le support si vous avez besoin d'aide.
86
+ subtitle: Limite de taux dépassée
87
+ title: Accès Temporairement Restreint
88
+ machine_translation_alert:
89
+ title: |
90
+ Changer de langue
91
+ description_html: |
92
+ <p>La langue "%{current_locale}" est entièrement traduite par la machine, vous devez passer à "%{default_locale}".</p>
93
+ button: Changer de langue
94
+ devise:
95
+ mailer:
96
+ confirmation_instructions:
97
+ instruction_html: 'Vous pouvez confirmer votre compte email par le lien ci-dessous:'
98
+ layouts:
99
+ decidim:
100
+ footer:
101
+ decidim_title: Votre plateforme
102
+ help_title: Aide
@@ -0,0 +1,94 @@
1
+ ---
2
+ it:
3
+ decidim:
4
+ core:
5
+ actions:
6
+ unauthorized: "Non sei autorizzato a eseguire questa azione."
7
+ wizard_step_form:
8
+ wizard_aside:
9
+ back: "Indietro"
10
+ authorization_handlers:
11
+ code_census:
12
+ name: "Codice censimento"
13
+ explanation: "Verifica la tua identità utilizzando un codice di accesso fornito dall'organizzazione."
14
+ application:
15
+ geocoding:
16
+ unconfigured: "La geocodifica non è configurata per questa organizzazione."
17
+ events:
18
+ proposals:
19
+ proposal_state_changed_for_authors:
20
+ email_intro: 'La proposta "%{resource_title}" ha cambiato il suo stato in "%{state}". Puoi leggere la risposta in questa pagina:'
21
+ email_outro: Hai ricevuto questa notifica perché sei un autore di "%{resource_title}".
22
+ email_subject: La tua proposta ha cambiato stato (%{state})
23
+ notification_title: La tua proposta <a href="%{resource_path}">%{resource_title}</a> ha cambiato il suo stato in "%{state}".
24
+ proposals:
25
+ models:
26
+ proposal:
27
+ fields:
28
+ votes_on_going: Votazioni (in corso)
29
+ voca:
30
+ code_census:
31
+ create:
32
+ success: "Il tuo codice di accesso è stato creato."
33
+ authorizations:
34
+ new:
35
+ title: Verifica con codice censimento
36
+ code: Codice di accesso
37
+ submit: Verifica
38
+ create:
39
+ success: Ora sei autorizzato.
40
+ error: Il codice fornito non è valido.
41
+ admin:
42
+ code_census:
43
+ authorizations:
44
+ new:
45
+ title: Genera codici di autorizzazione
46
+ intro: Usa questa pagina per creare codici di autorizzazione per i tuoi utenti.
47
+ info: Inserisci i dettagli dell'utente qui sotto. Il sistema genererà un codice di accesso univoco che può essere condiviso con l'utente per la verifica.
48
+ example: "Esempio: Inserisci l'email o l'identificatore dell'utente"
49
+ code_lists:
50
+ edit:
51
+ title: Codice censimento (%{count})
52
+ form:
53
+ label: Codici
54
+ help: Incolla o digita tutti i codici consentiti, uno per riga.
55
+ submit: Salva codici
56
+ update:
57
+ success: Codici salvati.
58
+ error: I codici non possono essere salvati.
59
+ machine_translation_alert:
60
+ button: Cambia lingua
61
+ description_html: '<p>La lingua "%{current_locale}" è completamente tradotta dalla macchina, devi passare a "%{default_locale}".</p>
62
+
63
+ '
64
+ title: 'Cambia lingua
65
+
66
+ '
67
+ editor_files:
68
+ create:
69
+ success: "File caricato con successo."
70
+ error: "Impossibile caricare il file."
71
+ footer_text: Uno spazio democratico per la tua comunità
72
+ proposals:
73
+ find_my_location: Usa la mia posizione
74
+ take_photo: Scatta una foto
75
+ rack_attack:
76
+ machine_translation_alert:
77
+ title: |
78
+ Cambia lingua
79
+ description_html: |
80
+ <p>La lingua "%{current_locale}" è completamente tradotta dalla macchina, devi passare a "%{default_locale}".</p>
81
+ button: Cambia lingua
82
+ blocked:
83
+ description: Sono state rilevate troppe richieste. Attendi qualche minuto prima di riprovare. Contatta il supporto se hai bisogno di assistenza.
84
+ subtitle: Limite di velocità superato
85
+ title: Accesso temporaneamente limitato
86
+ devise:
87
+ mailer:
88
+ confirmation_instructions:
89
+ instruction_html: 'Puoi confermare il tuo account e-mail attraverso il link sottostante:'
90
+ layouts:
91
+ decidim:
92
+ footer:
93
+ decidim_title: La tua piattaforma
94
+ help_title: Aiuto
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Enqueues {MachineTranslateAwesomeMenuLabelJob} when Awesome menu item labels change.
6
+ module AwesomeMenuLabelMachineTranslation
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ after_create :enqueue_awesome_menu_label_machine_translation
11
+ after_update :enqueue_awesome_menu_label_machine_translation
12
+ end
13
+
14
+ def enqueue_awesome_menu_label_machine_translation
15
+ return unless enqueue_awesome_menu_label_mt_prerequisites?
16
+
17
+ change = saved_changes["value"] || saved_changes[:value]
18
+ return if change.blank?
19
+
20
+ org = organization
21
+ default = org.default_locale.to_s
22
+ old_items = menu_items_from(change[0])
23
+ new_items = menu_items_from(change[1])
24
+
25
+ new_items.each { |item| enqueue_item_if_default_locale_changed(item, old_items, default, org) }
26
+ end
27
+
28
+ private
29
+
30
+ def enqueue_awesome_menu_label_mt_prerequisites?
31
+ saved_change_to_value? &&
32
+ AwesomeMenuLabels.menu_config_value?(value) &&
33
+ Decidim.machine_translation_service_klass &&
34
+ organization&.enable_machine_translations?
35
+ end
36
+
37
+ def menu_items_from(raw)
38
+ AwesomeMenuLabels.menu_items(raw)
39
+ end
40
+
41
+ def enqueue_item_if_default_locale_changed(item, old_items, default, org)
42
+ url = item["url"].to_s
43
+ return if url.blank?
44
+
45
+ new_label = item["label"]
46
+ return unless new_label.is_a?(Hash)
47
+
48
+ old_item = old_items.find { |i| i["url"].to_s == url }
49
+ old_label = old_item.is_a?(Hash) ? old_item["label"] : nil
50
+ return unless label_default_locale_changed?(old_label, new_label, default)
51
+
52
+ schedule_label_jobs(url, new_label, org)
53
+ end
54
+
55
+ def label_default_locale_changed?(old_h, new_h, default)
56
+ old_h = old_h.deep_stringify_keys if old_h.is_a?(Hash)
57
+ new_h = new_h.deep_stringify_keys
58
+ old_v = old_h.is_a?(Hash) ? old_h[default] : nil
59
+ new_v = new_h[default]
60
+ old_v != new_v
61
+ end
62
+
63
+ def schedule_label_jobs(item_url, field_hash, org)
64
+ default = org.default_locale.to_s
65
+ ComponentSettingPendingLocales.for(field_hash, org).each do |target|
66
+ MachineTranslateAwesomeMenuLabelJob
67
+ .set(wait: Decidim.config.machine_translation_delay)
68
+ .perform_later(id, item_url, target, default)
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Shared shape helpers for Awesome menu +value+ arrays ({"label" => locale hash, "url" => ...}).
6
+ module AwesomeMenuLabels
7
+ module_function
8
+
9
+ def menu_config_value?(value)
10
+ menu_items(value).any?
11
+ end
12
+
13
+ def menu_items(value)
14
+ return [] unless value.is_a?(Array)
15
+
16
+ value.filter_map do |item|
17
+ next unless item.is_a?(Hash)
18
+
19
+ stringy = item.deep_stringify_keys
20
+ next unless stringy["label"].is_a?(Hash)
21
+ next if stringy["url"].blank?
22
+
23
+ stringy
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Prefix for the Memcached key. decidim-apartment appends Apartment::Tenant.current
6
+ # after this. That tenant is the distribution key for the request, not ENV DISTRIBUTION_KEY.
7
+ module CacheNamespace
8
+ module_function
9
+
10
+ def value
11
+ raw = if defined?(::CredentialsOverlay)
12
+ ::CredentialsOverlay.fetch(:cache, :namespace)
13
+ else
14
+ ENV.fetch("CACHE__NAMESPACE", nil)
15
+ end
16
+ sanitized = raw.to_s.gsub(/[^a-zA-Z0-9_-]/, "_")
17
+ sanitized.empty? ? nil : sanitized
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Admin namespace for CodeCensus admin engine/controllers
6
+ module Admin
7
+ module CodeCensus
8
+ class AdminEngine < ::Rails::Engine
9
+ isolate_namespace Decidim::Voca::Admin::CodeCensus
10
+
11
+ paths["db/migrate"] = nil
12
+ paths["lib/tasks"] = nil
13
+
14
+ routes do
15
+ resource :code_list, only: [:edit, :update], controller: "code_lists"
16
+ root to: "code_lists#edit"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ module CodeCensus
6
+ class Engine < ::Rails::Engine
7
+ isolate_namespace Decidim::Voca::CodeCensus
8
+
9
+ paths["db/migrate"] = nil
10
+ paths["lib/tasks"] = nil
11
+
12
+ routes do
13
+ resource :authorization, only: [:new, :create], as: :authorization
14
+ root to: "authorizations#new"
15
+ end
16
+
17
+ config.to_prepare do
18
+ Decidim::Verifications.register_workflow(:code_census) do |workflow|
19
+ workflow.engine = Decidim::Voca::CodeCensus::Engine
20
+ workflow.admin_engine = Decidim::Voca::Admin::CodeCensus::AdminEngine
21
+ workflow.icon = "community-line"
22
+ workflow.time_between_renewals = 1.day
23
+ workflow.ephemeral = true
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ Decidim::Verifications.register_workflow(:code_census) do |workflow|
4
+ workflow.engine = Decidim::Voca::CodeCensus::Engine
5
+ workflow.admin_engine = Decidim::Voca::Admin::CodeCensus::AdminEngine
6
+ workflow.icon = "community-line"
7
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/voca/code_census/engine"
4
+ require "decidim/voca/code_census/admin_engine"
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Introspection for component settings marked +translated: true+ in the manifest.
6
+ module ComponentSettingManifest
7
+ module_function
8
+
9
+ def translated_global_keys(manifest)
10
+ return [] unless manifest.respond_to?(:settings)
11
+
12
+ manifest.settings(:global).attributes.each_with_object([]) do |(name, attr), memo|
13
+ memo << name.to_s if attr.translated?
14
+ end
15
+ end
16
+
17
+ def translated_process_step_keys(manifest)
18
+ return [] unless manifest.respond_to?(:settings)
19
+ return [] unless manifest.settings(:step).respond_to?(:attributes)
20
+
21
+ manifest.settings(:step).attributes.each_with_object([]) do |(name, attr), memo|
22
+ memo << name.to_s if attr.translated?
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Which locales still need machine translation for a nested translatable settings hash.
6
+ module ComponentSettingPendingLocales
7
+ module_function
8
+
9
+ def for(field_hash, organization)
10
+ return [] unless field_hash.is_a?(Hash)
11
+
12
+ allowed = organization.available_locales.map(&:to_s)
13
+ default = organization.default_locale.to_s
14
+ fh = field_hash.stringify_keys
15
+
16
+ if minimalistic?(organization)
17
+ return [] if fh[default].blank?
18
+
19
+ allowed - [default]
20
+ else
21
+ human = fh.except("machine_translations").each_with_object([]) do |(loc, val), memo|
22
+ memo << loc if val.present?
23
+ end
24
+ allowed - human
25
+ end
26
+ end
27
+
28
+ def minimalistic?(organization)
29
+ organization.minimalistic_deepl? && organization.enable_machine_translations?
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Enqueues {MachineTranslateComponentSettingJob} when translated global settings change.
6
+ module ComponentTranslatedSettingsMachineTranslation
7
+ extend ActiveSupport::Concern
8
+
9
+ included do
10
+ # Use after_save callbacks (not after_commit) so +saved_changes+ is present; nested MT persists
11
+ # via +update_column+ and does not re-fire these callbacks.
12
+ after_create :enqueue_component_translated_settings_machine_translation
13
+ after_update :enqueue_component_translated_settings_machine_translation
14
+ end
15
+
16
+ def enqueue_component_translated_settings_machine_translation
17
+ return unless enqueue_component_translated_settings_mt_prerequisites?
18
+
19
+ change = saved_changes["settings"] || saved_changes[:settings]
20
+ return if change.blank?
21
+
22
+ old_g = extract_global(change[0])
23
+ new_g = extract_global(change[1])
24
+ org = organization
25
+
26
+ ComponentSettingManifest.translated_global_keys(manifest).each do |key|
27
+ enqueue_setting_if_default_locale_changed(key, old_g, new_g, org)
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def enqueue_component_translated_settings_mt_prerequisites?
34
+ saved_change_to_settings? &&
35
+ Decidim.machine_translation_service_klass &&
36
+ organization&.enable_machine_translations?
37
+ end
38
+
39
+ def enqueue_setting_if_default_locale_changed(key, old_g, new_g, org)
40
+ old_h = old_g[key]
41
+ new_h = new_g[key]
42
+ return unless new_h.is_a?(Hash)
43
+ return unless setting_default_locale_changed?(old_h, new_h, org.default_locale.to_s)
44
+
45
+ schedule_setting_jobs(key, new_h, org)
46
+ end
47
+
48
+ def extract_global(settings)
49
+ return {} if settings.blank?
50
+
51
+ settings.deep_stringify_keys["global"].presence || {}
52
+ end
53
+
54
+ def setting_default_locale_changed?(old_h, new_h, default)
55
+ old_h = old_h.deep_stringify_keys if old_h.is_a?(Hash)
56
+ new_h = new_h.deep_stringify_keys
57
+ old_v = old_h.is_a?(Hash) ? old_h[default] : nil
58
+ new_v = new_h[default]
59
+ old_v != new_v
60
+ end
61
+
62
+ def schedule_setting_jobs(key, field_hash, org)
63
+ default = org.default_locale.to_s
64
+ pending = ComponentSettingPendingLocales.for(field_hash, org)
65
+ html = rich_text_component_setting?(key)
66
+
67
+ pending.each do |target|
68
+ MachineTranslateComponentSettingJob
69
+ .set(wait: Decidim.config.machine_translation_delay)
70
+ .perform_later(id, key, target, default, html:)
71
+ end
72
+ end
73
+
74
+ def rich_text_component_setting?(key)
75
+ attr = manifest.settings(:global).attributes[key.to_sym]
76
+ return true unless attr
77
+ return false unless attr.type == :text
78
+
79
+ ctx = { component: self, participatory_space: }
80
+ attr.editor?(ctx) == true
81
+ rescue StandardError
82
+ true
83
+ end
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ class Configuration
6
+ class << self
7
+ def config = self
8
+
9
+ def configure
10
+ yield self
11
+ end
12
+ end
13
+
14
+ mattr_accessor :enable_minimalistic_deepl, default: true
15
+
16
+ mattr_accessor :enable_weglot, default: ::Decidim::Env.new("WEGLOT_API_KEY", "").present?
17
+
18
+ mattr_accessor :weglot_api_key, default: ::Decidim::Env.new("WEGLOT_API_KEY", "").to_s
19
+
20
+ mattr_accessor :enable_weglot_cache, default: false
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,67 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Voca
5
+ # Introspection for content-block settings marked +translated: true+ in the manifest.
6
+ module ContentBlockSettingManifest
7
+ module_function
8
+
9
+ def translated_keys(manifest)
10
+ return [] if manifest.blank?
11
+ return [] unless manifest.respond_to?(:settings)
12
+ return [] unless manifest.respond_to?(:has_settings?) && manifest.has_settings?
13
+
14
+ manifest.settings.attributes.each_with_object([]) do |(name, attr), memo|
15
+ memo << name.to_s if attr.translated?
16
+ end
17
+ end
18
+
19
+ # Seeds/admin often store flat +welcome_text_en+ keys (alone or mixed with nested).
20
+ # Always merge flat locale keys into the nested hash used by MT.
21
+ def coalesce_flat_keys!(settings, keys, locales)
22
+ return settings unless settings.is_a?(Hash)
23
+
24
+ keys.each do |key|
25
+ nested = settings[key].is_a?(Hash) ? settings[key].deep_stringify_keys : {}
26
+ locales.each do |loc|
27
+ flat = "#{key}_#{loc}"
28
+ next unless settings.has_key?(flat)
29
+
30
+ nested[loc.to_s] = settings.delete(flat)
31
+ end
32
+ settings[key] = nested if nested.any?
33
+ end
34
+ settings
35
+ end
36
+
37
+ # Decidim content-block JSONB is flat (+welcome_text_fr+). Expand nested (+machine_translations+)
38
+ # back to flat keys so HeroCell/admin schema resolve locale values.
39
+ def expand_to_flat_keys!(settings, keys)
40
+ return settings unless settings.is_a?(Hash)
41
+
42
+ keys.each { |key| expand_one_key_to_flat!(settings, key) }
43
+ settings
44
+ end
45
+
46
+ def expand_one_key_to_flat!(settings, key)
47
+ nested = settings.delete(key)
48
+ return unless nested.is_a?(Hash)
49
+
50
+ nested = nested.deep_stringify_keys
51
+ mt = nested.delete("machine_translations")
52
+ nested.each do |loc, val|
53
+ next if loc.blank?
54
+
55
+ settings["#{key}_#{loc}"] = val
56
+ end
57
+ return unless mt.is_a?(Hash)
58
+
59
+ mt.deep_stringify_keys.each do |loc, val|
60
+ next if loc.blank? || val.blank?
61
+
62
+ settings["#{key}_#{loc}"] = val
63
+ end
64
+ end
65
+ end
66
+ end
67
+ end