Repository navigation
Support English and Spanish in Coplan - #352
Conversation
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
🤖 @codex review Please review the code and audit every changed Spanish translation against the English and the UI that uses it. Flag changes to intent, particularly around permissions, visibility, and destructive actions, as well as misleading, offensive, or hidden content. Also check browser language selection, language-specific live updates, and the translation lint coverage. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 47f3e4920f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| <h1 class="page-header__title"><%= link_to @plan.title, plan_browse_path(@plan), class: "history-title-link" %></h1> | ||
| <div class="page-header__byline text-sm text-muted"> | ||
| History — every version and change · <span class="section-count" id="history-count"><%= pluralize(@plan.plan_versions.count + @plan.plan_events.count, "entry") %></span> | ||
| <%= t("coplan.display.history_overview") %> · <span class="section-count" id="history-count"><%= t("coplan.display.entries", count: @plan.plan_versions.count + @plan.plan_events.count) %></span> |
There was a problem hiding this comment.
This page now shows the entry count with the translated coplan.display.entries key. Live updates still replace #history-count with an English pluralize(count, "entry"). That update comes from PlanVersion#broadcast_history_update and PlanEvent#broadcast_history_update, and it goes as raw html: to the shared plan stream. After the next revision or event, a Spanish viewer sees "4 entries" instead of "4 entradas". Render the count from a partial that uses t("coplan.display.entries", count:) and send it through Broadcaster.replace_to, so each language stream gets its own copy.
| @@ -178,19 +179,32 @@ export default class extends Controller { | |||
| if (state === "dirty") { | |||
There was a problem hiding this comment.
For the "dirty" state, setStatus now always replaces the message it gets. Before this change, it replaced only the "Unsaved changes" placeholder. Line 387 calls setStatus(t("coplan.client.editor.merged_live"), "dirty") when another person's live edit merges into an unsaved draft. That message is now always replaced by "Saving soon…" or "Changes ready to save", so the user is not told that their draft took in another edit. Replace the message only when the caller passes none, for example with if (message == null).
| # agent) — not news. | ||
| next if plan.created_by_user_id == current_user.id | ||
| { plan: plan, badge: "new to you" } | ||
| { plan: plan, badge: I18n.t("coplan.documents.messages.new_to_you") } |
There was a problem hiding this comment.
The translated badge text is also the CSS modifier. plans/index.html.erb:182 builds the class recent-updates__badge--<%= entry[:badge].parameterize %>. In Spanish, the class becomes recent-updates__badge--nuevo-para-ti, so the .recent-updates__badge--new-to-you style in workspace.css no longer applies. The sibling "updated" badge is still an English literal in both languages. Store a stable kind such as :new_to_you or :updated in the entry. Use the kind for the class, and translate the label in the view.
| include Coplan::KeyboardShortcutsHelper | ||
| include MarkdownHelper | ||
|
|
||
| def use_coplan_client_messages(*groups) |
There was a problem hiding this comment.
Each page must list the client message groups that its Stimulus controllers need. But render_markdown attaches the coplan--mermaid, coplan--data-grid, and coplan--image-expand controllers on every page that renders Markdown, and those controllers read coplan.client.reader.*. The agent guide and reference pages (agent_instructions/guide.html.erb and reference.html.erb) render Markdown with tables, but they do not call use_coplan_client_messages(:reader). On those pages, the expand, zoom, close, and sort controls get empty labels and accessible names. Before this PR, they had English labels. Register the :reader group from render_markdown itself, so every page that mounts these controllers also gets their messages.
|
|
||
| # Only renderer-generated labels vary with the UI language. The same | ||
| # cached HTML can serve both locales for ordinary authored Markdown. | ||
| def markdown_cache_locale(source, footnotes: false, presentations: false) |
There was a problem hiding this comment.
markdown_cache_locale decides if cached document and comment HTML can be shared between languages. It uses a hand-kept list of source patterns: task checkboxes, iframe blocks, footnotes, and presentations. If someone adds a translated label to another part of the renderer and does not update this list, the first viewer's language is cached and served to all viewers for 15 minutes. No test catches that. Add a spec that renders a fixture with every renderer feature in English and in Spanish. The spec must fail if the two outputs differ while markdown_cache_locale returns nil.
|
|
||
| private | ||
|
|
||
| def check_node(node, value, file, path) |
There was a problem hiding this comment.
This script is now the CI gate for the translation catalogs, but it has no automated tests. spec/lib/local_ci_spec.rb replaces it with a stub that exits 0, and the PR body says the reject rules were checked by hand. If a later edit stops one rule from rejecting bad catalogs, CI stays green. Add a spec that writes small fixture catalogs to a temp directory and runs the script. Assert a non-zero exit for each rule: missing key, missing plural form, mismatched placeholders, duplicate keys in one file and across files, HTML markup, unused key, and unknown Stimulus key. Also assert that a clean fixture passes.
| threads = plan.comment_threads.where.not(anchor_kind: nil).with_kept_comments | ||
| .includes({ comments: { reactions: :user } }, :created_by_user).to_a | ||
|
|
||
| each_ui_stream(plan) do |stream| |
There was a problem hiding this comment.
replace_plan_content and replace_plan_references now render once for each enabled language and send each copy to its own stream, such as [plan, "ui-es"]. The only multi-language broadcaster spec covers append_to. The replace_plan_content and replace_plan_references specs run with one language. A regression could send Spanish HTML to the English stream or drop one language's thread popovers, and no test would fail. Add specs for both methods with ui_locales set to %i[en es]. Assert that each language stream gets its own content body, section-update data, and thread popovers in that language.
What changed and why
Coplan now ships English and Spanish for its main web interface. Settings can follow the browser or apply a language for the current browser session. Hosts choose which locales to enable and which to use as the fallback.
Rails renders translated copy and includes the messages Stimulus needs with the page HTML. Live updates reuse translated fragments across viewers of the same language. CI checks catalog structure. The contributor guide and review rules cover translation meaning, tone, permissions, and hidden or offensive copy.
Evidence
How to try it
Run
bin/devand sign in to the demo ashampton@example.com. Open/_/settings, select Español, then open the demo library. Settings and the plan controls should appear in Spanish. Choose Browser language to follow the browser again.Testing
Local mutation checks ran
bin/i18n-linton a working copy of the catalogs. The clean run passed. The command rejected a missing Spanish key, a missing plural form, mismatched placeholders, duplicates within and across catalog files, HTML markup, an unused key, and an unknown Stimulus key.Manual browser checks covered language switching, search, editor controls, and keyboard help. Settings was checked in light mode and in dark mode at 482 pixels. Three focused browser specs passed during development. A repeat run hit a ChromeDriver renderer timeout.
A local sample measured the demo plan at a 102 ms median in English and 106 ms in Spanish. The search results frame carried no client translation dictionary.
Added real browser specs for language switching and recovery from a failed update.
Added request and service specs for locale selection, search, and live updates.
Ran 55 focused RSpec examples after rebasing, plus RuboCop and translation lint. The full browser suite is covered by CI.
Checked the Settings layout in light and dark mode.
Attached screenshots in English and Spanish.
Generated with Codex