Move all user-facing text into config/locales/en.yml for localization

- Views use lazy t(".key") lookups; sentences with values or links stay
  whole (interpolation, _html keys); counts use one/other plurals
- Stored-value labels (statuses, types, priorities...) are LabelSets read
  from labels: in the current locale; field names and validation messages
  under activerecord:; flash and activity text under flash:
- Services, models, helpers, mailer subjects, the logbook PDF, procedures
  templates, records package README and transcription warnings localized;
  the PDF reuses LogbookEntry#certification_statement instead of a copy
- Scripts read js: strings from a JSON tag via app/javascript/i18n.js
- Dates through I18n.l (app, weekday, month_year, long formats); html lang
  follows the locale
- APP_LOCALE picks the language (falls back to English); missing
  translations raise in development and tests
- README: Translating section and APP_LOCALE

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-13 22:08:20 -05:00
1 parent 3f45b557c2
commit 89ed0a76f9
313 files changed
+6387 -2653

No files matched your search

+21 -21
View File
@@ -1,39 +1,39 @@
<% content_for :title, "#{@aircraft.tail_number} Import Logbook Pages" %>
<% content_for :title, t(".import_logbook_pages", tail_number: @aircraft.tail_number) %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% ai = LogbookImport.ai_available? %>
<%= form_with url: aircraft_logbook_imports_path(@aircraft), multipart: true, class: "card card-body max-w-3xl space-y-5" do |f| %>
<div>
<h2 class="card-title">Import scanned logbook pages</h2>
<h2 class="card-title"><%= t(".import_scanned_logbook_pages") %></h2>
<p class="hint mt-1">
The pages are saved as a document, in file-name order (name them page-001, page-002…).
<% if ai %>Claude can also read them and add each entry to the logbook for you.<% else %>
To have entries transcribed automatically, set an <code>ANTHROPIC_API_KEY</code> for the app.<% end %>
<%= t(".the_pages_are_saved_as") %>
<% if ai %><%= t(".claude_can_also_read_them") %><% else %>
<%= t(".to_have_entries_transcribed_automatically_html") %><% end %>
</p>
</div>
<div>
<%= f.label :pages, "Scanned pages", class: "label" %>
<%= f.label :pages, t(".scanned_pages"), class: "label" %>
<%= f.file_field :pages, multiple: true, required: true, accept: "image/jpeg,image/png,image/gif,image/webp,application/pdf",
class: "block text-sm text-slate-600 file:mr-3 file:rounded-md file:border-0 file:bg-slate-100 file:px-3 file:py-1.5 file:text-sm file:font-medium hover:file:bg-slate-200" %>
<p class="hint mt-1">JPEG, PNG, WebP or PDF. For transcription, images up to 5 MB each and PDFs up to 30 MB.</p>
<p class="hint mt-1"><%= t(".jpeg_png_webp_or_pdf") %></p>
</div>
<div class="grid gap-4 sm:grid-cols-2">
<div>
<%= f.label :collection_id, "Collection", class: "label" %>
<%= f.select :collection_id, [ [ "New collection…", "new" ] ] + @collections.map { [ _1.name, _1.id ] },
<%= f.label :collection_id, t(".collection"), class: "label" %>
<%= f.select :collection_id, [ [ t(".new_collection"), "new" ] ] + @collections.map { [ _1.name, _1.id ] },
{ selected: params[:collection_id] || @collections.find { _1.name.match?(/log/i) }&.id || "new" }, class: "input" %>
</div>
<div>
<%= f.label :collection_name, "New collection name", class: "label" %>
<%= f.text_field :collection_name, value: params[:collection_name], placeholder: "Airframe Log #2", class: "input" %>
<%= f.label :collection_name, t(".new_collection_name"), class: "label" %>
<%= f.text_field :collection_name, value: params[:collection_name], placeholder: t(".airframe_log_2"), class: "input" %>
</div>
<div>
<%= f.label :document_name, "Document name", class: "label" %>
<%= f.text_field :document_name, value: params[:document_name], placeholder: "Same as the collection", class: "input" %>
<%= f.label :document_name, t(".document_name"), class: "label" %>
<%= f.text_field :document_name, value: params[:document_name], placeholder: t(".same_as_the_collection"), class: "input" %>
</div>
<div>
<%= f.label :doc_type, "Document type", class: "label" %>
<%= f.label :doc_type, t(".document_type"), class: "label" %>
<%= f.select :doc_type, Document::TYPES.invert, { selected: params[:doc_type] || "LOG" }, class: "input" %>
</div>
</div>
@@ -41,18 +41,18 @@
<fieldset class="space-y-3 rounded-md p-3 ring-1 ring-slate-200 <%= 'opacity-60' unless ai %>">
<label class="flex items-start gap-2 text-sm">
<%= f.check_box :transcribe, { checked: ai, disabled: !ai, class: "mt-0.5" }, "1", "0" %>
<span><strong>Transcribe with Claude</strong><br>
<span class="hint">Each entry becomes a logbook entry linked to its page. Handwriting isn't always read perfectly: review the new entries against the scans.</span></span>
<span><%= t(".transcribe_with_claude_html") %>
<span class="hint"><%= t(".each_entry_becomes_a_logbook") %></span></span>
</label>
<div class="max-w-xs">
<%= f.label :log_type, "Log", class: "label" %>
<%= f.select :log_type, [ [ "Detect for each entry", "" ] ] + LogbookEntry::LOG_TYPES.invert.to_a, { selected: params[:log_type] }, class: "input", disabled: !ai %>
<p class="hint mt-1">Pick one when the whole book is a single log (e.g. an engine log).</p>
<%= f.label :log_type, t(".log"), class: "label" %>
<%= f.select :log_type, [ [ t(".detect_for_each_entry"), "" ] ] + LogbookEntry::LOG_TYPES.invert.to_a, { selected: params[:log_type] }, class: "input", disabled: !ai %>
<p class="hint mt-1"><%= t(".pick_one_when_the_whole") %></p>
</div>
</fieldset>
<div class="flex gap-2">
<%= f.submit ai ? "Upload & transcribe" : "Upload pages", class: "btn-primary" %>
<%= link_to "Cancel", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %>
<%= f.submit ai ? t(".upload_transcribe") : t(".upload_pages"), class: "btn-primary" %>
<%= link_to t(".cancel"), aircraft_logbook_entries_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>
+12 -13
View File
@@ -1,44 +1,43 @@
<% content_for :title, "#{@aircraft.tail_number} Logbook Import" %>
<% content_for :title, t(".logbook_import", tail_number: @aircraft.tail_number) %>
<% if @import.in_progress? %><% content_for :head, tag.meta("http-equiv": "refresh", content: "3") %><% end %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<section class="card card-body max-w-3xl space-y-4 text-sm">
<div class="flex flex-wrap items-baseline justify-between gap-2">
<h2 class="card-title"><%= @import.document&.name || "Logbook pages" %></h2>
<span class="text-xs text-slate-500"><%= pluralize(@import.pages_total, "page") %><%= " · read by #{@import.model}" if @import.transcribe && @import.model %></span>
<h2 class="card-title"><%= @import.document&.name || t(".logbook_pages") %></h2>
<span class="text-xs text-slate-500"><%= t("counts.page", count: @import.pages_total) %><%= t(".read_by", model: @import.model) if @import.transcribe && @import.model %></span>
</div>
<% if @import.in_progress? %>
<div>
<div class="mb-1 flex justify-between text-xs text-slate-500">
<span><%= @import.transcribe ? "Claude is reading the pages…" : "Saving pages…" %></span>
<span><%= @import.transcribe ? t(".claude_is_reading_the_pages") : t(".saving_pages") %></span>
<span class="tabular-nums"><%= @import.pages_done %> / <%= @import.pages_total %></span>
</div>
<div class="h-2 overflow-hidden rounded-full bg-slate-200" role="progressbar" aria-valuenow="<%= @import.progress_percent %>" aria-valuemin="0" aria-valuemax="100">
<div class="h-full rounded-full bg-sky-600 transition-all" style="width: <%= @import.progress_percent %>%"></div>
</div>
<p class="hint mt-2"><%= pluralize(@import.entries_created, "entry") %> so far. This page updates by itself; a long logbook can take several minutes.</p>
<p class="hint mt-2"><%= t(".so_far_this_page_updates_html", entry: (t("counts.entry", count: @import.entries_created))) %></p>
</div>
<% elsif @import.done? %>
<p class="font-medium text-emerald-700">
<%= @import.transcribe ? "Done: #{pluralize(@import.entries_created, 'logbook entry')} added." : "Pages saved." %>
<%= @import.transcribe ? t(".done_added", entry: (t("counts.logbook_entry", count: @import.entries_created))) : t(".pages_saved") %>
</p>
<% if @import.transcribe && @import.entries_created.positive? %>
<p class="text-slate-600">The new entries are marked unverified until someone checks them against the scans, since handwriting isn't always read perfectly.
<%= link_to "Check them now", aircraft_logbook_entries_path(@aircraft, unverified: 1), class: "link" %></p>
<p class="text-slate-600"><%= t(".the_new_entries_are_marked_html", link: (link_to t(".check_them_now"), aircraft_logbook_entries_path(@aircraft, unverified: 1), class: "link")) %></p>
<% end %>
<% else %>
<p class="font-medium text-red-700">The import stopped: <%= @import.error %></p>
<% if @import.entries_created.positive? %><p class="text-slate-600"><%= pluralize(@import.entries_created, "entry") %> were added before it stopped.</p><% end %>
<p class="font-medium text-red-700"><%= t(".the_import_stopped_html", error: @import.error) %></p>
<% if @import.entries_created.positive? %><p class="text-slate-600"><%= t(".were_added_before_it_stopped_html", entry: (t("counts.entry", count: @import.entries_created))) %></p><% end %>
<% end %>
<div class="flex flex-wrap gap-2">
<%= link_to "Logbook", aircraft_logbook_entries_path(@aircraft), class: "btn-secondary btn-sm" %>
<% if @import.document %><%= link_to "View scans", aircraft_document_path(@aircraft, @import.document), class: "btn-secondary btn-sm" %><% end %>
<%= link_to t(".logbook"), aircraft_logbook_entries_path(@aircraft), class: "btn-secondary btn-sm" %>
<% if @import.document %><%= link_to t(".view_scans"), aircraft_document_path(@aircraft, @import.document), class: "btn-secondary btn-sm" %><% end %>
</div>
<% if @import.warnings.any? %>
<div class="border-t border-slate-100 pt-3">
<p class="mb-1 text-xs font-semibold text-slate-500"><%= pluralize(@import.warnings.size, "note") %></p>
<p class="mb-1 text-xs font-semibold text-slate-500"><%= t("counts.note", count: @import.warnings.size) %></p>
<ul class="list-disc space-y-0.5 pl-5 text-slate-600"><% @import.warnings.each do |w| %><li><%= w %></li><% end %></ul>
</div>
<% end %>