fix CLDR issues

pull/2473/head
Ayrat Badykov 5 years ago
parent 761fb05256
commit 2a5c63b5e5
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 2
      apps/block_scout_web/lib/block_scout_web/channels/address_channel.ex
  2. 4
      apps/block_scout_web/lib/block_scout_web/templates/address/overview.html.eex
  3. 4
      apps/block_scout_web/lib/block_scout_web/templates/block/overview.html.eex
  4. 6
      apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex
  5. 2
      apps/block_scout_web/lib/block_scout_web/views/address_view.ex
  6. 4
      apps/block_scout_web/lib/block_scout_web/views/block_view.ex
  7. 2
      apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex

@ -73,7 +73,7 @@ defmodule BlockScoutWeb.AddressChannel do
def handle_out("count", %{count: count}, socket) do def handle_out("count", %{count: count}, socket) do
Gettext.put_locale(BlockScoutWeb.Gettext, socket.assigns.locale) Gettext.put_locale(BlockScoutWeb.Gettext, socket.assigns.locale)
push(socket, "count", %{count: Cldr.Number.to_string!(count, format: "#,###")}) push(socket, "count", %{count: BlockScoutWeb.Cldr.Number.to_string!(count, format: "#,###")})
{:noreply, socket} {:noreply, socket}
end end

@ -79,7 +79,7 @@
<%= gettext("Incoming Transactions") %> <%= gettext("Incoming Transactions") %>
<% else %> <% else %>
<span data-selector="transaction-count"> <span data-selector="transaction-count">
<%= Cldr.Number.to_string!(@transaction_count, format: "#,###") %> <%= BlockScoutWeb.Cldr.Number.to_string!(@transaction_count, format: "#,###") %>
</span> </span>
<%= gettext("Transactions Sent") %> <%= gettext("Transactions Sent") %>
<% end %> <% end %>
@ -92,7 +92,7 @@
<%= if validator?(@validation_count) do %> <%= if validator?(@validation_count) do %>
<span class="address-detail-item"> <span class="address-detail-item">
<span data-selector="validation-count"> <span data-selector="validation-count">
<%= Cldr.Number.to_string!(@validation_count, format: "#,###") %> <%= BlockScoutWeb.Cldr.Number.to_string!(@validation_count, format: "#,###") %>
</span> </span>
<%= gettext("Blocks Validated") %> <%= gettext("Blocks Validated") %>
</span> </span>

@ -98,7 +98,7 @@
<dt class="col-sm-3 text-muted"><%= gettext "Gas Used" %></dt> <dt class="col-sm-3 text-muted"><%= gettext "Gas Used" %></dt>
<dd class="col-sm-9"> <dd class="col-sm-9">
<span><%= @block.gas_used |> Cldr.Number.to_string! %></span> <span><%= @block.gas_used |> Cldr.Number.to_string! %></span>
<span class="text-muted">(<%= (Decimal.to_integer(@block.gas_used) / Decimal.to_integer(@block.gas_limit)) |> Cldr.Number.to_string!(format: "#.#%") %>)</span> <span class="text-muted">(<%= (Decimal.to_integer(@block.gas_used) / Decimal.to_integer(@block.gas_limit)) |> BlockScoutWeb.Cldr.Number.to_string!(format: "#.#%") %>)</span>
</dt> </dt>
</dl> </dl>
<dl class="row mb-0"> <dl class="row mb-0">
@ -147,7 +147,7 @@
<div class="text-right"> <div class="text-right">
<h3 class="address-balance-text"> <h3 class="address-balance-text">
<%= @block.gas_used |> Cldr.Number.to_string! %> <%= @block.gas_used |> Cldr.Number.to_string! %>
<span class="text-muted">(<%= (Decimal.to_integer(@block.gas_used) / Decimal.to_integer(@block.gas_limit)) |> Cldr.Number.to_string!(format: "#.#%") %>)</span> <span class="text-muted">(<%= (Decimal.to_integer(@block.gas_used) / Decimal.to_integer(@block.gas_limit)) |> BlockScoutWeb.Cldr.Number.to_string!(format: "#.#%") %>)</span>
</h3> </h3>
<p class="address-current-balance"><%= @block.gas_limit |> Cldr.Number.to_string! %><%= gettext "Gas Limit" %></p> <p class="address-current-balance"><%= @block.gas_limit |> Cldr.Number.to_string! %><%= gettext "Gas Limit" %></p>
</div> </div>

