0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/app/views/about/index.html.erb
Natalie Tay af11f8992c
FEATURE: Localizable /about page fields via its settings page (#41123)
The /about page (unlike /guidelines or /tos) is not backed by a topic,
but instead via a bunch of site settings.

If it were backed by a topic, localization would be easy as it can just
use TopicLocalizations. We also can't swap it out to use a topic, since
there are so many fields on the about page that can't be safely
contained in a topic.

----------

This PR adds SiteSettingLocalization, allowing new attributes in site
settings config for localization.

For now this is wired into the About page settings flow:
  - admins can select a non-default locale on /admin/config/about
  - only translatable About fields are shown for that locale
  - localized About values are used on /about and /about.json
- company_url can be set manually per locale, but is excluded from
automatic translation
- ~~AI backfill can translate eligible site setting localizations~~ no
backfill (added in
https://github.com/discourse/discourse/pull/41123/commits/386c655d2f44aca54440c069bd06ea8007793d84,
removed in
https://github.com/discourse/discourse/pull/41123/commits/6f8ec9cc43dca4195bda638b1ce980eb68a59941.
about page has very non automa-ble fields

This intentionally keeps the scope narrow. It does not make every site
setting localizable, and any other setting can be localized by adding to
that allowlist.

Some screenshots

|page | 📸  | 
|--|--|
| eng setting | <img width="1278" height="871" alt="Screenshot
2026-06-23 at 11 00 34 PM"
src="https://github.com/user-attachments/assets/59431464-fb05-41d9-8c4f-fd9aae7fb45f"
/>
| ja setting | <img width="1278" height="871" alt="Screenshot 2026-06-23
at 11 01 20 PM"
src="https://github.com/user-attachments/assets/73cd2878-f59a-4dc4-a76d-2f46b74a6eed"
/>
| ja anon about page | <img width="1278" height="871" alt="Screenshot
2026-06-23 at 11 01 48 PM"
src="https://github.com/user-attachments/assets/02464a5f-9ca0-4519-9521-be41498c1967"
/>
2026-06-26 20:41:08 +08:00

118 lines
3.9 KiB
Text
Vendored

<% if crawler_layout? %>
<section itemscope itemtype="https://schema.org/AboutPage">
<h1 itemprop="name">
<%=t "js.about.title", **{title: @about.title} %>
</h1>
<div itemprop="text">
<%= @about.description %>
</div>
<h2><%=t "js.about.our_admins" %></h2>
<div class='admins-list' itemscope itemtype='http://schema.org/ItemList'>
<% @about.admins.each do |user| %>
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
<a rel='nofollow' href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
<span itemprop='image'>
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
</span>
<span itemprop='name'>
<%= user.username %>
<% if user.name.present? && SiteSetting.enable_names %>
- <%= user.name %>
<% end %>
</span>
</a>
</div>
<% end %>
</div>
<% if @about.moderators.count > 0 %>
<h2><%=t "js.about.our_moderators" %></h2>
<div class='moderators-list' itemscope itemtype='http://schema.org/ItemList'>
<% @about.moderators.each do |user| %>
<div itemprop='itemListElement' itemscope itemtype='http://schema.org/ListItem'>
<meta itemprop='url' content='<%= user_path(user.encoded_username(lower: true)) %>'>
<a rel='nofollow' href='<%= user_path(user.encoded_username(lower: true)) %>' itemprop='item'>
<span itemprop='image'>
<img width="45" height="45" class="avatar" src="<%= user.small_avatar_url %>">
</span>
<span itemprop='name'>
<%= user.username %>
<% if user.name.present? && SiteSetting.enable_names %>
- <%= user.name %>
<% end %>
</span>
</a>
</div>
<% end %>
</div>
<% end %>
<%- stats = About.fetch_cached_stats %>
<section class='about stats'>
<h2><%=t 'js.about.stats' %></h2>
<table class='table'>
<tr>
<th>&nbsp;</th>
<th><%=t 'js.about.stat.all_time' %></th>
<th><%=t 'js.about.stat.last_day' %></th>
<th><%=t 'js.about.stat.last_7_days' %></th>
<th><%=t 'js.about.stat.last_30_days' %></th>
</tr>
<tr>
<td class='title'><%=t 'js.about.topic_count' %></td>
<td><%= stats["topic_count"] %></td>
<td><%= stats["topics_last_day"] %></td>
<td><%= stats["topics_7_days"] %></td>
<td><%= stats["topics_30_days"] %></td>
</tr>
<tr>
<td><%=t 'js.about.post_count' %></td>
<td><%= stats["post_count"] %></td>
<td><%= stats["posts_last_day"] %></td>
<td><%= stats["posts_7_days"] %></td>
<td><%= stats["posts_30_days"] %></td>
</tr>
<tr>
<td><%=t 'js.about.user_count' %></td>
<td><%= stats["user_count"] %></td>
<td><%= stats["users_last_day"] %></td>
<td><%= stats["users_7_days"] %></td>
<td><%= stats["users_30_days"] %></td>
</tr>
<tr>
<td><%=t 'js.about.active_user_count' %></td>
<td>&mdash;</td>
<td><%= stats["active_users_last_day"] %></td>
<td><%= stats["active_users_7_days"] %></td>
<td><%= stats["active_users_30_days"] %></td>
</tr>
<tr>
<td><%=t 'js.about.like_count' %></td>
<td><%= stats["like_count"] %></td>
<td><%= stats["likes_last_day"] %></td>
<td><%= stats["likes_7_days"] %></td>
<td><%= stats["likes_30_days"] %></td>
</tr>
</table>
</section>
</section>
<br/>
<br/>
<% end %>
<% if @title %>
<% content_for :title do %><%= @title %><% end %>
<% end %>
<% content_for :head do %>
<%= raw crawlable_meta_data(title: @title || @about.title, description: @about.description) %>
<% end %>