Files
sure/app/views/settings/api_keys/show.html.erb
Brendon Scheiber 0c126b1674 feat(i18n): extract hardcoded English strings to locale files (#1806)
* Extract hardcoded strings to i18n

Replace numerous hardcoded English strings with I18n lookups (t / I18n.t) across controllers, views, helpers, and components, and convert model validation error messages to symbol keys. Added multiple locale files under config/locales for models and views. This centralizes user-facing notices/alerts, UI text, import/validation messages, and prepares the app for localization and easier translation maintenance.

* Update en.yml

* Update preview-cleanup.yml

* Revert "Update preview-cleanup.yml"

This reverts commit 1ba6d3c34c.

* test: align i18n assertions with translated messages

* Standardize balance error key and tweak locales

Replace SophtronAccount's :requires_balance error key with :no_balance and update related locale strings for sophtron, plaid, and simplefin accounts to use the new key and clearer copy. Also switch the QIF upload redirect notice to use a relative translation key (t('.qif_uploaded')), remove an unused SSO providers help line, and fix a trailing-newline/whitespace issue in the subscriptions locale. These changes standardize validation keys and improve translation consistency and messaging.

---------

Co-authored-by: KiloClaw <kiloclaw@openclaw.ai>
2026-05-17 09:52:49 +02:00

198 lines
8.1 KiB
Plaintext

<% if @newly_created && @plain_key %>
<%= content_for :page_title, t(".newly_created.page_title") %>
<div class="bg-container rounded-xl shadow-border-xs p-4">
<div class="space-y-4">
<div class="p-3 shadow-border-xs bg-container rounded-lg">
<div class="flex items-start gap-3">
<%= render DS::FilledIcon.new(
icon: "check-circle",
rounded: true,
size: "lg",
variant: :success
) %>
<div class="flex-1">
<h3 class="font-medium text-primary"><%= t(".newly_created.heading") %></h3>
<p class="text-secondary text-sm mt-1"><%= t(".newly_created.key_ready", name: @current_api_key.name) %></p>
</div>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".newly_created.your_api_key") %></h4>
<p class="text-secondary text-sm mb-3"><%= t(".newly_created.copy_store_securely") %></p>
<div class="bg-container rounded-lg p-3 border border-primary" data-controller="clipboard">
<div class="flex items-center justify-between gap-3">
<code id="api-key-display" class="font-mono text-sm text-primary break-all" data-clipboard-target="source"><%= @current_api_key.plain_key %></code>
<%= render DS::Button.new(
text: t(".newly_created.copy_api_key"),
variant: "ghost",
icon: "copy",
data: { action: "clipboard#copy" }
) %>
</div>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".newly_created.how_to_use") %></h4>
<p class="text-secondary text-sm mb-3"><%= t(".current_api_key.usage_instructions", product_name: product_name) %></p>
<div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary">
curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts
</div>
</div>
<div class="flex justify-end pt-4 border-t border-primary">
<%= render DS::Link.new(
text: t(".newly_created.continue"),
href: settings_api_key_path,
variant: "primary"
) %>
</div>
</div>
</div>
<% elsif @current_api_key %>
<%= content_for :page_title, t(".current_api_key.title") %>
<%= content_for :page_actions do %>
<%= render DS::Link.new(
text: t(".current_api_key.regenerate_key"),
href: new_settings_api_key_path(regenerate: true),
variant: "secondary"
) %>
<% end %>
<div class="bg-container rounded-xl shadow-border-xs p-4">
<div class="space-y-4">
<div class="p-3 shadow-border-xs bg-container rounded-lg flex justify-between items-center">
<div class="flex items-center gap-3">
<%= render DS::FilledIcon.new(
icon: "key",
rounded: true,
size: "lg"
) %>
<div class="text-sm space-y-1">
<p class="text-primary font-medium"><%= @current_api_key.name %></p>
<p class="text-secondary">
<%= t(".current_api_key.created_ago", time: time_ago_in_words(@current_api_key.created_at)) %>
<% if @current_api_key.last_used_at %>
• <%= t(".current_api_key.last_used_ago", time: time_ago_in_words(@current_api_key.last_used_at)) %>
<% else %>
• <%= t(".current_api_key.never_used") %>
<% end %>
</p>
</div>
</div>
<div class="rounded-md bg-success px-2 py-1">
<p class="text-success-foreground font-medium text-xs"><%= t(".current_api_key.active") %></p>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".current_api_key.permissions") %></h4>
<div class="flex flex-wrap gap-2">
<% @current_api_key.scopes.each do |scope| %>
<span class="inline-flex items-center gap-1 px-2 py-1 button-bg-primary text-inverse rounded-full text-xs font-medium">
<%= icon("shield-check", class: "w-3 h-3") %>
<%= case scope
when "read" then t(".current_api_key.scope_read_only")
when "read_write" then t(".current_api_key.scope_read_write")
else scope.humanize
end %>
</span>
<% end %>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".current_api_key.title") %></h4>
<p class="text-secondary text-sm mb-3"><%= t(".current_api_key.copy_store_securely") %></p>
<div class="bg-container rounded-lg p-3 border border-primary" data-controller="clipboard">
<div class="flex items-center justify-between gap-3">
<code id="api-key-display" class="font-mono text-sm text-primary break-all" data-clipboard-target="source"><%= @current_api_key.plain_key %></code>
<%= render DS::Button.new(
text: t(".current_api_key.copy_api_key"),
variant: "ghost",
icon: "copy",
data: { action: "clipboard#copy" }
) %>
</div>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".current_api_key.usage_instructions_title") %></h4>
<p class="text-secondary text-sm mb-3"><%= t(".current_api_key.usage_instructions", product_name: product_name) %></p>
<div class="bg-container rounded-lg p-3 font-mono text-sm text-primary border border-primary">
curl -H "X-Api-Key: <%= @current_api_key.plain_key %>" <%= request.base_url %>/api/v1/accounts
</div>
</div>
<div class="flex justify-end pt-4 border-t border-primary">
<%= render DS::Button.new(
text: t(".current_api_key.revoke_key"),
href: settings_api_key_path,
method: :delete,
variant: "destructive",
data: {
turbo_confirm: t(".current_api_key.revoke_confirmation")
}
) %>
</div>
</div>
</div>
<% else %>
<%= content_for :page_title, t(".no_api_key.title") %>
<%= content_for :page_actions do %>
<%= render DS::Link.new(
text: t(".no_api_key.create_api_key"),
href: new_settings_api_key_path,
variant: "primary"
) %>
<% end %>
<div class="bg-container rounded-xl shadow-border-xs p-4">
<div class="space-y-4">
<div class="p-3 shadow-border-xs bg-container rounded-lg">
<div class="flex items-start gap-3">
<%= render DS::FilledIcon.new(
icon: "key",
rounded: true,
size: "lg"
) %>
<div class="flex-1">
<h3 class="font-medium text-primary"><%= t(".no_api_key.heading", product_name: product_name) %></h3>
<p class="text-secondary text-sm mt-1"><%= t(".no_api_key.description") %></p>
</div>
</div>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-3"><%= t(".no_api_key.what_you_can_do") %></h4>
<ul class="space-y-2 text-sm text-secondary">
<li class="flex items-start gap-2">
<%= icon("check", class: "w-4 h-4 text-primary mt-0.5") %>
<span><%= t(".no_api_key.feature_1") %></span>
</li>
<li class="flex items-start gap-2">
<%= icon("check", class: "w-4 h-4 text-primary mt-0.5") %>
<span><%= t(".no_api_key.feature_2") %></span>
</li>
<li class="flex items-start gap-2">
<%= icon("check", class: "w-4 h-4 text-primary mt-0.5") %>
<span><%= t(".no_api_key.feature_3") %></span>
</li>
</ul>
</div>
<div class="bg-surface-inset rounded-xl p-4">
<h4 class="font-medium text-primary mb-2"><%= t(".no_api_key.security_note_title") %></h4>
<p class="text-secondary text-sm"><%= t(".no_api_key.security_note") %></p>
</div>
</div>
</div>
<% end %>