@ -56,7 +56,7 @@
<%= gettext "Total transactions" %> <%= gettext "Total transactions" %>
</span> </span>
<span class="dashboard-banner-network-stats-value" data-selector="transaction-count"> <span class="dashboard-banner-network-stats-value" data-selector="transaction-count">
<%= Cldr.Number.to_string!(@transaction_estimated_count, format: "#,###") %> <%= BlockScoutWeb.Cldr.Number.to_string!(@transaction_estimated_count, format: "#,###") %>
</span> </span>
</div> </div>
<div class="dashboard-banner-network-stats-item dashboard-banner-network-stats-item-3"> <div class="dashboard-banner-network-stats-item dashboard-banner-network-stats-item-3">
@ -64,7 +64,7 @@
<%= gettext "Total blocks" %> <%= gettext "Total blocks" %>
</span> </span>
<span class="dashboard-banner-network-stats-value" data-selector="block-count"> <span class="dashboard-banner-network-stats-value" data-selector="block-count">
<%= Cldr.Number.to_string!(@block_count, format: "#,###") %> <%= BlockScoutWeb.Cldr.Number.to_string!(@block_count, format: "#,###") %>
</span> </span>
</div> </div>
<div class="dashboard-banner-network-stats-item dashboard-banner-network-stats-item-4"> <div class="dashboard-banner-network-stats-item dashboard-banner-network-stats-item-4">
@ -72,7 +72,7 @@
<%= gettext "Wallet addresses" %> <%= gettext "Wallet addresses" %>
</span> </span>
<span class="dashboard-banner-network-stats-value" data-selector="address-count"> <span class="dashboard-banner-network-stats-value" data-selector="address-count">
<%= Cldr.Number.to_string!(@address_count, format: "#,###") %> <%= BlockScoutWeb.Cldr.Number.to_string!(@address_count, format: "#,###") %>
</span> </span>
</div> </div>
</div> </div>

@ -222,7 +222,7 @@ defmodule BlockScoutWeb.AddressView do
def incoming_transaction_count(address_hash) do def incoming_transaction_count(address_hash) do
address_hash address_hash
|> Chain.address_to_incoming_transaction_count() |> Chain.address_to_incoming_transaction_count()
|> Cldr.Number.to_string!(format: "#,###") |> BlockScoutWeb.Cldr.Number.to_string!(format: "#,###")
end end
def trimmed_hash(%Hash{} = hash) do def trimmed_hash(%Hash{} = hash) do

@ -33,7 +33,7 @@ defmodule BlockScoutWeb.BlockView do
# We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Unit.to_string! spec # We do this to trick Dialyzer to not complain about non-local returns caused by bug in Cldr.Unit.to_string! spec
case :erlang.phash2(1, 1) do case :erlang.phash2(1, 1) do
0 -> 0 ->
Cldr.Unit.to_string!(unit) BlockScoutWeb.Cldr.Unit.to_string!(unit)
1 -> 1 ->
# does not occur # does not occur
@ -42,7 +42,7 @@ defmodule BlockScoutWeb.BlockView do
end end
def formatted_gas(gas, format \\ []) do def formatted_gas(gas, format \\ []) do
Cldr.Number.to_string!(gas, format) BlockScoutWeb.Cldr.Number.to_string!(gas, format)
end end
def formatted_timestamp(%Block{timestamp: timestamp}) do def formatted_timestamp(%Block{timestamp: timestamp}) do

@ -100,7 +100,7 @@ defmodule BlockScoutWeb.TransactionView do
%Block{consensus: true} -> %Block{consensus: true} ->
{:ok, confirmations} = Chain.confirmations(block, named_arguments) {:ok, confirmations} = Chain.confirmations(block, named_arguments)
Cldr.Number.to_string!(confirmations, format: "#,###") BlockScoutWeb.Cldr.Number.to_string!(confirmations, format: "#,###")
end end
end end

Loading…
Cancel
Save