i18n_proofreading 1.2.0 → 1.2.1

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 (37) hide show
  1. checksums.yaml +4 -4
  2. data/AGENTS.md +1 -1
  3. data/CHANGELOG.md +23 -0
  4. data/README.md +2 -2
  5. data/config/locales/i18n_proofreading.ar.yml +1 -1
  6. data/config/locales/i18n_proofreading.bg.yml +1 -1
  7. data/config/locales/i18n_proofreading.bn.yml +1 -1
  8. data/config/locales/i18n_proofreading.de.yml +1 -1
  9. data/config/locales/i18n_proofreading.el.yml +1 -1
  10. data/config/locales/i18n_proofreading.en.yml +1 -1
  11. data/config/locales/i18n_proofreading.es.yml +1 -1
  12. data/config/locales/i18n_proofreading.fr.yml +1 -1
  13. data/config/locales/i18n_proofreading.hi.yml +1 -1
  14. data/config/locales/i18n_proofreading.hr.yml +1 -1
  15. data/config/locales/i18n_proofreading.id.yml +1 -1
  16. data/config/locales/i18n_proofreading.it.yml +1 -1
  17. data/config/locales/i18n_proofreading.ja.yml +1 -1
  18. data/config/locales/i18n_proofreading.ko.yml +1 -1
  19. data/config/locales/i18n_proofreading.lb.yml +1 -1
  20. data/config/locales/i18n_proofreading.nl.yml +1 -1
  21. data/config/locales/i18n_proofreading.pl.yml +1 -1
  22. data/config/locales/i18n_proofreading.pt.yml +1 -1
  23. data/config/locales/i18n_proofreading.ro.yml +1 -1
  24. data/config/locales/i18n_proofreading.ru.yml +1 -1
  25. data/config/locales/i18n_proofreading.th.yml +1 -1
  26. data/config/locales/i18n_proofreading.tr.yml +1 -1
  27. data/config/locales/i18n_proofreading.uk.yml +1 -1
  28. data/config/locales/i18n_proofreading.ur.yml +1 -1
  29. data/config/locales/i18n_proofreading.vi.yml +1 -1
  30. data/config/locales/i18n_proofreading.zh-CN.yml +1 -1
  31. data/lib/generators/i18n_proofreading/install/install_generator.rb +1 -1
  32. data/lib/generators/i18n_proofreading/install/templates/initializer.rb +1 -1
  33. data/lib/i18n_proofreading/configuration.rb +1 -1
  34. data/lib/i18n_proofreading/version.rb +1 -1
  35. data/lib/i18n_proofreading/widget.js +17 -13
  36. data/lib/i18n_proofreading/widget.rb +1 -1
  37. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b064bdf9957104685057c004265c500cc66817f1e80ec826c8d384596570a864
4
- data.tar.gz: 7188a0820bee5027d18f65fc234bfc55bb96a96c4066755896759e1f75bb1680
3
+ metadata.gz: 44c336fff23d26e91d584879766e3f0bce2cf6d9d73af485fdae275452f7682c
4
+ data.tar.gz: 92a38f638af73db3ce29ee5b822aafbb7bc8cc6fd925f2393c34ad542bab94f6
5
5
  SHA512:
