Aggiunge traduzioni it/en/fr/de/es agli avvisi e toglie gli override Android/iOS.

Un avviso ha un testo per lingua; per differenziare le piattaforme si creano due avvisi. L'app riceve già il copy risolto da Accept-Language.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-20 16:26:30 +02:00
co-authored by Cursor
parent fb82b74e92
commit f02782d0f0
25 changed files with 396 additions and 168 deletions
@@ -37,67 +37,34 @@
<p class="muted admin-form-hint"><%= t("admin.announcements.form.channels_hint") %></p>
</fieldset>
<div>
<%= f.label :title, t("admin.announcements.form.title") %>
<%= f.text_field :title, required: true, maxlength: 120 %>
</div>
<div>
<%= f.label :body, t("admin.announcements.form.body") %>
<%= f.text_area :body, required: true, rows: 5, maxlength: 2000 %>
</div>
<div>
<%= f.label :action_url, t("admin.announcements.form.action_url") %>
<%= f.url_field :action_url, placeholder: "https://" %>
</div>
<p class="muted admin-form-hint"><%= t("admin.announcements.form.action_url_hint") %></p>
<div>
<%= f.label :action_label, t("admin.announcements.form.action_label") %>
<%= f.text_field :action_label, maxlength: 40 %>
</div>
<fieldset class="admin-channels admin-platform-copy">
<legend><%= t("admin.announcements.form.android_override") %></legend>
<p class="muted admin-form-hint"><%= t("admin.announcements.form.platform_override_hint") %></p>
<div>
<%= f.label :android_title, t("admin.announcements.form.title") %>
<%= f.text_field :android_title, maxlength: 120 %>
</div>
<div>
<%= f.label :android_body, t("admin.announcements.form.body") %>
<%= f.text_area :android_body, rows: 4, maxlength: 2000 %>
</div>
<div>
<%= f.label :android_action_url, t("admin.announcements.form.action_url") %>
<%= f.url_field :android_action_url, placeholder: "https://play.google.com/..." %>
</div>
<div>
<%= f.label :android_action_label, t("admin.announcements.form.action_label") %>
<%= f.text_field :android_action_label, maxlength: 40 %>
</div>
</fieldset>
<fieldset class="admin-channels admin-platform-copy">
<legend><%= t("admin.announcements.form.ios_override") %></legend>
<p class="muted admin-form-hint"><%= t("admin.announcements.form.platform_override_hint") %></p>
<div>
<%= f.label :ios_title, t("admin.announcements.form.title") %>
<%= f.text_field :ios_title, maxlength: 120 %>
</div>
<div>
<%= f.label :ios_body, t("admin.announcements.form.body") %>
<%= f.text_area :ios_body, rows: 4, maxlength: 2000 %>
</div>
<div>
<%= f.label :ios_action_url, t("admin.announcements.form.action_url") %>
<%= f.url_field :ios_action_url, placeholder: "https://apps.apple.com/..." %>
</div>
<div>
<%= f.label :ios_action_label, t("admin.announcements.form.action_label") %>
<%= f.text_field :ios_action_label, maxlength: 40 %>
<fieldset class="admin-channels">
<legend><%= t("admin.announcements.form.locales_legend") %></legend>
<p class="muted admin-form-hint"><%= t("admin.announcements.form.locales_hint") %></p>
<div class="admin-locale-tabs" role="tablist">
<% language_options.each do |opt| %>
<button type="button"
class="admin-locale-tab<%= " is-active" if opt[:code].to_s == I18n.default_locale.to_s %>"
data-locale-tab="<%= opt[:code] %>"
role="tab"
aria-selected="<%= opt[:code].to_s == I18n.default_locale.to_s %>">
<span aria-hidden="true"><%= opt[:flag] %></span>
<%= opt[:native] %>
<% if opt[:code].to_s == I18n.default_locale.to_s %>
<span class="muted">(<%= t("admin.announcements.form.locale_required") %>)</span>
<% elsif announcement.filled_locale_codes.include?(opt[:code].to_s) %>
<span class="muted"></span>
<% end %>
</button>
<% end %>
</div>
<% language_options.each do |opt| %>
<div class="admin-locale-panel"
data-locale-panel="<%= opt[:code] %>"
role="tabpanel"
<%= "hidden" unless opt[:code].to_s == I18n.default_locale.to_s %>>
<%= render "locale_copy", f: f, announcement: announcement, locale: opt[:code] %>
</div>
<% end %>
</fieldset>
<div class="admin-form-row">
@@ -123,3 +90,23 @@
<%= link_to t("admin.announcements.form.cancel"), admin_announcements_path, class: "admin-btn admin-btn--outline" %>
</div>
<% end %>
<script>
(function () {
var tabs = document.querySelectorAll("[data-locale-tab]");
if (!tabs.length) return;
tabs.forEach(function (btn) {
btn.addEventListener("click", function () {
var loc = btn.getAttribute("data-locale-tab");
tabs.forEach(function (other) {
var on = other === btn;
other.classList.toggle("is-active", on);
other.setAttribute("aria-selected", on ? "true" : "false");
});
document.querySelectorAll("[data-locale-panel]").forEach(function (panel) {
panel.hidden = panel.getAttribute("data-locale-panel") !== loc;
});
});
});
})();
</script>
@@ -0,0 +1,44 @@
<% it = locale.to_s == I18n.default_locale.to_s %>
<% values = announcement.copy_values_for(locale) %>
<% name_base = "app_announcement[translations][#{locale}]" %>
<div>
<% if it %>
<%= f.label :title, t("admin.announcements.form.title") %>
<%= f.text_field :title, required: true, maxlength: 120, id: "ann_#{locale}_title" %>
<% else %>
<label for="ann_<%= locale %>_title"><%= t("admin.announcements.form.title") %></label>
<%= text_field_tag "#{name_base}[title]", values["title"], maxlength: 120, id: "ann_#{locale}_title" %>
<% end %>
</div>
<div>
<% if it %>
<%= f.label :body, t("admin.announcements.form.body") %>
<%= f.text_area :body, required: true, rows: 5, maxlength: 2000, id: "ann_#{locale}_body" %>
<% else %>
<label for="ann_<%= locale %>_body"><%= t("admin.announcements.form.body") %></label>
<%= text_area_tag "#{name_base}[body]", values["body"], rows: 5, maxlength: 2000, id: "ann_#{locale}_body" %>
<% end %>
</div>
<div>
<% if it %>
<%= f.label :action_url, t("admin.announcements.form.action_url") %>
<%= f.url_field :action_url, placeholder: "https://", id: "ann_#{locale}_action_url" %>
<% else %>
<label for="ann_<%= locale %>_action_url"><%= t("admin.announcements.form.action_url") %></label>
<%= url_field_tag "#{name_base}[action_url]", values["action_url"], placeholder: "https://", id: "ann_#{locale}_action_url" %>
<% end %>
</div>
<p class="muted admin-form-hint"><%= t("admin.announcements.form.action_url_hint") %></p>
<div>
<% if it %>
<%= f.label :action_label, t("admin.announcements.form.action_label") %>
<%= f.text_field :action_label, maxlength: 40, id: "ann_#{locale}_action_label" %>
<% else %>
<label for="ann_<%= locale %>_action_label"><%= t("admin.announcements.form.action_label") %></label>
<%= text_field_tag "#{name_base}[action_label]", values["action_label"], maxlength: 40, id: "ann_#{locale}_action_label" %>
<% end %>
</div>
@@ -36,6 +36,7 @@
<td>
<strong><%= item.title %></strong>
<div class="muted" style="font-size:0.85rem;margin-top:0.25rem"><%= truncate(item.body, length: 90) %></div>
<div class="muted" style="font-size:0.8rem;margin-top:0.2rem"><%= item.filled_locale_codes.map(&:upcase).join(" · ") %></div>
</td>
<td class="muted"><%= announcement_channels_label(item) %></td>
<td class="muted"><%= announcement_window_label(item) %></td>