Files
sure/app/views/rules/_rule.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

82 lines
3.6 KiB
Plaintext

<%# locals: (rule:) %>
<div id="<%= dom_id(rule) %>" class="flex justify-between items-center p-4 <%= rule.active? ? "text-primary" : "text-secondary" %>">
<div class="text-sm space-y-1.5">
<% if rule.name.present? %>
<h3 class="font-medium text-md"><%= rule.name %></h3>
<% end %>
<% if rule.conditions.any? %>
<% displayed_condition = rule.displayed_condition %>
<% additional_condition_count = rule.additional_displayable_conditions_count %>
<div class="flex items-center gap-2 mt-1">
<div class="flex items-center gap-1 text-secondary w-16 shrink-0">
<span class="font-mono text-xs">IF</span>
</div>
<p class="flex items-center flex-wrap gap-1.5 m-0">
<span class="px-2 py-1 border border-secondary rounded-full">
<% if displayed_condition.present? %>
<%= displayed_condition.filter.label %> <%= displayed_condition.operator %> <%= displayed_condition.value_display %>
<% else %>
<%= t("rules.no_condition") %>
<% end %>
</span>
<% if additional_condition_count.positive? %>
<%= t(".and_more_conditions", count: additional_condition_count) %>
<% end %>
</p>
</div>
<% end %>
<div class="flex items-center gap-2 mt-1">
<div class="flex items-center gap-1 text-secondary w-16 shrink-0">
<span class="font-mono text-xs"><%= t(".then") %></span>
</div>
<p class="flex items-center flex-wrap gap-1.5 m-0">
<span class="px-2 py-1 border border-secondary rounded-full">
<% if rule.actions.first.nil? %>
<%= t("rules.no_action") %>
<% else %>
<% if rule.actions.first.value && rule.actions.first.options %>
<%= t(".action_label_to", label: rule.actions.first.executor.label, value: rule.actions.first.value_display) %>
<% else %>
<%= rule.actions.first.executor.label %>
<% end %>
<% end %>
</span>
<% if rule.actions.count > 1 %>
<%= t(".and_more_actions", count: rule.actions.count - 1) %>
<% end %>
</p>
</div>
<div class="flex items-center gap-2 mt-1">
<div class="flex items-center gap-1 text-secondary w-16 shrink-0">
<span class="font-mono text-xs">FOR</span>
</div>
<p class="flex items-center flex-wrap gap-1.5 m-0">
<span class="px-2 py-1 border border-secondary rounded-full">
<% if rule.effective_date.nil? %>
<%= t(".all_past_and_future", resource: rule.resource_type.pluralize) %>
<% else %>
<%= t(".on_or_after", resource: rule.resource_type.pluralize, date: rule.effective_date.strftime("%b %-d, %Y")) %>
<% end %>
</span>
</p>
</div>
</div>
<div class="flex items-center gap-4">
<%= styled_form_with model: rule, namespace: "rule_#{rule.id}", data: { controller: "auto-submit-form" } do |f| %>
<%= f.toggle :active, { data: { auto_submit_form_target: "auto" } } %>
<% end %>
<%= render DS::Menu.new do |menu| %>
<% menu.with_item(variant: "link", text: t(".edit"), href: edit_rule_path(rule), icon: "pencil", data: { turbo_frame: "modal" }) %>
<% menu.with_item(variant: "link", text: t(".re_apply_rule"), href: confirm_rule_path(rule), icon: "refresh-cw", data: { turbo_frame: "modal" }) %>
<% menu.with_item(
variant: "button",
text: t(".delete"),
href: rule_path(rule),
icon: "trash-2",
method: :delete,
confirm: CustomConfirm.for_resource_deletion("rule")) %>
<% end %>
</div>
</div>