i18n_feedback 0.8.2 → 0.8.3

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +6 -319
  3. data/lib/i18n_feedback.rb +12 -35
  4. metadata +14 -62
  5. data/CHANGELOG.md +0 -191
  6. data/MIT-LICENSE +0 -21
  7. data/Rakefile +0 -14
  8. data/app/controllers/i18n_feedback/application_controller.rb +0 -32
  9. data/app/controllers/i18n_feedback/suggestions_controller.rb +0 -92
  10. data/app/helpers/i18n_feedback/tag_helper.rb +0 -19
  11. data/app/models/i18n_feedback/application_record.rb +0 -7
  12. data/app/models/i18n_feedback/suggestion.rb +0 -27
  13. data/app/views/i18n_feedback/suggestions/index.html.erb +0 -77
  14. data/app/views/layouts/i18n_feedback/application.html.erb +0 -96
  15. data/config/locales/i18n_feedback.ar.yml +0 -16
  16. data/config/locales/i18n_feedback.bg.yml +0 -16
  17. data/config/locales/i18n_feedback.bn.yml +0 -16
  18. data/config/locales/i18n_feedback.de.yml +0 -16
  19. data/config/locales/i18n_feedback.el.yml +0 -16
  20. data/config/locales/i18n_feedback.en.yml +0 -35
  21. data/config/locales/i18n_feedback.es.yml +0 -16
  22. data/config/locales/i18n_feedback.fr.yml +0 -16
  23. data/config/locales/i18n_feedback.hi.yml +0 -16
  24. data/config/locales/i18n_feedback.hr.yml +0 -16
  25. data/config/locales/i18n_feedback.id.yml +0 -16
  26. data/config/locales/i18n_feedback.it.yml +0 -16
  27. data/config/locales/i18n_feedback.ja.yml +0 -16
  28. data/config/locales/i18n_feedback.ko.yml +0 -16
  29. data/config/locales/i18n_feedback.lb.yml +0 -16
  30. data/config/locales/i18n_feedback.nl.yml +0 -16
  31. data/config/locales/i18n_feedback.pl.yml +0 -16
  32. data/config/locales/i18n_feedback.pt.yml +0 -16
  33. data/config/locales/i18n_feedback.ro.yml +0 -16
  34. data/config/locales/i18n_feedback.ru.yml +0 -16
  35. data/config/locales/i18n_feedback.th.yml +0 -16
  36. data/config/locales/i18n_feedback.tr.yml +0 -16
  37. data/config/locales/i18n_feedback.uk.yml +0 -16
  38. data/config/locales/i18n_feedback.ur.yml +0 -16
  39. data/config/locales/i18n_feedback.vi.yml +0 -16
  40. data/config/locales/i18n_feedback.zh-CN.yml +0 -16
  41. data/config/routes.rb +0 -13
  42. data/lib/generators/i18n_feedback/install/install_generator.rb +0 -40
  43. data/lib/generators/i18n_feedback/install/templates/create_i18n_feedback_suggestions.rb.tt +0 -22
  44. data/lib/generators/i18n_feedback/install/templates/initializer.rb +0 -56
  45. data/lib/i18n_feedback/configuration.rb +0 -91
  46. data/lib/i18n_feedback/engine.rb +0 -26
  47. data/lib/i18n_feedback/marking.rb +0 -46
  48. data/lib/i18n_feedback/middleware.rb +0 -145
  49. data/lib/i18n_feedback/version.rb +0 -5
  50. data/lib/i18n_feedback/widget.js +0 -443
  51. data/lib/i18n_feedback/widget.rb +0 -96