6
- metadata.gz: 0f7c3fc2dee542a89d4a6f594d057fbbf6c02559a5bae2b04fd5cfa7a5a297bc76bb2c3bfc1705addf36bad1cd488208e76ccf17647c7613a266bd080b8a7843
7
- data.tar.gz: f9dda98042e0a0ffc27a41eceecb7c6c6693a3e7e53373dc4c7bddb6dcb1eb3116ed97c3dac587a5a4b9bb07956438a3b52731d2c0dc6a7a5dd3d5470b5fe673
6
+ metadata.gz: b47ef1083e05980617e51f1a5bfec96e065969f53d0e92ba29b3f4e962ac310e560683f37a263be1a032e1853bd28d16883acdc5fb4b0cb1e7962f15272c1abf
7
+ data.tar.gz: 592a870c92d94cf50a885d5494d6fc78a3bb217dc877f36b1a89fa469a9eef6695872aca405f86b686f57adf38f248497256756e5869d7a2e1d61b7dbba51a55
data/AGENTS.md CHANGED
@@ -27,7 +27,7 @@ The generator writes `config/initializers/i18n_proofreading.rb`, one migration (
27
27
 
28
28
  ### 2. There is no step 2 — do not edit the layout
29
29
 
30
- The widget injects itself into HTML responses through a Rack middleware, so **no layout change is needed**. Boot the app in development and look for the **"Suggest edits"** pill bottom-left. Click it, then click any text; `Esc` exits.
30
+ The widget injects itself into HTML responses through a Rack middleware, so **no layout change is needed**. Boot the app in development and look for the **"Improve translation"** pill bottom-left. Click it, then click any text; `Esc` exits.
31
31
 
32
32
  Only if the host prefers to place it explicitly:
33
33
 
data/CHANGELOG.md CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [1.2.1] - 2026-10-30
6
+
7
+ ### Fixed
8
+
9
+ - **Esc and the pill now leave suggest mode on apps that harden their
10
+ cookies.** The widget used to switch the mode by writing the
11
+ `i18n_proofreading` cookie from JavaScript and reloading. An app that adds
12
+ `HttpOnly` to every cookie (SecureHeaders does in production) makes that
13
+ cookie unwritable from a script, so the delete was silently dropped and the
14
+ page reloaded still in suggest mode. The widget now visits the page with the
15
+ toggle parameter, the same server-side switch a host link uses.
16
+ - Costs: turning the mode on or off is now a redirect (one extra request)
17
+ instead of a reload. A page reached by a form POST is left with a GET to the
18
+ same URL, where a reload used to re-submit the form.
19
+
20
+ ### Changed
21
+
22
+ - **The pill reads "Improve translation"** (the `start` label, already
23
+ translated in every bundled language) instead of "Suggest edits", which did
24
+ not say what the tool is for. A host that overrides
25
+ `i18n_proofreading.pill` in its own locale files, or sets `pill_label`,
26
+ keeps its own text.
27
+
5
28
  ## [1.2.0] - 2026-10-30
6
29
 
7
30
  ### Fixed
data/README.md CHANGED
@@ -36,7 +36,7 @@ It creates three idempotent sample suggestions across pending, applied, and
36
36
  rejected states. Running the task again refreshes those records instead of
37
37
  duplicating them.
38
38
 
39
- Boot the app in development and look for the **"Suggest edits"** pill in the
39
+ Boot the app in development and look for the **"Improve translation"** pill in the
40
40
  bottom-left. Click it, then click any text. `Esc` exits.
41
41
 
42
42
  No layout change needed — the widget injects itself into HTML responses.
@@ -112,7 +112,7 @@ Everything is optional — the defaults work out of the box in development. In
112
112
  | `author_label` | the user's `email` | Label shown for the author |
113
113
  | `available_locales` | `I18n.available_locales` | Which locales a suggestion may target |
114
114
  | `auto_inject` | `true` | Inject the widget into HTML responses |
115
- | `show_pill` | `true` | The floating "Suggest edits" pill. `:auto` shows it only on pages without a toggle link of your own |
115
+ | `show_pill` | `true` | The floating "Improve translation" pill. `:auto` shows it only on pages without a toggle link of your own |
116
116
  | `pill_label` | `nil` | Fixed pill text. `nil` uses the localized default |
117
117
  | `toggle_param` | `"i18n_proofreading"` | Query param that toggles suggest mode |
118
118
  | `mount_path` | `"/i18n_proofreading"` | Keep in sync with `mount` in `routes.rb` |
@@ -1,6 +1,6 @@
1
1
  ar:
2
2
  i18n_proofreading:
3
- pill: "اقترح تعديلات"
3
+ pill: "تحسين الترجمة"
4
4
  start: "تحسين الترجمة"
5
5
  stop: "إيقاف الاقتراح (Esc)"
6
6
  pill_active: "إيقاف الاقتراح (Esc)"
@@ -1,6 +1,6 @@
1
1
  bg:
2
2
  i18n_proofreading:
3
- pill: "Предложи промени"
3
+ pill: "Подобряване на превода"
4
4
  pill_active: "Спиране на предложенията (Esc)"
5
5
  start: "Подобряване на превода"
6
6
  stop: "Спиране на предложенията (Esc)"
@@ -1,6 +1,6 @@
1
1
  bn:
2
2
  i18n_proofreading:
3
- pill: "সম্পাদনা প্রস্তাব করুন"
3
+ pill: "অনুবাদ উন্নত করুন"
4
4
  start: "অনুবাদ উন্নত করুন"
5
5
  stop: "প্রস্তাব দেওয়া বন্ধ করুন (Esc)"
6
6
  pill_active: "প্রস্তাব দেওয়া বন্ধ করুন (Esc)"
@@ -1,6 +1,6 @@
1
1
  de:
2
2
  i18n_proofreading:
3
- pill: "Änderungen vorschlagen"
3
+ pill: "Übersetzung verbessern"
4
4
  start: "Übersetzung verbessern"
5
5
  stop: "Vorschläge beenden (Esc)"
6
6
  pill_active: "Vorschläge beenden (Esc)"
@@ -1,6 +1,6 @@
1
1
  el:
2
2
  i18n_proofreading:
3
- pill: "Προτείνετε αλλαγές"
3
+ pill: "Βελτίωση μετάφρασης"
4
4
  pill_active: "Διακοπή προτάσεων (Esc)"
5
5
  start: "Βελτίωση μετάφρασης"
6
6
  stop: "Διακοπή προτάσεων (Esc)"
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  i18n_proofreading:
3
- pill: "Suggest edits"
3
+ pill: "Improve translation"
4
4
  start: "Improve translation"
5
5
  stop: "Stop suggesting (Esc)"
6
6
  pill_active: "Stop suggesting (Esc)"
@@ -1,6 +1,6 @@
1
1
  es:
2
2
  i18n_proofreading:
3
- pill: "Sugerir cambios"
3
+ pill: "Mejorar traducción"
4
4
  start: "Mejorar traducción"
5
5
  stop: "Dejar de sugerir (Esc)"
6
6
  pill_active: "Dejar de sugerir (Esc)"
@@ -1,6 +1,6 @@
1
1
  fr:
2
2
  i18n_proofreading:
3
- pill: "Proposer des corrections"
3
+ pill: "Améliorer la traduction"
4
4
  start: "Améliorer la traduction"
5
5
  stop: "Arrêter de proposer (Esc)"
6
6
  pill_active: "Arrêter de proposer (Échap)"
@@ -1,6 +1,6 @@
1
1
  hi:
2
2
  i18n_proofreading:
3
- pill: "बदलाव सुझाएँ"
3
+ pill: "अनुवाद सुधारें"
4
4
  start: "अनुवाद सुधारें"
5
5
  stop: "सुझाव देना बंद करें (Esc)"
6
6
  pill_active: "सुझाव देना बंद करें (Esc)"
@@ -1,6 +1,6 @@
1
1
  hr:
2
2
  i18n_proofreading:
3
- pill: "Predloži izmjene"
3
+ pill: "Poboljšaj prijevod"
4
4
  pill_active: "Prestani predlagati (Esc)"
5
5
  start: "Poboljšaj prijevod"
6
6
  stop: "Prestani predlagati (Esc)"
@@ -1,6 +1,6 @@
1
1
  id:
2
2
  i18n_proofreading:
3
- pill: "Sarankan perubahan"
3
+ pill: "Perbaiki terjemahan"
4
4
  start: "Perbaiki terjemahan"
5
5
  stop: "Berhenti menyarankan (Esc)"
6
6
  pill_active: "Berhenti menyarankan (Esc)"
@@ -1,6 +1,6 @@
1
1
  it:
2
2
  i18n_proofreading:
3
- pill: "Suggerisci modifiche"
3
+ pill: "Migliora la traduzione"
4
4
  start: "Migliora la traduzione"
5
5
  stop: "Interrompi i suggerimenti (Esc)"
6
6
  pill_active: "Interrompi i suggerimenti (Esc)"
@@ -1,6 +1,6 @@
1
1
  ja:
2
2
  i18n_proofreading:
3
- pill: "修正を提案"
3
+ pill: "翻訳を改善"
4
4
  start: "翻訳を改善"
5
5
  stop: "提案を終了 (Esc)"
6
6
  pill_active: "提案を終了(Esc)"
@@ -1,6 +1,6 @@
1
1
  ko:
2
2
  i18n_proofreading:
3
- pill: "수정 제안"
3
+ pill: "번역 개선"
4
4
  start: "번역 개선"
5
5
  stop: "제안 중지 (Esc)"
6
6
  pill_active: "제안 중지 (Esc)"
@@ -1,6 +1,6 @@
1
1
  lb:
2
2
  i18n_proofreading:
3
- pill: "Ännerunge virschloen"
3
+ pill: "Iwwersetzung verbesseren"
4
4
  pill_active: "Virschléi stoppen (Esc)"
5
5
  start: "Iwwersetzung verbesseren"
6
6
  stop: "Virschléi stoppen (Esc)"
@@ -1,6 +1,6 @@
1
1
  nl:
2
2
  i18n_proofreading:
3
- pill: "Wijzigingen voorstellen"
3
+ pill: "Vertaling verbeteren"
4
4
  start: "Vertaling verbeteren"
5
5
  stop: "Stoppen met voorstellen (Esc)"
6
6
  pill_active: "Stoppen met voorstellen (Esc)"
@@ -1,6 +1,6 @@
1
1
  pl:
2
2
  i18n_proofreading:
3
- pill: "Zaproponuj zmiany"
3
+ pill: "Popraw tłumaczenie"
4
4
  start: "Popraw tłumaczenie"
5
5
  stop: "Zakończ sugerowanie (Esc)"
6
6
  pill_active: "Zakończ sugerowanie (Esc)"
@@ -1,6 +1,6 @@
1
1
  pt:
2
2
  i18n_proofreading:
3
- pill: "Sugerir edições"
3
+ pill: "Melhorar tradução"
4
4
  start: "Melhorar tradução"
5
5
  stop: "Parar de sugerir (Esc)"
6
6
  pill_active: "Parar de sugerir (Esc)"
@@ -1,6 +1,6 @@
1
1
  ro:
2
2
  i18n_proofreading:
3
- pill: "Sugerează modificări"
3
+ pill: "Îmbunătățește traducerea"
4
4
  pill_active: "Oprește sugestiile (Esc)"
5
5
  start: "Îmbunătățește traducerea"
6
6
  stop: "Oprește sugestiile (Esc)"
@@ -1,6 +1,6 @@
1
1
  ru:
2
2
  i18n_proofreading:
3
- pill: "Предложить правки"
3
+ pill: "Улучшить перевод"
4
4
  start: "Улучшить перевод"
5
5
  stop: "Остановить предложения (Esc)"
6
6
  pill_active: "Остановить предложения (Esc)"
@@ -1,6 +1,6 @@
1
1
  th:
2
2
  i18n_proofreading:
3
- pill: "แนะนำการแก้ไข"
3
+ pill: "ปรับปรุงคำแปล"
4
4
  start: "ปรับปรุงคำแปล"
5
5
  stop: "หยุดแนะนำ (Esc)"
6
6
  pill_active: "หยุดแนะนำ (Esc)"
@@ -1,6 +1,6 @@
1
1
  tr:
2
2
  i18n_proofreading:
3
- pill: "Düzenleme öner"
3
+ pill: "Çeviriyi iyileştir"
4
4
  start: "Çeviriyi iyileştir"
5
5
  stop: "Önermeyi durdur (Esc)"
6
6
  pill_active: "Önermeyi durdur (Esc)"
@@ -1,6 +1,6 @@
1
1
  uk:
2
2
  i18n_proofreading:
3
- pill: "Запропонувати зміни"
3
+ pill: "Покращити переклад"
4
4
  start: "Покращити переклад"
5
5
  stop: "Зупинити пропозиції (Esc)"
6
6
  pill_active: "Зупинити пропозиції (Esc)"
@@ -1,6 +1,6 @@
1
1
  ur:
2
2
  i18n_proofreading:
3
- pill: "ترامیم تجویز کریں"
3
+ pill: "ترجمہ بہتر بنائیں"
4
4
  start: "ترجمہ بہتر بنائیں"
5
5
  stop: "تجویز کرنا بند کریں (Esc)"
6
6
  pill_active: "تجویز کرنا بند کریں (Esc)"
@@ -1,6 +1,6 @@
1
1
  vi:
2
2
  i18n_proofreading:
3
- pill: "Đề xuất chỉnh sửa"
3
+ pill: "Cải thiện bản dịch"
4
4
  start: "Cải thiện bản dịch"
5
5
  stop: "Dừng đề xuất (Esc)"
6
6
  pill_active: "Dừng đề xuất (Esc)"
@@ -1,6 +1,6 @@
1
1
  zh-CN:
2
2
  i18n_proofreading:
3
- pill: "建议修改"
3
+ pill: "改进翻译"
4
4
  start: "改进翻译"
5
5
  stop: "停止建议 (Esc)"
6
6
  pill_active: "停止建议(Esc)"
@@ -30,7 +30,7 @@ module I18nProofreading
30
30
  def post_install
31
31
  say "\ni18n_proofreading installed. Run `rails db:migrate`, then boot in development", :green
32
32
  say 'Optional: run `bin/rails i18n_proofreading:seed_demo` for sample suggestions.'
33
- say "and look for the “Suggest edits” pill in the bottom-left corner.\n"
33
+ say "and look for the “Improve translation” pill in the bottom-left corner.\n"
34
34
  end
35
35
  end
36
36
  end
@@ -52,7 +52,7 @@ I18nProofreading.configure do |config|
52
52
  #
53
53
  # config.auto_inject = true
54
54
 
55
- # Show the floating "Suggest edits" pill. Set false to hide it and toggle
55
+ # Show the floating "Improve translation" pill. Set false to hide it and toggle
56
56
  # suggest mode from your own link instead, e.g.
57
57
  # `<%= link_to "Proofread", "?i18n_proofreading=true" %>`. "?i18n_proofreading=false"
58
58
  # exits; the choice is remembered in a cookie. Set :auto to hide the pill only
@@ -73,7 +73,7 @@ module I18nProofreading
73
73
  attr_accessor :show_pill
74
74
 
75
75
  # Text on the floating toggle pill. Leave nil to use the localized default
76
- # ("Suggest edits", translated via the `i18n_proofreading.pill` I18n key).
76
+ # ("Improve translation", translated via the `i18n_proofreading.pill` I18n key).
77
77
  attr_accessor :pill_label
78
78
 
79
79
  # The query-string parameter that turns suggest mode on/off, so a host can
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module I18nProofreading
4
- VERSION = '1.2.0'
4
+ VERSION = '1.2.1'
5
5
  end
@@ -5,8 +5,9 @@
5
5
  * data-i18n-proofreading-config> the server injects — re-read on every render so a
6
6
  * Turbo visit always reflects the current page's suggest state.
7
7
  *
8
- * A floating pill toggles "suggest mode", which is server state: the pill sets or
9
- * clears the i18n_proofreading cookie and reloads, so the backend only prints the
8
+ * A floating pill toggles "suggest mode", which is server state: the pill visits
9
+ * the page with the toggle parameter, the middleware sets or clears the
10
+ * i18n_proofreading cookie and redirects back, so the backend only prints the
10
11
  * "…text… ⟦some.key.path⟧" markers while proofreading. The markers are never shown
11
12
  * to the user — on load the widget strips each ⟦key⟧ token out of the DOM and
12
13
  * stashes the key on its element. A click on any such element opens a popover to
@@ -33,10 +34,11 @@
33
34
  // must never reach the screen either.
34
35
  var ANY_TOKEN = new RegExp(LEFT + "[^" + RIGHT + "]*" + RIGHT);
35
36
  var TOKENS = new RegExp("\\s*" + LEFT + "[^" + RIGHT + "]*" + RIGHT, "g");
36
- var COOKIE = "i18n_proofreading";
37
- // A host's own on/off link ("?i18n_proofreading=true"). The parameter name
38
- // is server configuration, the same on every page.
39
- var TOGGLE_LINK = 'a[href*="' + (config.toggleParam || "i18n_proofreading") + '="]';
37
+ // The query parameter that switches suggest mode ("?i18n_proofreading=true"),
38
+ // and a host's own on/off link carrying it. Server configuration, the same on
39
+ // every page.
40
+ var TOGGLE_PARAM = config.toggleParam || "i18n_proofreading";
41
+ var TOGGLE_LINK = 'a[href*="' + TOGGLE_PARAM + '="]';
40
42
  var MARKED_ATTRS = ["placeholder", "title", "aria-label", "value"];
41
43
  var Z = 2147483000;
42
44
 
@@ -138,13 +140,15 @@
138
140
 
139
141
  // --- suggest-mode toggle --------------------------------------------------
140
142
 
143
+ // Hand the switch to the middleware, the same way a host link does, rather
144
+ // than writing the cookie here: a host that hardens every cookie (HttpOnly,
145
+ // as SecureHeaders does) makes it unwritable from JavaScript, so a script-side
146
+ // delete was silently dropped and the reload came back still in suggest mode.
147
+ // The middleware sets the cookie and redirects back without the parameter.
141
148
  function toggle() {
142
- if (config.active) {
143
- document.cookie = COOKIE + "=; path=/; max-age=0";
144
- } else {
145
- document.cookie = COOKIE + "=1; path=/";
146
- }
147
- window.location.reload();
149
+ var url = new URL(window.location.href);
150
+ url.searchParams.set(TOGGLE_PARAM, config.active ? "false" : "true");
151
+ window.location.assign(url.toString());
148
152
  }
149
153
 
150
154
  // --- marker stripping -----------------------------------------------------
@@ -246,7 +250,7 @@
246
250
  }
247
251
 
248
252
  function labelText() {
249
- return config.pillLabel || t("pill", "Suggest edits");
253
+ return config.pillLabel || t("pill", "Improve translation");
250
254
  }
251
255
 
252
256
  // Resolve a server-translated label, falling back to English if the config
@@ -106,7 +106,7 @@ module I18nProofreading
106
106
  # stays fully worded even for a locale the gem ships no translation for.
107
107
  def labels(locale)
108
108
  {
109
- pill: t(locale, :pill, 'Suggest edits'),
109
+ pill: t(locale, :pill, 'Improve translation'),
110
110
  pillActive: t(locale, :pill_active, 'Stop suggesting (Esc)'),
111
111
  title: t(locale, :title, 'Suggest a translation fix'),
112
112
  currentText: t(locale, :current_text, 'Current text'),
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_proofreading
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yaroslav Shmarov