Skip to content

Commit

Permalink
Merge pull request #2074 from manyfold3d/pluralization
Browse files Browse the repository at this point in the history
Fix translation of pluralized model names
  • Loading branch information
Floppy authored Apr 23, 2024
2 parents 0aa9659 + 5022f92 commit bdb7d2e
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 46 deletions.
2 changes: 1 addition & 1 deletion app/helpers/problems_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def max_problem_severity(problems = Problem.all)
def problem_icon(problems = Problem.all)
return "" if problems.empty?
severity = max_problem_severity(problems)
content_tag(:span, icon("exclamation-triangle-fill", Problem.model_name.human.pluralize), class: "text-#{severity} align-middle")
content_tag(:span, icon("exclamation-triangle-fill", Problem.model_name.human(count: 100)), class: "text-#{severity} align-middle")
end
end
2 changes: 1 addition & 1 deletion app/views/application/_filters_card.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<% end %>
<% if @filters[:tag] %>
<tr>
<td><%= icon "tag", ActsAsTaggableOn::Tag.model_name.human %> <%= ActsAsTaggableOn::Tag.model_name.human.pluralize %></td>
<td><%= icon "tag", ActsAsTaggableOn::Tag.model_name.human(count: 100) %> <%= ActsAsTaggableOn::Tag.model_name.human(count: 100) %></td>
<td><span class='pe-none'><%= render partial: "tag", collection: @tag, locals: {state: :normal} %></span></td>
<td><%= link_to icon("trash", t(".remove_filter")), @filters.except(:tag), {class: "text-danger"} %></td>
</tr>
Expand Down
6 changes: 3 additions & 3 deletions app/views/application/_footer.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<div class="col-4 col-lg-2 mb-3">
<h5><%= t ".stats_heading" %></h5>
<ul class="list-unstyled">
<li class="mb-2"><%= pluralize(Library.count, Library.model_name.human) %></li>
<li class="mb-2"><%= pluralize(Model.count, Model.model_name.human) %></li>
<li class="mb-2"><%= pluralize(ModelFile.count, ModelFile.model_name.human) %></li>
<li class="mb-2"><%= Library.count %> <%= Library.model_name.human(count: Library.count) %></li>
<li class="mb-2"><%= Model.count %> <%= Model.model_name.human(count: Model.count) %></li>
<li class="mb-2"><%= ModelFile.count %> <%= ModelFile.model_name.human(count: ModelFile.count) %></li>
</ul>
</div>
<div class="col-4 col-lg-2 mb-3">
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_links_card.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<% unless links.empty? %>
<%= card :secondary, Link.model_name.human.pluralize do %>
<%= card :secondary, Link.model_name.human(count: 100) do %>
<ul class='links'>
<% links.each do |link| %>
<li><%= link_to t("sites.%{site}" % {site: link.site}), link.url %></li>
Expand Down
8 changes: 4 additions & 4 deletions app/views/application/_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
<div class="collapse navbar-collapse row" id="navbar">
<ul class="navbar-nav col-6 ps-4 ps-lg-0 align-self-start">
<li class="nav-item">
<%= nav_link "box", Model.model_name.human.pluralize, models_path(@filters) %>
<%= nav_link "box", Model.model_name.human(count: 100), models_path(@filters) %>
</li>
<li class="nav-item">
<%= nav_link "people", Creator.model_name.human.pluralize, creators_path(@filters&.except(:creator)) %>
<%= nav_link "people", Creator.model_name.human(count: 100), creators_path(@filters&.except(:creator)) %>
</li>
<li class="nav-item">
<%= nav_link "collection", Collection.model_name.human.pluralize, collections_path(@filters&.except(:collection)) %>
<%= nav_link "collection", Collection.model_name.human(count: 100), collections_path(@filters&.except(:collection)) %>
</li>
<% policy_scope(Library).find_each do |library| %>
<li class="nav-item">
Expand Down Expand Up @@ -55,7 +55,7 @@
<% if Problem.visible(current_user.problem_settings).count > 0 %>
<li class="nav-item">
<%= nav_link "exclamation-triangle-fill",
Problem.model_name.human.pluralize,
Problem.model_name.human(count: 100),
problems_path,
icon_style: "link-#{max_problem_severity}",
text_style: "d-lg-none" %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/application/_tag_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
</ul>
<% end %>
<% if defined?(muted_tags) && !muted_tags.empty? && current_user.tag_cloud_settings["hide_unrelated"] %>
<p class="small"><%= pluralize(muted_tags.count, "unrelated tag") %> <%= t ".hidden" %> </p>
<p class="small"><%= t ".muted_tags", count: muted_tags.count %></p>
<% end %>
4 changes: 2 additions & 2 deletions app/views/collections/_collection.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
</ul>
</div>
<div>
<%= link_to pluralize(collection.models.count, t("activerecord.models.model")), {controller: "models", collection: collection.id}, class: "btn btn-primary" if policy(collection).show? %>
<%= link_to(pluralize(collection.collections.count, t("activerecord.models.collection")), (@filters || {}).merge(controller: "collections", collection: collection.id), class: "btn btn-primary") if collection.collections.count > 0 && policy(collection).show? %>
<%= link_to "#{collection.models.count} #{Model.model_name.human count: collection.models.count}", {controller: "models", collection: collection.id}, class: "btn btn-primary" if policy(collection).show? %>
<%= link_to "#{collection.collections.count} #{Collection.model_name.human count: collection.collections.count}", (@filters || {}).merge(controller: "collections", collection: collection.id), class: "btn btn-primary" if collection.collections.count > 0 && policy(collection).show? %>
<%= link_to t("general.edit"), edit_collection_path(collection), {class: "btn btn-outline-secondary"} if policy(collection).edit? %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/collections/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<% end %>
<%= render "filters_card" %>
<% unless @tags.empty? %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human.pluralize, collapse: "md" do %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human(count: 100), collapse: "md" do %>
<%= render "tag_list", tags: @tags - (@tag || []), muted_tags: @tags - @commontags %>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/creators/_creator.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<li><%= link_to t("sites.%{site}" % {site: link.site}), link.url %></li>
<% end %>
</ul>
<%= link_to pluralize(creator.models.count, "Model").to_s, models_path(creator: creator.id), {class: "btn btn-primary"} if policy(creator).show? %>
<%= link_to "#{creator.models.count} #{Model.model_name.human count: creator.models.count}", models_path(creator: creator.id), {class: "btn btn-primary"} if policy(creator).show? %>
<%= link_to "Edit", edit_creator_path(creator), {class: "btn btn-outline-secondary"} if policy(creator).edit? %>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/creators/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<% end %>
<%= render "filters_card" %>
<% unless @tags.empty? %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human.pluralize, collapse: "md" do %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human(count: 100), collapse: "md" do %>
<%= render "tag_list", tags: @tags - (@tag || []), muted_tags: @tags - @commontags %>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/model_files/bulk_edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= render partial: "breadcrumb" %>
<h1>Bulk Edit <%= ModelFile.model_name.human.pluralize %></h1>
<h1>Bulk Edit <%= ModelFile.model_name.human(count: @files.count) %></h1>

