mirror of
https://github.com/rickbarrette/simple-aircraft-manager-rails.git
synced 2026-11-17 23:50:36 -05:00
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:
1 parent
3f45b557c2
commit
89ed0a76f9
313 files changed
+6387
-2653
No files matched your search
@@ -1,13 +1,13 @@
|
||||
<li class="flex items-center justify-between gap-3 px-4 py-2">
|
||||
<div>
|
||||
<%= link_to doc.name, aircraft_document_path(aircraft, doc), class: "link font-medium" %>
|
||||
<span class="ml-2 text-xs text-slate-500"><%= doc.type_label %> · <%= pluralize(doc.pages.size, "file") %></span>
|
||||
<% if doc.legacy_record? %><span class="ml-1 badge-gray" title="Scan of the paper (legacy) records">Legacy record</span><% end %>
|
||||
<% if doc.expires_on %><span class="ml-1 <%= doc.expired? ? 'badge-red' : (Date.current + doc.expiry_warning_days >= doc.expires_on ? 'badge-orange' : 'badge-gray') %>"><%= doc.expired? ? "Expired" : "Expires" %> <%= fmt_date(doc.expires_on) %></span><% end %>
|
||||
<span class="ml-2 text-xs text-slate-500"><%= doc.type_label %> · <%= t("counts.file", count: doc.pages.size) %></span>
|
||||
<% if doc.legacy_record? %><span class="ml-1 badge-gray" title="<%= t(".scan_of_the_paper_legacy") %>"><%= t(".legacy_record") %></span><% end %>
|
||||
<% if doc.expires_on %><span class="ml-1 <%= doc.expired? ? 'badge-red' : (Date.current + doc.expiry_warning_days >= doc.expires_on ? 'badge-orange' : 'badge-gray') %>"><%= doc.expired? ? t(".expired") : t(".expires") %> <%= fmt_date(doc.expires_on) %></span><% end %>
|
||||
<% if doc.description.present? %><div class="text-xs text-slate-500"><%= doc.description.truncate(120) %></div><% end %>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<%= visibility_badge(doc.effective_visibility) %>
|
||||
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(aircraft, doc), class: "btn-secondary btn-sm" %><% end %>
|
||||
<% if owner? %><%= link_to t(".edit"), edit_aircraft_document_path(aircraft, doc), class: "btn-secondary btn-sm" %><% end %>
|
||||
</div>
|
||||
</li>
|
||||
@@ -2,30 +2,30 @@
|
||||
<%= f.errors_summary %>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<%= f.field :name, required: true %>
|
||||
<%= f.field :doc_type, as: :select, label: "Type", collection: Document::TYPES.invert %>
|
||||
<%= f.field :document_collection_id, as: :select, label: "Collection",
|
||||
collection: [["— None —", nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
|
||||
<%= f.field :visibility, as: :select, label: "Share-link visibility",
|
||||
collection: [["Inherit from collection", nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
|
||||
<%= f.field :doc_type, as: :select, label: t(".type"), collection: Document::TYPES.invert %>
|
||||
<%= f.field :document_collection_id, as: :select, label: t(".collection"),
|
||||
collection: [[t(".none"), nil]] + aircraft.document_collections.ordered.map { [_1.name, _1.id] } %>
|
||||
<%= f.field :visibility, as: :select, label: t(".share_link_visibility"),
|
||||
collection: [[t(".inherit_from_collection"), nil]] + DocumentCollection::VISIBILITIES.invert.to_a %>
|
||||
</div>
|
||||
<%= f.field :legacy_record, as: :checkbox, label: "Legacy record (a scan of the paper logbooks or records)",
|
||||
hint: "Records from before the electronic records began. Keep the paper originals." %>
|
||||
<%= f.field :expires_on, as: :date, label: "Expires on", wrapper: { class: "max-w-xs" },
|
||||
hint: "Optional. Registration (good for 7 years, 14 CFR 47.40), insurance, radio license… You'll be reminded before it expires; an expired registration shows the aircraft grounded." %>
|
||||
<%= f.field :legacy_record, as: :checkbox, label: t(".legacy_record_a_scan_of"),
|
||||
hint: t(".records_from_before_the_electronic") %>
|
||||
<%= f.field :expires_on, as: :date, label: t(".expires_on"), wrapper: { class: "max-w-xs" },
|
||||
hint: t(".optional_registration_good_for_7") %>
|
||||
<%= f.field :description, as: :textarea, rows: 2 %>
|
||||
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? "Add files" : "Files",
|
||||
hint: "Images, PDFs or text, up to #{Setting.max_upload_mb} MB each. Each file is a page in the viewer, in upload order." %>
|
||||
<%= f.field :pages, as: :file, multiple: true, label: document.persisted? ? t(".add_files") : t(".files"),
|
||||
hint: t(".images_pdfs_or_text_up", max_upload_mb: Setting.max_upload_mb) %>
|
||||
<% if document.persisted? && document.pages.any? %>
|
||||
<div>
|
||||
<p class="label">Remove existing files</p>
|
||||
<p class="label"><%= t(".remove_existing_files") %></p>
|
||||
<% document.pages.each do |p| %>
|
||||
<label class="flex items-center gap-2 text-sm"><%= check_box_tag "remove_page_ids[]", p.id, false %> <%= p.filename %></label>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% unless document.persisted? %>
|
||||
<p class="text-sm text-slate-500">Lots of files? <%= link_to "Bulk upload", new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link" %> makes a document from each one.</p>
|
||||
<p class="text-sm text-slate-500"><%= t(".lots_of_files_makes_a_html", link: (link_to t(".bulk_upload"), new_bulk_aircraft_documents_path(aircraft, collection_id: document.document_collection_id), class: "link")) %></p>
|
||||
<% end %>
|
||||
<div class="flex gap-2"><%= f.submit "Save Document" %><%= link_to "Cancel", aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
|
||||
<div class="flex gap-2"><%= f.submit t(".save_document") %><%= link_to t(".cancel"), aircraft_documents_path(aircraft), class: "btn-secondary" %></div>
|
||||
<% end %>
|
||||
<% if document.persisted? %><div class="mt-4"><%= delete_button "Delete document", aircraft_document_path(aircraft, document) %></div><% end %>
|
||||
<% if document.persisted? %><div class="mt-4"><%= delete_button t(".delete_document"), aircraft_document_path(aircraft, document) %></div><% end %>
|
||||
@@ -1,13 +1,13 @@
|
||||
<%# Multi-page viewer: one attachment per "page", with prev/next. %>
|
||||
<% pages = document.pages.to_a %>
|
||||
<% if pages.empty? %>
|
||||
<%= empty_state "No files uploaded." %>
|
||||
<%= empty_state t(".no_files_uploaded") %>
|
||||
<% else %>
|
||||
<% current = pages[page - 1] %>
|
||||
<div class="mb-3 flex items-center justify-between text-sm">
|
||||
<%= link_to "← Prev", url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
|
||||
<span>Page <%= page %> of <%= pages.size %> · <%= link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link" %></span>
|
||||
<%= link_to "Next →", url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
|
||||
<%= link_to t(".prev"), url_for(page: page - 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page <= 1)] %>
|
||||
<span><%= t(".page_of_html", page: page, pages: pages.size, link: (link_to current.filename, rails_blob_path(current, disposition: :attachment), class: "link")) %></span>
|
||||
<%= link_to t(".next"), url_for(page: page + 1), class: ["btn-secondary btn-sm", ("pointer-events-none opacity-40" if page >= pages.size)] %>
|
||||
</div>
|
||||
<div class="flex justify-center rounded bg-slate-50 p-2">
|
||||
<% if current.image? %>
|
||||
@@ -15,7 +15,7 @@
|
||||
<% elsif current.content_type == "application/pdf" %>
|
||||
<iframe src="<%= rails_blob_path(current, disposition: :inline) %>" class="h-[80vh] w-full"></iframe>
|
||||
<% else %>
|
||||
<p class="p-6 text-sm"><%= link_to "Download #{current.filename}", rails_blob_path(current, disposition: :attachment), class: "link" %></p>
|
||||
<p class="p-6 text-sm"><%= link_to t(".download", filename: current.filename), rails_blob_path(current, disposition: :attachment), class: "link" %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,12 +1,12 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Bulk Upload" %>
|
||||
<% content_for :title, t(".bulk_upload", tail_number: @aircraft.tail_number) %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<% file_classes = "block w-full 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" %>
|
||||
<%= form_with url: bulk_aircraft_documents_path(@aircraft), multipart: true, class: "card card-body max-w-3xl space-y-4",
|
||||
data: { controller: "bulk-upload", bulk_upload_url_value: rails_direct_uploads_path,
|
||||
bulk_upload_max_bytes_value: UploadValidation.max_size, action: "submit->bulk-upload#submit" } do %>
|
||||
<div>
|
||||
<h2 class="card-title">Bulk upload</h2>
|
||||
<p class="text-sm text-slate-500">Each file becomes its own document, named after the file. Give files the same name to combine them, in order, as the pages of one document.</p>
|
||||
<h2 class="card-title"><%= t(".bulk_upload_2") %></h2>
|
||||
<p class="text-sm text-slate-500"><%= t(".each_file_becomes_its_own") %></p>
|
||||
</div>
|
||||
<% if @bulk_error %>
|
||||
<div class="rounded-md bg-red-50 p-3 text-sm text-red-700 ring-1 ring-red-200" role="alert"><%= @bulk_error %></div>
|
||||
@@ -14,37 +14,37 @@
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<%= label_tag :doc_type, "Type", class: "label" %>
|
||||
<%= label_tag :doc_type, t(".type"), class: "label" %>
|
||||
<%= select_tag :doc_type, options_for_select(Document::TYPES.invert, @bulk[:doc_type]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :visibility, "Share-link visibility", class: "label" %>
|
||||
<%= select_tag :visibility, options_for_select([ [ "Inherit from collection", "" ] ] + DocumentCollection::VISIBILITIES.invert.to_a, @bulk[:visibility]), class: "input" %>
|
||||
<%= label_tag :visibility, t(".share_link_visibility"), class: "label" %>
|
||||
<%= select_tag :visibility, options_for_select([ [ t(".inherit_from_collection"), "" ] ] + DocumentCollection::VISIBILITIES.invert.to_a, @bulk[:visibility]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :document_collection_id, "Collection", class: "label" %>
|
||||
<%= label_tag :document_collection_id, t(".collection"), class: "label" %>
|
||||
<%= select_tag :document_collection_id,
|
||||
options_for_select([ [ "— None —", "" ] ] + @aircraft.document_collections.ordered.map { [ _1.name, _1.id ] }, @bulk[:document_collection_id]), class: "input" %>
|
||||
options_for_select([ [ t(".none"), "" ] ] + @aircraft.document_collections.ordered.map { [ _1.name, _1.id ] }, @bulk[:document_collection_id]), class: "input" %>
|
||||
</div>
|
||||
<div>
|
||||
<%= label_tag :new_collection, "…or a new collection", class: "label" %>
|
||||
<%= text_field_tag :new_collection, @bulk[:new_collection], class: "input", placeholder: "e.g. 2025 Annual" %>
|
||||
<%= label_tag :new_collection, t(".or_a_new_collection"), class: "label" %>
|
||||
<%= text_field_tag :new_collection, @bulk[:new_collection], class: "input", placeholder: t(".e_g_2025_annual") %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div>
|
||||
<%= label_tag :files, "Files", class: "label" %>
|
||||
<%= label_tag :files, t(".files"), class: "label" %>
|
||||
<%= file_field_tag "files[]", id: "files", multiple: true, class: file_classes,
|
||||
data: { bulk_upload_target: "input", action: "change->bulk-upload#add" } %>
|
||||
</div>
|
||||
<div data-bulk-upload-target="folderField" hidden>
|
||||
<%= label_tag :folder, "…or a whole folder", class: "label" %>
|
||||
<%= label_tag :folder, t(".or_a_whole_folder"), class: "label" %>
|
||||
<input type="file" id="folder" webkitdirectory multiple class="<%= file_classes %>"
|
||||
data-bulk-upload-target="folder" data-action="change->bulk-upload#add">
|
||||
</div>
|
||||
</div>
|
||||
<p class="hint !mt-1">Images, PDFs or text, up to <%= Setting.max_upload_mb %> MB each and <%= DocumentsController::MAX_BULK_FILES %> at a time.</p>
|
||||
<p class="hint !mt-1"><%= t(".images_pdfs_or_text_up_html", max_upload_mb: Setting.max_upload_mb, max_files: (DocumentsController::MAX_BULK_FILES)) %></p>
|
||||
|
||||
<div data-bulk-upload-target="panel" hidden class="space-y-2">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2">
|
||||
@@ -52,17 +52,17 @@
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<label class="flex items-center gap-2 text-sm text-slate-700" data-bulk-upload-target="groupField" hidden>
|
||||
<input type="checkbox" class="h-4 w-4 rounded border-slate-300" data-bulk-upload-target="group" data-action="bulk-upload#regroup">
|
||||
One document per folder
|
||||
<%= t(".one_document_per_folder") %>
|
||||
</label>
|
||||
<button type="button" class="btn-secondary btn-sm" data-action="bulk-upload#clear">Clear</button>
|
||||
<button type="button" class="btn-secondary btn-sm" data-action="bulk-upload#clear"><%= t(".clear") %></button>
|
||||
</div>
|
||||
</div>
|
||||
<ul class="divide-y divide-slate-100 rounded-md ring-1 ring-slate-200" data-bulk-upload-target="list"></ul>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<button type="submit" class="btn-primary" data-bulk-upload-target="submit">Upload</button>
|
||||
<%= link_to "Cancel", aircraft_documents_path(@aircraft), class: "btn-secondary" %>
|
||||
<button type="submit" class="btn-primary" data-bulk-upload-target="submit"><%= t(".upload") %></button>
|
||||
<%= link_to t(".cancel"), aircraft_documents_path(@aircraft), class: "btn-secondary" %>
|
||||
<p class="text-sm text-slate-500" data-bulk-upload-target="status" role="status"></p>
|
||||
</div>
|
||||
<% end %>
|
||||
@@ -1,16 +1,16 @@
|
||||
<% content_for :title, "#{@aircraft.tail_number} Documents" %>
|
||||
<% content_for :title, t(".documents", tail_number: @aircraft.tail_number) %>
|
||||
<%= render "shared/aircraft_header", aircraft: @aircraft %>
|
||||
<div class="mb-4 flex flex-wrap justify-end gap-2">
|
||||
<% if owner? %>
|
||||
<%= more_menu do %>
|
||||
<%= link_to "Upload several files", new_bulk_aircraft_documents_path(@aircraft), class: "menu-item" %>
|
||||
<%= link_to "New collection", new_aircraft_document_collection_path(@aircraft), class: "menu-item" %>
|
||||
<%= link_to t(".upload_several_files"), new_bulk_aircraft_documents_path(@aircraft), class: "menu-item" %>
|
||||
<%= link_to t(".new_collection"), new_aircraft_document_collection_path(@aircraft), class: "menu-item" %>
|
||||
<% end %>
|
||||
<%= link_to "+ Upload Document", new_aircraft_document_path(@aircraft), class: "btn-primary" %>
|
||||
<%= link_to t(".upload_document"), new_aircraft_document_path(@aircraft), class: "btn-primary" %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if @collections.empty? && @uncollected.empty? %>
|
||||
<div class="card"><%= empty_state "No documents yet. Upload logbook scans, 337s, weight & balance, receipts…" %></div>
|
||||
<div class="card"><%= empty_state t(".no_documents_yet_upload_logbook") %></div>
|
||||
<% end %>
|
||||
<div class="space-y-5">
|
||||
<% @collections.each do |col| %>
|
||||
@@ -26,14 +26,14 @@
|
||||
<div class="flex items-center gap-2">
|
||||
<%= visibility_badge(col.visibility) %>
|
||||
<% if owner? %>
|
||||
<%= link_to "+ Document", new_aircraft_document_path(@aircraft, collection_id: col.id), class: "btn-secondary btn-sm" %>
|
||||
<%= link_to "Edit", edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
|
||||
<%= link_to t(".document"), new_aircraft_document_path(@aircraft, collection_id: col.id), class: "btn-secondary btn-sm" %>
|
||||
<%= link_to t(".edit"), edit_aircraft_document_collection_path(@aircraft, col), class: "btn-secondary btn-sm" %>
|
||||
<% end %>
|
||||
</div>
|
||||
</summary>
|
||||
<% if col.documents.any? %>
|
||||
<ul class="divide-y divide-slate-100"><% col.documents.sort_by(&:name).each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
|
||||
<% else %><%= empty_state "Empty collection." %><% end %>
|
||||
<% else %><%= empty_state t(".empty_collection") %><% end %>
|
||||
</details>
|
||||
<% end %>
|
||||
<% if @uncollected.any? %>
|
||||
@@ -41,7 +41,7 @@
|
||||
<summary class="card-header cursor-pointer list-none border-b-0 group-open:border-b [&::-webkit-details-marker]:hidden">
|
||||
<div class="flex items-start gap-2">
|
||||
<span aria-hidden="true" class="mt-0.5 text-slate-400 transition group-open:rotate-90">›</span>
|
||||
<h2 class="card-title">Uncollected <span class="text-sm font-normal text-slate-500">(<%= @uncollected.size %>)</span></h2>
|
||||
<h2 class="card-title"><%= t(".uncollected") %> <span class="text-sm font-normal text-slate-500">(<%= @uncollected.size %>)</span></h2>
|
||||
</div>
|
||||
</summary>
|
||||
<ul class="divide-y divide-slate-100"><% @uncollected.each do |doc| %><%= render "documents/doc_row", doc: doc, aircraft: @aircraft %><% end %></ul>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<%= visibility_badge(@document.effective_visibility) %>
|
||||
<% if owner? %><%= link_to "Edit", edit_aircraft_document_path(@aircraft, @document), class: "btn-secondary btn-sm" %><% end %>
|
||||
<% if owner? %><%= link_to t(".edit"), edit_aircraft_document_path(@aircraft, @document), class: "btn-secondary btn-sm" %><% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
Reference in new issue
Block a user