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.
- checksums.yaml +4 -4
- data/AGENTS.md +1 -1
- data/CHANGELOG.md +23 -0
- data/README.md +2 -2
- data/config/locales/i18n_proofreading.ar.yml +1 -1
- data/config/locales/i18n_proofreading.bg.yml +1 -1
- data/config/locales/i18n_proofreading.bn.yml +1 -1
- data/config/locales/i18n_proofreading.de.yml +1 -1
- data/config/locales/i18n_proofreading.el.yml +1 -1
- data/config/locales/i18n_proofreading.en.yml +1 -1
- data/config/locales/i18n_proofreading.es.yml +1 -1
- data/config/locales/i18n_proofreading.fr.yml +1 -1
- data/config/locales/i18n_proofreading.hi.yml +1 -1
- data/config/locales/i18n_proofreading.hr.yml +1 -1
- data/config/locales/i18n_proofreading.id.yml +1 -1
- data/config/locales/i18n_proofreading.it.yml +1 -1
- data/config/locales/i18n_proofreading.ja.yml +1 -1
- data/config/locales/i18n_proofreading.ko.yml +1 -1
- data/config/locales/i18n_proofreading.lb.yml +1 -1
- data/config/locales/i18n_proofreading.nl.yml +1 -1
- data/config/locales/i18n_proofreading.pl.yml +1 -1
- data/config/locales/i18n_proofreading.pt.yml +1 -1
- data/config/locales/i18n_proofreading.ro.yml +1 -1
- data/config/locales/i18n_proofreading.ru.yml +1 -1
- data/config/locales/i18n_proofreading.th.yml +1 -1
- data/config/locales/i18n_proofreading.tr.yml +1 -1
- data/config/locales/i18n_proofreading.uk.yml +1 -1
- data/config/locales/i18n_proofreading.ur.yml +1 -1
- data/config/locales/i18n_proofreading.vi.yml +1 -1
- data/config/locales/i18n_proofreading.zh-CN.yml +1 -1
- data/lib/generators/i18n_proofreading/install/install_generator.rb +1 -1
- data/lib/generators/i18n_proofreading/install/templates/initializer.rb +1 -1
- data/lib/i18n_proofreading/configuration.rb +1 -1
- data/lib/i18n_proofreading/version.rb +1 -1
- data/lib/i18n_proofreading/widget.js +17 -13
- data/lib/i18n_proofreading/widget.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44c336fff23d26e91d584879766e3f0bce2cf6d9d73af485fdae275452f7682c
|
|
4
|
+
data.tar.gz: 92a38f638af73db3ce29ee5b822aafbb7bc8cc6fd925f2393c34ad542bab94f6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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 **"
|
|
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 **"
|
|
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 "
|
|
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` |
|
|
@@ -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 “
|
|
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 "
|
|
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
|
-
# ("
|
|
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
|
|
@@ -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
|
|
9
|
-
*
|
|
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
|
-
|
|
37
|
-
//
|
|
38
|
-
//
|
|
39
|
-
var
|
|
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
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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", "
|
|
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, '
|
|
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'),
|