<%= form_with url: bulk_update_library_model_model_files_path(@library, @model), method: :patch do |form| %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/models/bulk_edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Bulk Edit <%= Model.model_name.human.pluralize %></h1>
<h1>Bulk Edit <%= Model.model_name.human(count: @models.count) %></h1>

<%= form_with url: update_models_path, method: :patch do |form| %>

Expand Down
2 changes: 1 addition & 1 deletion app/views/models/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<% end %>
<%= render "filters_card" %>
<% unless @tags.empty? %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human.pluralize, collapse: "md" do %>
<%= card :secondary, ActsAsTaggableOn::Tag.model_name.human(count: 100), collapse: "md" do %>
<%= render "tag_list", tags: @tags - (@tag || []), muted_tags: @tags - @commontags %>
<% end %>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/models/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<% end %>
<% if @model.collection %>
<tr>
<td><%= icon "collection", Collection.model_name.human.pluralize %></td>
<td><%= icon "collection", Collection.model_name.human(count: 100) %></td>
<td><%= link_to @model.collection.name, models_path((@filters || {}).merge(collection: @model.collection.id)) %></td>
</tr>
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/problems/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1><%= Problem.model_name.human.pluralize %></h1>
<h1><%= Problem.model_name.human(count: 100) %></h1>

<%= render "filters" %>

Expand Down
32 changes: 24 additions & 8 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,30 @@ de:
already_presupported: kann nicht auf eine vorunterstützte Datei gesetzt werden
not_supported: keine vordefinierte Datei
models:
acts_as_taggable_on/tag: Tag
collection: Kollektion
creator: Ersteller
library: Sammlung
link: URL
model: Modell
model_file: Datei
problem: Problem
acts_as_taggable_on/tag:
one: Bezeichnung
other: Bezeichnungen
collection:
one: Kollektion
other: Kollektionen
creator:
one: Ersteller
other: Ersteller
library:
one: Sammlung
other: Sammlungen
link:
one: URL
other: URLs
model:
one: Modell
other: Modelle
model_file:
one: Datei
other: Dateien
problem:
one: Problem
other: Probleme
user:
one: Benutzer
other: Benutzer
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,9 @@ en:
settings: Settings
upload: Upload
tag_list:
hidden: hidden
muted_tags:
one: "%{count} unrelated tag hidden"
other: "%{count} unrelated tags hidden"
tagline: Helping you keep track of your 3d print files
title: Manyfold
errors:
Expand Down
32 changes: 24 additions & 8 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,30 @@ fr:
already_presupported: ne peut pas être défini sur un fichier présupporté
not_supported: n'est pas un fichier présupporté
models:
acts_as_taggable_on/tag: Étiquette
collection: Collection
creator: Créateur
library: Bibliothèque
link: Lien
model: Modèle
model_file: Fichier
problem: Problème
acts_as_taggable_on/tag:
one: Étiquette
other:
collection:
one: Collection
other:
creator:
one: Créateur
other:
library:
one: Bibliothèque
other:
link:
one: Lien
other:
model:
one: Modèle
other:
model_file:
one: Fichier
other:
problem:
one: Problème
other:
user:
one: Utilisateur
other: Utilisateurs
Expand Down
39 changes: 31 additions & 8 deletions config/locales/pl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,37 @@ pl:
already_presupported:
not_supported:
models:
acts_as_taggable_on/tag: Tag
collection: Kolekcja
creator: Twórca
library: Biblioteka
link: Link
model: Model
model_file: Plik
problem: Problem
acts_as_taggable_on/tag:
few:
one: Tag
other:
collection:
few:
one: Kolekcja
other:
creator:
one: Twórca
other: Twórców
library:
few: Biblioteki
one: Biblioteka
other: Bibliotek
link:
few:
one: Link
other:
model:
few: Modele
one: Model
other: Modeli
model_file:
few:
one: Plik
other:
problem:
few:
one: Problem
other:
user:
one: Użytkownik
other: Użytkowników
Expand Down

0 comments on commit bdb7d2e

Please sign in to comment.