fix/subscriber-count-pluralization (#84)
Reviewed-on: graham/towerops-web#84
This commit is contained in:
parent
c18f034997
commit
07fe6e6932
3 changed files with 8 additions and 2 deletions
|
|
@ -287,6 +287,12 @@ defmodule ToweropsWeb.DashboardLive do
|
|||
|
||||
defp format_number(number), do: to_string(number)
|
||||
|
||||
defp format_subscriber_count(count) when is_float(count), do: format_subscriber_count(round(count))
|
||||
|
||||
defp format_subscriber_count(count) when is_integer(count) and count > 0 do
|
||||
ngettext("%{count} sub", "%{count} subs", count, count: count)
|
||||
end
|
||||
|
||||
defp format_duration(nil), do: "Unknown"
|
||||
|
||||
defp format_duration(seconds) when is_integer(seconds) do
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@
|
|||
<td class="hidden sm:table-cell px-3 py-1.5 text-right whitespace-nowrap">
|
||||
<%= if alert.gaiia_impact && alert.gaiia_impact["total_subscribers"] && alert.gaiia_impact["total_subscribers"] > 0 do %>
|
||||
<span class="font-mono text-xs text-amber-600 dark:text-amber-400">
|
||||
{alert.gaiia_impact["total_subscribers"]}s
|
||||
{format_subscriber_count(alert.gaiia_impact["total_subscribers"])}
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
|
|
|
|||
|
|
@ -547,7 +547,7 @@ defmodule ToweropsWeb.DeviceLive.Index do
|
|||
defp format_subscriber_count(nil), do: nil
|
||||
|
||||
defp format_subscriber_count(%{subscriber_count: count}) when count > 0 do
|
||||
"#{count} subs"
|
||||
ngettext("%{count} sub", "%{count} subs", count, count: count)
|
||||
end
|
||||
|
||||
defp format_subscriber_count(_), do: nil
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue