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

+10 -10
View File
@@ -1,6 +1,6 @@
class Admin::AboutController < ApplicationController
before_action :require_admin!
rate_limit to: 5, within: 1.minute, only: %i[test_email test_reminder check_records], with: -> { redirect_to admin_about_path, alert: "Try again in a minute." }
rate_limit to: 5, within: 1.minute, only: %i[test_email test_reminder check_records], with: -> { redirect_to admin_about_path, alert: t("flash.admin_about.try_again_in_a") }
def show
@info = SystemInfo.new
@@ -11,33 +11,33 @@ class Admin::AboutController < ApplicationController
backup = DatabaseBackup.run!
check = RecordsIntegrity.check!
if backup.ok && check.ok
redirect_to admin_about_path(anchor: "records"), notice: "Backed up and checked: no problems found."
redirect_to admin_about_path(anchor: "records"), notice: t("flash.admin_about.backed_up_and_checked")
else
redirect_to admin_about_path(anchor: "records"), alert: "The records check found problems; see Records below."
redirect_to admin_about_path(anchor: "records"), alert: t("flash.admin_about.the_records_check_found")
end
end
# This week's reminder for the current admin, now.
def test_reminder
return redirect_to(admin_about_path, alert: "Email isn't set up yet.") unless MailSettings.configured?
return redirect_to(admin_about_path, alert: t("flash.admin_about.email_isn_t_set")) unless MailSettings.configured?
unless ReminderMailer.anything_for?(current_user)
return redirect_to admin_about_path, notice: "Nothing needs attention on the aircraft you own or your certificates, so there's no reminder to send."
return redirect_to admin_about_path, notice: t("flash.admin_about.nothing_needs_attention_on")
end
ReminderMailer.weekly(current_user).deliver_now
redirect_to admin_about_path, notice: "Reminder sent to #{current_user.email_address}."
redirect_to admin_about_path, notice: t("flash.admin_about.reminder_sent_to", email_address: current_user.email_address)
rescue StandardError => e
redirect_to admin_about_path, alert: "Sending failed: #{e.class.name.demodulize}: #{e.message.to_s.squish.truncate(240)}"
redirect_to admin_about_path, alert: t("flash.admin_about.sending_failed", error: e.class.name.demodulize, message: e.message.to_s.squish.truncate(240))
end
# Sends right away (not via the job queue) so problems show up here.
def test_email
unless MailSettings.configured?
return redirect_to admin_about_path, alert: "Email isn't set up yet: set SMTP_ADDRESS (and SMTP_PORT, SMTP_USERNAME, SMTP_PASSWORD, MAIL_FROM)."
return redirect_to admin_about_path, alert: t("flash.admin_about.email_isn_t_set_2")
end
AdminMailer.test_email(current_user).deliver_now
redirect_to admin_about_path, notice: "Test email sent to #{current_user.email_address}. If it doesn't arrive, check the spam folder."
redirect_to admin_about_path, notice: t("flash.admin_about.test_email_sent_to", email_address: current_user.email_address)
rescue StandardError => e # SMTP, DNS, TLS and timeout errors alike
Rails.logger.warn("[test email] #{e.class}: #{e.message}")
redirect_to admin_about_path, alert: "Sending failed: #{e.class.name.demodulize}: #{e.message.to_s.squish.truncate(240)}"
redirect_to admin_about_path, alert: t("flash.admin_about.sending_failed_2", error: e.class.name.demodulize, message: e.message.to_s.squish.truncate(240))
end
end
+5 -5
View File
@@ -16,11 +16,11 @@ class Admin::AirportsController < ApplicationController
# Queue a download + sync from OurAirports.
def refresh
if AirportUpdate.in_progress.exists?
redirect_to admin_airports_path, alert: "An update is already running."
redirect_to admin_airports_path, alert: t("flash.admin_airports.an_update_is_already")
else
update = AirportUpdate.create!(source_url: AirportData::SOURCE_URL, requested_by: current_user)
AirportUpdateJob.perform_later(update.id)
redirect_to admin_airports_path, notice: "Airport update started. Refresh this page in a minute or two."
redirect_to admin_airports_path, notice: t("flash.admin_airports.airport_update_started_refresh")
end
end
@@ -31,7 +31,7 @@ class Admin::AirportsController < ApplicationController
def create
@airport = Airport.new(airport_params.merge(custom: true))
if @airport.save
redirect_to admin_airports_path, notice: "Custom airport #{@airport.ident} added."
redirect_to admin_airports_path, notice: t("flash.admin_airports.custom_airport_added", ident: @airport.ident)
else
render :new, status: :unprocessable_entity
end
@@ -41,7 +41,7 @@ class Admin::AirportsController < ApplicationController
def update
if @airport.update(airport_params)
redirect_to admin_airports_path, notice: "#{@airport.ident} updated."
redirect_to admin_airports_path, notice: t("flash.admin_airports.updated", ident: @airport.ident)
else
render :edit, status: :unprocessable_entity
end
@@ -49,7 +49,7 @@ class Admin::AirportsController < ApplicationController
def destroy
@airport.destroy!
redirect_to admin_airports_path, notice: "#{@airport.ident} removed."
redirect_to admin_airports_path, notice: t("flash.admin_airports.removed", ident: @airport.ident)
end
private
+1 -1
View File
@@ -12,7 +12,7 @@ class Admin::AuditsController < ApplicationController
def create
answers = params.fetch(:answers, {}).permit(RecordsAudit::MANUAL.keys.index_with { %i[passed note] }).to_h
run = RecordsAudit.new.record!(user: current_user, answers: answers, notes: params[:notes], sample_ids: Array(params[:sample_ids]).map(&:to_i))
redirect_to admin_audit_path(run), notice: run.passed ? "Audit recorded: everything passed." : "Audit recorded, with items that didn't pass. Note what's being done about them."
redirect_to admin_audit_path(run), notice: run.passed ? t("flash.admin_audits.passed") : t("flash.admin_audits.not_passed")
end
def show
@@ -13,7 +13,7 @@ class Admin::ComponentTypesController < ApplicationController
def create
@component_type = ComponentType.new(type_params)
if @component_type.save
redirect_to admin_component_types_path, notice: "Component type created."
redirect_to admin_component_types_path, notice: t("flash.admin_component_types.component_type_created")
else
render :new, status: :unprocessable_entity
end
@@ -23,7 +23,7 @@ class Admin::ComponentTypesController < ApplicationController
def update
if @component_type.update(type_params)
redirect_to admin_component_types_path, notice: "Component type updated."
redirect_to admin_component_types_path, notice: t("flash.admin_component_types.component_type_updated")
else
render :edit, status: :unprocessable_entity
end
@@ -31,7 +31,7 @@ class Admin::ComponentTypesController < ApplicationController
def destroy
if @component_type.destroy
redirect_to admin_component_types_path, notice: "Component type deleted."
redirect_to admin_component_types_path, notice: t("flash.admin_component_types.component_type_deleted")
else
redirect_to admin_component_types_path, alert: @component_type.errors.full_messages.to_sentence
end
@@ -14,7 +14,7 @@ class Admin::LogbookTemplatesController < ApplicationController
def create
@template = LogbookTemplate.new(template_params)
if @template.save
redirect_to admin_logbook_templates_path, notice: "Template added."
redirect_to admin_logbook_templates_path, notice: t("flash.admin_logbook_templates.template_added")
else
render :new, status: :unprocessable_entity
end
@@ -24,7 +24,7 @@ class Admin::LogbookTemplatesController < ApplicationController
def update
if @template.update(template_params)
redirect_to admin_logbook_templates_path, notice: "Template updated."
redirect_to admin_logbook_templates_path, notice: t("flash.admin_logbook_templates.template_updated")
else
render :edit, status: :unprocessable_entity
end
@@ -32,12 +32,12 @@ class Admin::LogbookTemplatesController < ApplicationController
def destroy
@template.destroy!
redirect_to admin_logbook_templates_path, notice: "Template deleted."
redirect_to admin_logbook_templates_path, notice: t("flash.admin_logbook_templates.template_deleted")
end
def restore
added = LogbookTemplate.restore_defaults!
redirect_to admin_logbook_templates_path, notice: added.positive? ? "Restored #{helpers.pluralize(added, 'built-in template')}." : "All the built-in templates are already here."
redirect_to admin_logbook_templates_path, notice: added.positive? ? t("flash.admin_logbook_templates.restored", count: added) : t("flash.admin_logbook_templates.all_present")
end
private
@@ -16,12 +16,12 @@ class Admin::OffsiteBackupsController < ApplicationController
changed_client = attrs[:client_id].present? && attrs[:client_id].strip != @connection.client_id
@connection.disconnect! if changed_client && @connection.connected?
@connection.update!(attrs.transform_values(&:strip))
redirect_to admin_offsite_backup_path, notice: "Saved. Now connect your Google account."
redirect_to admin_offsite_backup_path, notice: t("flash.admin_offsite_backups.saved_now_connect_your")
end
# Off to Google to grant access (a link, so no form-action CSP entry is needed).
def connect
return redirect_to(admin_offsite_backup_path, alert: "Enter the Google OAuth client ID and secret first.") unless @connection.configured?
return redirect_to(admin_offsite_backup_path, alert: t("flash.admin_offsite_backups.enter_the_google_oauth")) unless @connection.configured?
session[:offsite_oauth_state] = state = SecureRandom.urlsafe_base64(24)
redirect_to GoogleDriveClient.authorize_url(client_id: @connection.client_id, redirect_uri: @connection.redirect_uri, state: state),
allow_other_host: true
@@ -30,9 +30,9 @@ class Admin::OffsiteBackupsController < ApplicationController
def callback
expected = session.delete(:offsite_oauth_state)
unless expected.present? && params[:state].present? && ActiveSupport::SecurityUtils.secure_compare(expected, params[:state].to_s)
return redirect_to(admin_offsite_backup_path, alert: "That Google sign-in didn't match a request from here. Try connecting again.")
return redirect_to(admin_offsite_backup_path, alert: t("flash.admin_offsite_backups.that_google_sign_in"))
end
return redirect_to(admin_offsite_backup_path, alert: "Google Drive wasn't connected (#{params[:error]}).") if params[:error].present? || params[:code].blank?
return redirect_to(admin_offsite_backup_path, alert: t("flash.admin_offsite_backups.google_drive_wasn_t", error: params[:error])) if params[:error].present? || params[:code].blank?
token = GoogleDriveClient.exchange_code(client_id: @connection.client_id, client_secret: @connection.client_secret,
code: params[:code].to_s, redirect_uri: @connection.redirect_uri)
@@ -42,25 +42,25 @@ class Admin::OffsiteBackupsController < ApplicationController
@connection.ensure_folders!(drive)
Rails.logger.info("[offsite] #{current_user.email_address} connected Google Drive #{@connection.account_email}")
OffsiteBackupJob.perform_later
redirect_to admin_offsite_backup_path, notice: "Google Drive connected (#{@connection.account_email}). The first off-site backup has started; it copies every uploaded file, so it can take a while."
redirect_to admin_offsite_backup_path, notice: t("flash.admin_offsite_backups.google_drive_connected_the", account_email: @connection.account_email)
rescue GoogleDriveClient::Error => e
redirect_to admin_offsite_backup_path, alert: "Couldn't connect Google Drive: #{e.message}"
redirect_to admin_offsite_backup_path, alert: t("flash.admin_offsite_backups.couldn_t_connect_google", message: e.message)
end
def destroy
@connection.disconnect!
Rails.logger.info("[offsite] #{current_user.email_address} disconnected Google Drive")
redirect_to admin_offsite_backup_path, notice: "Google Drive disconnected. The copies already there stay in your Drive."
redirect_to admin_offsite_backup_path, notice: t("flash.admin_offsite_backups.google_drive_disconnected_the")
end
def backup_now
OffsiteBackupJob.perform_later
redirect_to admin_offsite_backup_path, notice: "Off-site backup started. Refresh in a minute to see the result."
redirect_to admin_offsite_backup_path, notice: t("flash.admin_offsite_backups.off_site_backup_started")
end
def restore_test
OffsiteBackupJob.perform_later("restore_test")
redirect_to admin_offsite_backup_path, notice: "Restore test started. Refresh in a minute to see the result."
redirect_to admin_offsite_backup_path, notice: t("flash.admin_offsite_backups.restore_test_started_refresh")
end
private
@@ -14,7 +14,7 @@ class Admin::ProceduresController < ApplicationController
if @policy.update(params.require(:recordkeeping_policy).permit(:operator_name, :responsible_name, :responsible_title, :hosting_description,
:offsite_backup_description, :audit_interval_months, :audit_sample_size,
:additional_procedures))
redirect_to admin_procedures_path, notice: "Saved. Review the draft and adopt it as a new revision when it's right."
redirect_to admin_procedures_path, notice: t("flash.admin_procedures.saved_review_the_draft")
else
@revisions = ProceduresRevision.latest_first
render :show, status: :unprocessable_entity
@@ -29,14 +29,14 @@ class Admin::ProceduresController < ApplicationController
def adopt
policy = RecordkeepingPolicy.current
if policy.unfilled_fields.any?
return redirect_to(admin_procedures_path, alert: "Fill in the [bracketed] blanks first: #{policy.unfilled_fields.to_sentence}.")
return redirect_to(admin_procedures_path, alert: t("flash.admin_procedures.fill_in_the_bracketed", items: policy.unfilled_fields.to_sentence))
end
return redirect_to(admin_procedures_path, alert: "Fill in the operator, responsible person, hosting and off-site backup (or connect Google Drive) first.") unless policy.complete?
return redirect_to(admin_procedures_path, alert: t("flash.admin_procedures.fill_in_the_operator")) unless policy.complete?
number = (ProceduresRevision.maximum(:number) || 0) + 1
revision = ProceduresRevision.create!(number: number, adopted_by: current_user, adopted_at: Time.current,
summary: params[:summary].to_s.strip.first(500).presence || "Revision #{number}",
content: draft_html(number: number, summary: params[:summary].to_s.strip.first(500)))
redirect_to admin_procedures_path, notice: "Revision #{revision.number} adopted. Print it or keep the PDF with your records."
redirect_to admin_procedures_path, notice: t("flash.admin_procedures.revision_adopted_print_it", number: revision.number)
end
def revision
@@ -48,7 +48,7 @@ class Admin::ProceduresController < ApplicationController
def draft_html(number: nil, summary: nil)
render_to_string(partial: "admin/procedures/document",
locals: { policy: RecordkeepingPolicy.current, number: number || "#{(ProceduresRevision.maximum(:number) || 0) + 1} (draft)",
locals: { policy: RecordkeepingPolicy.current, number: number || t("flash.admin_procedures.draft_number", number: (ProceduresRevision.maximum(:number) || 0) + 1),
adopted_at: number ? Time.current : nil, adopted_by: number ? current_user : nil,
revisions: ProceduresRevision.latest_first.to_a, summary: summary })
end
+1 -1
View File
@@ -11,7 +11,7 @@ class Admin::SettingsController < ApplicationController
@errors = records.flat_map { _1.errors.full_messages }
if @errors.empty?
Rails.logger.info("[settings] #{current_user.email_address} changed #{submitted.inspect}")
redirect_to edit_admin_settings_path, notice: "Settings saved."
redirect_to edit_admin_settings_path, notice: t("flash.admin_settings.settings_saved")
else
@values = %w[max_upload_mb backups_kept offsite_backups_kept documents_claude_text].index_with { Setting.integer(_1) }.merge(submitted)
render :edit, status: :unprocessable_entity
+11 -11
View File
@@ -14,7 +14,7 @@ class Admin::UsersController < ApplicationController
@user = User.new(user_params)
@user.admin = admin_flag
if @user.save
redirect_to admin_users_path, notice: "User #{@user.email_address} created."
redirect_to admin_users_path, notice: t("flash.admin_users.user_created", email_address: @user.email_address)
else
render :new, status: :unprocessable_entity
end
@@ -26,12 +26,12 @@ class Admin::UsersController < ApplicationController
attrs = user_params
attrs = attrs.except(:password, :password_confirmation) if attrs[:password].blank?
if @user == current_user && !admin_flag
return redirect_to admin_users_path, alert: "You can't remove your own admin rights."
return redirect_to admin_users_path, alert: t("flash.admin_users.you_can_t_remove")
end
@user.admin = admin_flag
if @user.update(attrs)
@user.sessions.where.not(id: Current.session.id).destroy_all if attrs.key?(:password) # new password signs them out
redirect_to admin_users_path, notice: "User updated."
redirect_to admin_users_path, notice: t("flash.admin_users.user_updated")
else
render :edit, status: :unprocessable_entity
end
@@ -41,7 +41,7 @@ class Admin::UsersController < ApplicationController
# keeping their account, so the signatures they made stay attributed.
def unlock
@user.unlock!
redirect_to admin_users_path, notice: "#{@user.email_address} unlocked."
redirect_to admin_users_path, notice: t("flash.admin_users.unlocked", email_address: @user.email_address)
end
# For a user who lost their authenticator: they sign in with their password
@@ -49,28 +49,28 @@ class Admin::UsersController < ApplicationController
def reset_two_factor
@user.disable_otp!
Rails.logger.info("[auth] #{current_user.email_address} turned off two-factor for #{@user.email_address}")
redirect_to admin_users_path, notice: "Two-factor turned off for #{@user.email_address}. Ask them to set it up again from their profile."
redirect_to admin_users_path, notice: t("flash.admin_users.two_factor_turned_off", email_address: @user.email_address)
end
def disable
return redirect_to admin_users_path, alert: "You can't disable yourself." if @user == current_user
return redirect_to admin_users_path, alert: t("flash.admin_users.you_can_t_disable") if @user == current_user
@user.update!(disabled_at: Time.current)
@user.sessions.destroy_all
redirect_to admin_users_path, notice: "#{@user.email_address} disabled: signed out, can't sign in or sign entries. Their past signatures are kept."
redirect_to admin_users_path, notice: t("flash.admin_users.disabled_signed_out_can", email_address: @user.email_address)
end
def enable
@user.update!(disabled_at: nil)
redirect_to admin_users_path, notice: "#{@user.email_address} enabled."
redirect_to admin_users_path, notice: t("flash.admin_users.enabled", email_address: @user.email_address)
end
def destroy
return redirect_to admin_users_path, alert: "You can't delete yourself." if @user == current_user
return redirect_to admin_users_path, alert: t("flash.admin_users.you_can_t_delete") if @user == current_user
if @user.entry_signatures.exists?
return redirect_to admin_users_path, alert: "#{@user.email_address} has signed logbook entries; disable the account instead of deleting it."
return redirect_to admin_users_path, alert: t("flash.admin_users.has_signed_logbook_entries", email_address: @user.email_address)
end
@user.destroy!
redirect_to admin_users_path, notice: "User deleted."
redirect_to admin_users_path, notice: t("flash.admin_users.user_deleted")
end
private