Files
simple-aircraft-manager-rails/app/views/airport_codes/show.html.erb
T
rickyandClaude Opus 5.5 89ed0a76f9 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>
2026-11-13 22:08:20 -05:00

66 lines
4.3 KiB
ERB

<% content_for :title, t(".standardize_airport_codes") %>
<%= render "shared/aircraft_header", aircraft: @aircraft %>
<% changes = @standardizer.changes %>
<%= form_with url: aircraft_airport_codes_path(@aircraft), method: :patch, class: "space-y-5" do |f| %>
<section class="card">
<div class="card-header">
<h2 class="card-title"><%= t(".standardize_airport_codes") %></h2>
<span class="text-xs text-slate-500"><%= t(".to_update_entries_html", code: (t("counts.code", count: changes.size)), flights: (changes.sum(&:flights))) %></span>
</div>
<div class="card-body text-sm text-slate-600">
<%= t(".rewrites_the_airport_codes_in_html", tail_number: @aircraft.tail_number) %>
</div>
<% if changes.any? %>
<table class="table">
<thead><tr><th class="w-8"><input type="checkbox" checked aria-label="<%= t(".select_all") %>" data-check-all></th><th><%= t(".logged") %></th><th><%= t(".standard") %></th><th><%= t(".airport") %></th><th class="text-right"><%= t(".entries") %></th></tr></thead>
<tbody>
<% changes.each do |c| %>
<tr>
<td><%= check_box_tag "codes[]", c.from, c.suggested, id: "code_#{c.from.parameterize}" %></td>
<td class="font-mono"><%= label_tag "code_#{c.from.parameterize}", c.from %></td>
<td class="font-mono font-semibold"><%= c.to %></td>
<td><%= c.airport.name %> <span class="text-xs text-slate-500"><%= c.airport.place %></span>
<% if c.note %><div class="text-xs text-amber-700"><%= c.note %></div><% end %></td>
<td class="text-right tabular-nums"><%= c.flights %></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<%= empty_state t(".all_logged_codes_already_match") %>
<% end %>
</section>
<% if @standardizer.unknown.any? %>
<section class="card">
<div class="card-header"><h2 class="card-title"><%= t(".not_in_the_airport_database") %></h2></div>
<div class="card-body space-y-3 text-sm">
<p class="text-slate-600"><%= t(".often_a_typo_tick_fix") %><% if current_user.admin? %> <%= t(".for_a_private_strip_that_html", link: (link_to t(".custom_airport"), admin_airports_path, class: "link")) %><% end %></p>
<% @standardizer.unknown.each do |u| %>
<div class="flex flex-wrap items-start gap-3">
<label class="mt-2 flex items-center gap-2"><%= t(".fix_html", checkbox: (check_box_tag "fix[]", u.code, u.suggestion.present?, id: "fix_#{u.code.parameterize}")) %></label>
<div class="mt-2 w-16 font-mono"><%= u.code %></div>
<div class="mt-2 text-xs text-slate-500"><%= t("counts.entry", count: u.flights) %> →</div>
<div class="relative w-72" data-controller="airport-autocomplete"
data-airport-autocomplete-url-value="<%= airport_search_path(aircraft_id: @aircraft.id) %>">
<%= text_field_tag "fixes[#{u.code}]", u.suggestion&.code, class: "input font-mono uppercase placeholder:normal-case placeholder:font-sans",
placeholder: t(".airport_code_or_name"), "aria-label": t(".airport_for", code: u.code),
data: { airport_autocomplete_target: "input",
action: "input->airport-autocomplete#search keydown->airport-autocomplete#keydown blur->airport-autocomplete#blur" } %>
<ul data-airport-autocomplete-target="list" role="listbox" hidden
class="absolute z-20 mt-1 max-h-72 w-[min(28rem,90vw)] overflow-auto rounded-md bg-surface py-1 shadow-lg ring-1 ring-slate-200"></ul>
<p class="hint min-h-4" data-airport-autocomplete-target="hint"></p>
</div>
<% if u.suggestion %><div class="mt-2 text-xs text-sky-800"><%= t(".suggested_letters_swapped_html", suggestion: u.suggestion.name, location: u.suggestion.place) %></div><% end %>
</div>
<% end %>
</div>
</section>
<% end %>
<div class="flex gap-2">
<% if changes.any? || @standardizer.unknown.any? %><%= f.submit t(".update_selected_codes"), class: "btn-primary", data: { turbo_confirm: t(".rewrite_the_selected_airport_codes", tail_number: @aircraft.tail_number) } %><% end %>
<%= link_to t(".back_to_flights"), aircraft_flight_logs_path(@aircraft), class: "btn-secondary" %>
</div>
<% end %>