@@ -1,16 +0,0 @@
1
- el:
2
- i18n_feedback:
3
- pill: "Προτείνετε αλλαγές"
4
- pill_active: "Διακοπή προτάσεων (Esc)"
5
- start: "Βελτίωση μετάφρασης"
6
- stop: "Διακοπή προτάσεων (Esc)"
7
- title: "Προτείνετε διόρθωση μετάφρασης"
8
- current_text: "Τρέχον κείμενο"
9
- suggested_text: "Προτεινόμενο κείμενο"
10
- comment: "Σχόλιο"
11
- comment_placeholder: "Προαιρετική σημείωση για τον προγραμματιστή"
12
- prior_title: "Έχει ήδη προταθεί (σε εκκρεμότητα)"
13
- cancel: "Άκυρο"
14
- save: "Αποστολή πρότασης"
15
- error_blank: "Παρακαλώ εισαγάγετε μια πρόταση."
16
- error_save: "Δεν ήταν δυνατή η αποθήκευση της πρότασης."
@@ -1,35 +0,0 @@
1
- en:
2
- i18n_feedback:
3
- pill: "Suggest edits"
4
- start: "Improve translation"
5
- stop: "Stop suggesting (Esc)"
6
- pill_active: "Stop suggesting (Esc)"
7
- title: "Suggest a translation fix"
8
- current_text: "Current text"
9
- suggested_text: "Suggested text"
10
- comment: "Comment"
11
- comment_placeholder: "Optional note for the developer"
12
- prior_title: "Already suggested (pending)"
13
- cancel: "Cancel"
14
- save: "Send suggestion"
15
- error_blank: "Please enter a suggestion."
16
- error_save: "Could not save the suggestion."
17
- # Triage dashboard. English-only by default (an admin-facing surface); every
18
- # string is rendered through I18n with these as fallbacks, so a host can
19
- # translate or reword any of them under its own `i18n_feedback.*` scope.
20
- statuses:
21
- pending: "Pending"
22
- applied: "Applied"
23
- rejected: "Rejected"
24
- dashboard:
25
- title: "Translation suggestions"
26
- subtitle: "Review what reviewers proposed, then apply it to your locale files."
27
- locale: "Locale"
28
- filter: "Filter"
29
- all_locales: "All locales"
30
- current: "Current"
31
- suggested: "Suggested"
32
- ago: "ago"
33
- empty: "Nothing here yet."
34
- newer: "← Newer"
35
- older: "Older →"
@@ -1,16 +0,0 @@
1
- es:
2
- i18n_feedback:
3
- pill: "Sugerir cambios"
4
- start: "Mejorar traducción"
5
- stop: "Dejar de sugerir (Esc)"
6
- pill_active: "Dejar de sugerir (Esc)"
7
- title: "Sugerir una corrección de traducción"
8
- current_text: "Texto actual"
9
- suggested_text: "Texto sugerido"
10
- comment: "Comentario"
11
- comment_placeholder: "Nota opcional para el desarrollador"
12
- prior_title: "Ya sugerido (pendiente)"
13
- cancel: "Cancelar"
14
- save: "Enviar sugerencia"
15
- error_blank: "Introduce una sugerencia."
16
- error_save: "No se pudo guardar la sugerencia."
@@ -1,16 +0,0 @@
1
- fr:
2
- i18n_feedback:
3
- pill: "Proposer des corrections"
4
- start: "Améliorer la traduction"
5
- stop: "Arrêter de proposer (Esc)"
6
- pill_active: "Arrêter de proposer (Échap)"
7
- title: "Proposer une correction de traduction"
8
- current_text: "Texte actuel"
9
- suggested_text: "Texte proposé"
10
- comment: "Commentaire"
11
- comment_placeholder: "Note facultative pour le développeur"
12
- prior_title: "Déjà proposé (en attente)"
13
- cancel: "Annuler"
14
- save: "Envoyer la suggestion"
15
- error_blank: "Veuillez saisir une suggestion."
16
- error_save: "Impossible d'enregistrer la suggestion."
@@ -1,16 +0,0 @@
1
- hi:
2
- i18n_feedback:
3
- pill: "बदलाव सुझाएँ"
4
- start: "अनुवाद सुधारें"
5
- stop: "सुझाव देना बंद करें (Esc)"
6
- pill_active: "सुझाव देना बंद करें (Esc)"
7
- title: "अनुवाद सुधार सुझाएँ"
8
- current_text: "वर्तमान टेक्स्ट"
9
- suggested_text: "सुझाया गया टेक्स्ट"
10
- comment: "टिप्पणी"
11
- comment_placeholder: "डेवलपर के लिए वैकल्पिक टिप्पणी"
12
- prior_title: "पहले से सुझाया गया (लंबित)"
13
- cancel: "रद्द करें"
14
- save: "सुझाव भेजें"
15
- error_blank: "कृपया एक सुझाव दर्ज करें।"
16
- error_save: "सुझाव सहेजा नहीं जा सका।"
@@ -1,16 +0,0 @@
1
- hr:
2
- i18n_feedback:
3
- pill: "Predloži izmjene"
4
- pill_active: "Prestani predlagati (Esc)"
5
- start: "Poboljšaj prijevod"
6
- stop: "Prestani predlagati (Esc)"
7
- title: "Predložite ispravak prijevoda"
8
- current_text: "Trenutni tekst"
9
- suggested_text: "Predloženi tekst"
10
- comment: "Komentar"
11
- comment_placeholder: "Neobavezna napomena za razvojni tim"
12
- prior_title: "Već predloženo (na čekanju)"
13
- cancel: "Odustani"
14
- save: "Pošalji prijedlog"
15
- error_blank: "Unesite prijedlog."
16
- error_save: "Prijedlog nije moguće spremiti."
@@ -1,16 +0,0 @@
1
- id:
2
- i18n_feedback:
3
- pill: "Sarankan perubahan"
4
- start: "Perbaiki terjemahan"
5
- stop: "Berhenti menyarankan (Esc)"
6
- pill_active: "Berhenti menyarankan (Esc)"
7
- title: "Sarankan perbaikan terjemahan"
8
- current_text: "Teks saat ini"
9
- suggested_text: "Teks yang disarankan"
10
- comment: "Komentar"
11
- comment_placeholder: "Catatan opsional untuk pengembang"
12
- prior_title: "Sudah disarankan (menunggu)"
13
- cancel: "Batal"
14
- save: "Kirim saran"
15
- error_blank: "Silakan masukkan saran."
16
- error_save: "Tidak dapat menyimpan saran."
@@ -1,16 +0,0 @@
1
- it:
2
- i18n_feedback:
3
- pill: "Suggerisci modifiche"
4
- start: "Migliora la traduzione"
5
- stop: "Interrompi i suggerimenti (Esc)"
6
- pill_active: "Interrompi i suggerimenti (Esc)"
7
- title: "Suggerisci una correzione di traduzione"
8
- current_text: "Testo attuale"
9
- suggested_text: "Testo suggerito"
10
- comment: "Commento"
11
- comment_placeholder: "Nota facoltativa per lo sviluppatore"
12
- prior_title: "Già suggerito (in sospeso)"
13
- cancel: "Annulla"
14
- save: "Invia suggerimento"
15
- error_blank: "Inserisci un suggerimento."
16
- error_save: "Impossibile salvare il suggerimento."
@@ -1,16 +0,0 @@
1
- ja:
2
- i18n_feedback:
3
- pill: "修正を提案"
4
- start: "翻訳を改善"
5
- stop: "提案を終了 (Esc)"
6
- pill_active: "提案を終了(Esc)"
7
- title: "翻訳の修正を提案"
8
- current_text: "現在のテキスト"
9
- suggested_text: "提案するテキスト"
10
- comment: "コメント"
11
- comment_placeholder: "開発者への任意のメモ"
12
- prior_title: "提案済み(保留中)"
13
- cancel: "キャンセル"
14
- save: "提案を送信"
15
- error_blank: "提案を入力してください。"
16
- error_save: "提案を保存できませんでした。"
@@ -1,16 +0,0 @@
1
- ko:
2
- i18n_feedback:
3
- pill: "수정 제안"
4
- start: "번역 개선"
5
- stop: "제안 중지 (Esc)"
6
- pill_active: "제안 중지 (Esc)"
7
- title: "번역 수정 제안"
8
- current_text: "현재 텍스트"
9
- suggested_text: "제안 텍스트"
10
- comment: "의견"
11
- comment_placeholder: "개발자를 위한 선택 메모"
12
- prior_title: "이미 제안됨 (대기 중)"
13
- cancel: "취소"
14
- save: "제안 보내기"
15
- error_blank: "제안을 입력하세요."
16
- error_save: "제안을 저장할 수 없습니다."
@@ -1,16 +0,0 @@
1
- lb:
2
- i18n_feedback:
3
- pill: "Ännerunge virschloen"
4
- pill_active: "Virschléi stoppen (Esc)"
5
- start: "Iwwersetzung verbesseren"
6
- stop: "Virschléi stoppen (Esc)"
7
- title: "Eng Iwwersetzungskorrektur virschloen"
8
- current_text: "Aktuellen Text"
9
- suggested_text: "Virgeschloenen Text"
10
- comment: "Kommentar"
11
- comment_placeholder: "Optional Notiz fir den Entwéckler"
12
- prior_title: "Scho virgeschloen (a Waardschleef)"
13
- cancel: "Ofbriechen"
14
- save: "Virschlag schécken"
15
- error_blank: "Gitt wannechgelift e Virschlag an."
16
- error_save: "De Virschlag konnt net gespäichert ginn."
@@ -1,16 +0,0 @@
1
- nl:
2
- i18n_feedback:
3
- pill: "Wijzigingen voorstellen"
4
- start: "Vertaling verbeteren"
5
- stop: "Stoppen met voorstellen (Esc)"
6
- pill_active: "Stoppen met voorstellen (Esc)"
7
- title: "Een vertaalcorrectie voorstellen"
8
- current_text: "Huidige tekst"
9
- suggested_text: "Voorgestelde tekst"
10
- comment: "Opmerking"
11
- comment_placeholder: "Optionele notitie voor de ontwikkelaar"
12
- prior_title: "Al voorgesteld (in behandeling)"
13
- cancel: "Annuleren"
14
- save: "Suggestie versturen"
15
- error_blank: "Voer een suggestie in."
16
- error_save: "Kan de suggestie niet opslaan."
@@ -1,16 +0,0 @@
1
- pl:
2
- i18n_feedback:
3
- pill: "Zaproponuj zmiany"
4
- start: "Popraw tłumaczenie"
5
- stop: "Zakończ sugerowanie (Esc)"
6
- pill_active: "Zakończ sugerowanie (Esc)"
7
- title: "Zaproponuj poprawkę tłumaczenia"
8
- current_text: "Bieżący tekst"
9
- suggested_text: "Proponowany tekst"
10
- comment: "Komentarz"
11
- comment_placeholder: "Opcjonalna notatka dla programisty"
12
- prior_title: "Już zaproponowano (oczekujące)"
13
- cancel: "Anuluj"
14
- save: "Wyślij sugestię"
15
- error_blank: "Wprowadź sugestię."
16
- error_save: "Nie udało się zapisać sugestii."
@@ -1,16 +0,0 @@
1
- pt:
2
- i18n_feedback:
3
- pill: "Sugerir edições"
4
- start: "Melhorar tradução"
5
- stop: "Parar de sugerir (Esc)"
6
- pill_active: "Parar de sugerir (Esc)"
7
- title: "Sugerir uma correção de tradução"
8
- current_text: "Texto atual"
9
- suggested_text: "Texto sugerido"
10
- comment: "Comentário"
11
- comment_placeholder: "Nota opcional para o desenvolvedor"
12
- prior_title: "Já sugerido (pendente)"
13
- cancel: "Cancelar"
14
- save: "Enviar sugestão"
15
- error_blank: "Insira uma sugestão."
16
- error_save: "Não foi possível salvar a sugestão."
@@ -1,16 +0,0 @@
1
- ro:
2
- i18n_feedback:
3
- pill: "Sugerează modificări"
4
- pill_active: "Oprește sugestiile (Esc)"
5
- start: "Îmbunătățește traducerea"
6
- stop: "Oprește sugestiile (Esc)"
7
- title: "Sugerează o corectură de traducere"
8
- current_text: "Text curent"
9
- suggested_text: "Text sugerat"
10
- comment: "Comentariu"
11
- comment_placeholder: "Notă opțională pentru dezvoltator"
12
- prior_title: "Deja sugerat (în așteptare)"
13
- cancel: "Anulează"
14
- save: "Trimite sugestia"
15
- error_blank: "Introduceți o sugestie."
16
- error_save: "Sugestia nu a putut fi salvată."
@@ -1,16 +0,0 @@
1
- ru:
2
- i18n_feedback:
3
- pill: "Предложить правки"
4
- start: "Улучшить перевод"
5
- stop: "Остановить предложения (Esc)"
6
- pill_active: "Остановить предложения (Esc)"
7
- title: "Предложить исправление перевода"
8
- current_text: "Текущий текст"
9
- suggested_text: "Предлагаемый текст"
10
- comment: "Комментарий"
11
- comment_placeholder: "Необязательная заметка для разработчика"
12
- prior_title: "Уже предложено (в ожидании)"
13
- cancel: "Отмена"
14
- save: "Отправить предложение"
15
- error_blank: "Введите предложение."
16
- error_save: "Не удалось сохранить предложение."
@@ -1,16 +0,0 @@
1
- th:
2
- i18n_feedback:
3
- pill: "แนะนำการแก้ไข"
4
- start: "ปรับปรุงคำแปล"
5
- stop: "หยุดแนะนำ (Esc)"
6
- pill_active: "หยุดแนะนำ (Esc)"
7
- title: "แนะนำการแก้ไขคำแปล"
8
- current_text: "ข้อความปัจจุบัน"
9
- suggested_text: "ข้อความที่แนะนำ"
10
- comment: "ความคิดเห็น"
11
- comment_placeholder: "หมายเหตุเพิ่มเติมสำหรับนักพัฒนา"
12
- prior_title: "แนะนำไปแล้ว (รอดำเนินการ)"
13
- cancel: "ยกเลิก"
14
- save: "ส่งคำแนะนำ"
15
- error_blank: "โปรดป้อนคำแนะนำ"
16
- error_save: "ไม่สามารถบันทึกคำแนะนำได้"
@@ -1,16 +0,0 @@
1
- tr:
2
- i18n_feedback:
3
- pill: "Düzenleme öner"
4
- start: "Çeviriyi iyileştir"
5
- stop: "Önermeyi durdur (Esc)"
6
- pill_active: "Önermeyi durdur (Esc)"
7
- title: "Çeviri düzeltmesi öner"
8
- current_text: "Mevcut metin"
9
- suggested_text: "Önerilen metin"
10
- comment: "Yorum"
11
- comment_placeholder: "Geliştirici için isteğe bağlı not"
12
- prior_title: "Zaten önerildi (beklemede)"
13
- cancel: "İptal"
14
- save: "Öneriyi gönder"
15
- error_blank: "Lütfen bir öneri girin."
16
- error_save: "Öneri kaydedilemedi."
@@ -1,16 +0,0 @@
1
- uk:
2
- i18n_feedback:
3
- pill: "Запропонувати зміни"
4
- start: "Покращити переклад"
5
- stop: "Зупинити пропозиції (Esc)"
6
- pill_active: "Зупинити пропозиції (Esc)"
7
- title: "Запропонувати виправлення перекладу"
8
- current_text: "Поточний текст"
9
- suggested_text: "Запропонований текст"
10
- comment: "Коментар"
11
- comment_placeholder: "Необов’язкова примітка для розробника"
12
- prior_title: "Уже запропоновано (очікує)"
13
- cancel: "Скасувати"
14
- save: "Надіслати пропозицію"
15
- error_blank: "Будь ласка, введіть пропозицію."
16
- error_save: "Не вдалося зберегти пропозицію."
@@ -1,16 +0,0 @@
1
- ur:
2
- i18n_feedback:
3
- pill: "ترامیم تجویز کریں"
4
- start: "ترجمہ بہتر بنائیں"
5
- stop: "تجویز کرنا بند کریں (Esc)"
6
- pill_active: "تجویز کرنا بند کریں (Esc)"
7
- title: "ترجمے کی اصلاح تجویز کریں"
8
- current_text: "موجودہ متن"
9
- suggested_text: "تجویز کردہ متن"
10
- comment: "تبصرہ"
11
- comment_placeholder: "ڈویلپر کے لیے اختیاری نوٹ"
12
- prior_title: "پہلے ہی تجویز کیا جا چکا (زیر التوا)"
13
- cancel: "منسوخ کریں"
14
- save: "تجویز بھیجیں"
15
- error_blank: "براہ کرم ایک تجویز درج کریں۔"
16
- error_save: "تجویز محفوظ نہیں ہو سکی۔"
@@ -1,16 +0,0 @@
1
- vi:
2
- i18n_feedback:
3
- pill: "Đề xuất chỉnh sửa"
4
- start: "Cải thiện bản dịch"
5
- stop: "Dừng đề xuất (Esc)"
6
- pill_active: "Dừng đề xuất (Esc)"
7
- title: "Đề xuất sửa bản dịch"
8
- current_text: "Văn bản hiện tại"
9
- suggested_text: "Văn bản đề xuất"
10
- comment: "Nhận xét"
11
- comment_placeholder: "Ghi chú tùy chọn cho nhà phát triển"
12
- prior_title: "Đã đề xuất (đang chờ)"
13
- cancel: "Hủy"
14
- save: "Gửi đề xuất"
15
- error_blank: "Vui lòng nhập một đề xuất."
16
- error_save: "Không thể lưu đề xuất."
@@ -1,16 +0,0 @@
1
- zh-CN:
2
- i18n_feedback:
3
- pill: "建议修改"
4
- start: "改进翻译"
5
- stop: "停止建议 (Esc)"
6
- pill_active: "停止建议(Esc)"
7
- title: "建议翻译修正"
8
- current_text: "当前文本"
9
- suggested_text: "建议文本"
10
- comment: "备注"
11
- comment_placeholder: "给开发者的可选备注"
12
- prior_title: "已提交建议(待处理)"
13
- cancel: "取消"
14
- save: "发送建议"
15
- error_blank: "请输入建议。"
16
- error_save: "无法保存建议。"
data/config/routes.rb DELETED
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- I18nFeedback::Engine.routes.draw do
4
- # index is the read-only admin dashboard; create + the `context` collection
5
- # route are the widget's public API (see SuggestionsController). There is
6
- # deliberately no update/destroy — the tool never mutates suggestions from the
7
- # UI, since it can't write to the host's locale files.
8
- resources :suggestions, only: %i[index create] do
9
- get :context, on: :collection
10
- end
11
-
12
- root to: 'suggestions#index'
13
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rails/generators'
4
- require 'rails/generators/active_record'
5
-
6
- module I18nFeedback
7
- module Generators
8
- class InstallGenerator < Rails::Generators::Base
9
- include ActiveRecord::Generators::Migration
10
-
11
- source_root File.expand_path('templates', __dir__)
12
-
13
- desc 'Installs i18n_feedback: config initializer, migration, and engine mount.'
14
-
15
- def create_initializer
16
- copy_file 'initializer.rb', 'config/initializers/i18n_feedback.rb'
17
- end
18
-
19
- def create_suggestions_migration
20
- migration_template 'create_i18n_feedback_suggestions.rb.tt',
21
- 'db/migrate/create_i18n_feedback_suggestions.rb'
22
- end
23
-
24
- def mount_engine
25
- route %(mount I18nFeedback::Engine => "/i18n_feedback")
26
- end
27
-
28
- def post_install
29
- say "\ni18n_feedback installed. Run `rails db:migrate`, then boot in development", :green
30
- say "and look for the “Suggest edits” pill in the bottom-left corner.\n"
31
- end
32
-
33
- private
34
-
35
- def migration_version
36
- "[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
37
- end
38
- end
39
- end
40
- end
@@ -1,22 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class CreateI18nFeedbackSuggestions < ActiveRecord::Migration<%= migration_version %>
4
- def change
5
- create_table :i18n_feedback_suggestions do |t|
6
- t.string :translation_key, null: false
7
- t.string :locale, null: false
8
- t.text :old_value
9
- t.text :proposed_value, null: false
10
- t.text :comment
11
- t.string :page_url
12
- t.string :status, null: false, default: 'pending'
13
- t.string :author_id
14
- t.string :author_label
15
-
16
- t.timestamps
17
- end
18
-
19
- add_index :i18n_feedback_suggestions, %i[translation_key locale]
20
- add_index :i18n_feedback_suggestions, :status
21
- end
22
- end
@@ -1,56 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- I18nFeedback.configure do |config|
4
- # Environments the tool is active in. It is never active anywhere else.
5
- config.enabled_environments = %w[development staging]
6
-
7
- # Per-request gate on top of the environment check. Return false to hide the
8
- # tool. Receives the Rack::Request — plug in an admin check, a feature flag, an
9
- # IP allowlist, etc.
10
- #
11
- # config.enabled = ->(request) { true }
12
-
13
- # Who may open the triage dashboard (mounted at your `mount_path`) to review,
14
- # apply, and delete suggestions. Independent of the checks above — the widget
15
- # is dev/staging-only, but you may want to triage from production. Defaults to
16
- # development only; wire it to your own admin check to open it elsewhere.
17
- #
18
- # config.authorize_admin = ->(request) { request.env["warden"]&.user&.admin? }
19
-
20
- # Attribute a suggestion to a user (optional). Return an object responding to
21
- # #id (ideally #email too), or nil. Receives the Rack::Request. You resolve the
22
- # user however your app does — session, Warden, a token, etc.
23
- #
24
- # config.current_user = ->(request) { nil }
25
-
26
- # How to label the author in the "already suggested" list.
27
- #
28
- # config.author_label = ->(user) { user.try(:email) }
29
-
30
- # The widget is injected into HTML responses automatically. Set this to false to
31
- # place it yourself with `<%= i18n_feedback_tag %>` at the end of your layout.
32
- #
33
- # config.auto_inject = true
34
-
35
- # Show the floating "Suggest edits" pill. Set false to hide it and toggle
36
- # suggest mode from your own link instead, e.g.
37
- # `<%= link_to "Proofread", "?i18n_feedback=true" %>`. "?i18n_feedback=false"
38
- # exits; the choice is remembered in a cookie.
39
- #
40
- # config.show_pill = true
41
- # config.toggle_param = "i18n_feedback"
42
-
43
- # Keep this in sync with the `mount` line in config/routes.rb.
44
- #
45
- # config.mount_path = "/i18n_feedback"
46
-
47
- # Called with each saved suggestion — notify Slack, send an email, open a
48
- # ticket. Runs inline after save, so keep it fast or hand off to a job.
49
- #
50
- # config.on_submit = ->(suggestion) { SuggestionMailer.with(suggestion:).created.deliver_later }
51
-
52
- # Per-IP throttle on the submission endpoint, passed to Rails' built-in rate
53
- # limiter (Rails 7.2+; ignored on 7.1). Set nil to disable.
54
- #
55
- # config.rate_limit = { to: 30, within: 60 }
56
- end
@@ -1,91 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module I18nFeedback
4
- # Host-tunable settings. Everything has a safe default, so a fresh install works
5
- # with zero configuration in development; the hooks below let an app decide who
6
- # sees the tool and how suggestions are attributed.
7
- class Configuration
8
- # Environments the tool is active in. It is never active anywhere else, so a
9
- # production deploy can't accidentally expose the key markers or the endpoint.
10
- attr_accessor :enabled_environments
11
-
12
- # Per-request gate, on top of the environment check. Return false to hide the
13
- # tool for this request. Receives the Rack::Request. Plug in an admin check, a
14
- # feature flag, an allowlist, etc.
15
- attr_accessor :enabled
16
-
17
- # Per-request gate for the triage dashboard (browse suggestions, change their
18
- # status, delete). Independent of `enabled` and `enabled_environments`: the
19
- # widget is dev/staging-only, but a maintainer may want to triage from
20
- # production. Defaults to development only, so a fresh install never exposes
21
- # the dashboard until you wire it to your own admin check.
22
- attr_accessor :authorize_admin
23
-
24
- # Resolve the current user for attribution (optional). Return an object
25
- # responding to #id, or nil. Receives the Rack::Request.
26
- attr_accessor :current_user
27
-
28
- # Turn a resolved user into a short label shown in the "already suggested"
29
- # list. Receives whatever #current_user returned.
30
- attr_accessor :author_label
31
-
32
- # The locales a suggestion may target. Used to validate submissions.
33
- attr_accessor :available_locales
34
-
35
- # Inject the widget into HTML responses automatically. Set false to place it
36
- # yourself with `<%= i18n_feedback_tag %>` in your layout.
37
- attr_accessor :auto_inject
38
-
39
- # Where the engine is mounted. The widget posts suggestions to
40
- # "#{mount_path}/suggestions", so keep this in sync with the `mount` line in
41
- # your routes.
42
- attr_accessor :mount_path
43
-
44
- # Show the floating toggle pill. Set false to hide it and drive suggest mode
45
- # from your own link instead (see #toggle_param).
46
- attr_accessor :show_pill
47
-
48
- # Text on the floating toggle pill. Leave nil to use the localized default
49
- # ("Suggest edits", translated via the `i18n_feedback.pill` I18n key).
50
- attr_accessor :pill_label
51
-
52
- # The query-string parameter that turns suggest mode on/off, so a host can
53
- # link to it from anywhere: "?i18n_feedback=true" enables it, "false" exits.
54
- # The choice is remembered in a cookie, so the rest of the app stays in
55
- # suggest mode without the parameter.
56
- attr_accessor :toggle_param
57
-
58
- # Called with each saved suggestion — notify Slack, send an email, open a
59
- # ticket. Runs inline after save; keep it fast or hand off to a job.
60
- attr_accessor :on_submit
61
-
62
- # Per-IP throttle for the public submission endpoint, as keyword arguments
63
- # for Rails' rate limiter (Rails 7.2+; ignored on 7.1). Read once when the
64
- # controller loads — set it in an initializer. nil disables throttling.
65
- attr_accessor :rate_limit
66
-
67
- def initialize
68
- @enabled_environments = %w[development staging]
69
- @enabled = ->(_request) { true }
70
- @authorize_admin = ->(_request) { Rails.env.development? }
71
- @current_user = ->(_request) {}
72
- @author_label = ->(user) { user.respond_to?(:email) ? user.email : user&.to_s }
73
- @available_locales = -> { I18n.available_locales.map(&:to_s) }
74
- @auto_inject = true
75
- @mount_path = '/i18n_feedback'
76
- @show_pill = true
77
- @pill_label = nil
78
- @toggle_param = 'i18n_feedback'
79
- @on_submit = ->(_suggestion) {}
80
- @rate_limit = { to: 30, within: 60 }
81
- end
82
-
83
- def environment_enabled?
84
- enabled_environments.map(&:to_s).include?(Rails.env.to_s)
85
- end
86
-
87
- def suggestions_endpoint
88
- "#{mount_path.chomp('/')}/suggestions"
89
- end
90
- end
91
- end