Skip to content

Commit

Permalink
GTFS diff: changement dans la section "Résumé"
Browse files Browse the repository at this point in the history
- traduction (i18n) de l'objet concerné par un changement (fichier, ligne ou
  colonne)
- ordre des résumés : ajoutés, modifications puis suppressions
  • Loading branch information
ptitfred committed Feb 5, 2025
1 parent 926185a commit 4bf0566
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 27 deletions.
29 changes: 29 additions & 0 deletions apps/transport/lib/transport_web/live/gtfs_diff_select_live.ex
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,33 @@ defmodule TransportWeb.Live.GTFSDiffSelectLive do
defp error_to_string(:too_large), do: "File is too large, must be <#{@max_file_size_mb}MB"
defp error_to_string(:too_many_files), do: "You must select 2 files"
defp error_to_string(:not_accepted), do: "You have selected an unacceptable file type"

@doc """
iex> Gettext.put_locale("en")
iex> translate_target("file", 1)
"1 file"
iex> translate_target("file", 3)
"3 files"
iex> translate_target("row", 1)
"1 row"
iex> translate_target("row", 3)
"3 rows"
iex> Gettext.put_locale("fr")
iex> translate_target("file", 1)
"1 fichier"
iex> translate_target("file", 3)
"3 fichiers"
iex> translate_target("row", 1)
"1 ligne"
iex> translate_target("row", 3)
"3 lignes"
"""
def translate_target(target, n) do
case target do
"file" -> dngettext("validations", "%{count} file", "%{count} files", n)
"row" -> dngettext("validations", "%{count} row", "%{count} rows", n)
"column" -> dngettext("validations", "%{count} column", "%{count} columns", n)
_ -> "#{n} #{target}#{if n > 1, do: "s"}"
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -90,33 +90,17 @@
gtfs_original_file_name_2: @gtfs_original_file_name_2
) %>
<div class="summary">
<div :if={@diff_summary["add"]}>
<ul>
<%= for {{file, "add", target}, n} <- @diff_summary["add"] do %>
<li>
<span class="green"><%= dgettext("validations", "added") %> &nbsp;</span><%= "#{n} #{target}#{if n > 1, do: "s"} - #{file}" %>
</li>
<% end %>
</ul>
</div>
<div :if={@diff_summary["delete"]}>
<ul>
<%= for {{file, "delete", target}, n} <- @diff_summary["delete"] do %>
<li>
<span class="red"><%= dgettext("validations", "deleted") %> &nbsp;</span><%= "#{n} #{target}#{if n > 1, do: "s"} - #{file}" %>
</li>
<% end %>
</ul>
</div>
<div :if={@diff_summary["update"]}>
<ul>
<%= for {{file, "update", target}, n} <- @diff_summary["update"] do %>
<li>
<span class="orange"><%= dgettext("validations", "updated") %> &nbsp;</span><%= "#{n} #{target}#{if n > 1, do: "s"} - #{file}" %>
</li>
<% end %>
</ul>
</div>
<%= for {diff_nature, translation, css_class} <- [{"add", dgettext("validations", "added"), "green"}, {"update", dgettext("validations", "updated"), "orange"}, {"delete", dgettext("validations", "deleted"), "red"}] do %>
<div :if={@diff_summary[diff_nature]}>
<ul>
<%= for {{file, ^diff_nature, target}, n} <- @diff_summary[diff_nature] do %>
<li>
<span class={css_class}><%= translation %> &nbsp;</span><%= "#{translate_target(target, n)} - #{file}" %>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
</div>
<% else %>
Expand Down
18 changes: 18 additions & 0 deletions apps/transport/priv/gettext/en/LC_MESSAGES/validations.po
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,21 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "enRoute Chouette Valid"
msgstr "enRoute Chouette Valid validator"

#, elixir-autogen, elixir-format
msgid "%{count} column"
msgid_plural "%{count} columns"
msgstr[0] ""
msgstr[1] ""

#, elixir-autogen, elixir-format
msgid "%{count} file"
msgid_plural "%{count} files"
msgstr[0] ""
msgstr[1] ""

#, elixir-autogen, elixir-format
msgid "%{count} row"
msgid_plural "%{count} rows"
msgstr[0] ""
msgstr[1] ""
18 changes: 18 additions & 0 deletions apps/transport/priv/gettext/fr/LC_MESSAGES/validations.po
Original file line number Diff line number Diff line change
Expand Up @@ -437,3 +437,21 @@ msgstr "le validateur GTFS du <abbr title=\"Point d’Accès National\">PAN</abb
#, elixir-autogen, elixir-format
msgid "enRoute Chouette Valid"
msgstr "le validateur NeTEx d’enRoute"

#, elixir-autogen, elixir-format
msgid "%{count} column"
msgid_plural "%{count} columns"
msgstr[0] "%{count} colonne"
msgstr[1] "%{count} colonnes"

#, elixir-autogen, elixir-format
msgid "%{count} file"
msgid_plural "%{count} files"
msgstr[0] "%{count} fichier"
msgstr[1] "%{count} fichiers"

#, elixir-autogen, elixir-format
msgid "%{count} row"
msgid_plural "%{count} rows"
msgstr[0] "%{count} ligne"
msgstr[1] "%{count} lignes"
18 changes: 18 additions & 0 deletions apps/transport/priv/gettext/validations.pot
Original file line number Diff line number Diff line change
Expand Up @@ -435,3 +435,21 @@ msgstr ""
#, elixir-autogen, elixir-format
msgid "enRoute Chouette Valid"
msgstr ""

#, elixir-autogen, elixir-format
msgid "%{count} column"
msgid_plural "%{count} columns"
msgstr[0] ""
msgstr[1] ""

#, elixir-autogen, elixir-format
msgid "%{count} file"
msgid_plural "%{count} files"
msgstr[0] ""
msgstr[1] ""

#, elixir-autogen, elixir-format
msgid "%{count} row"
msgid_plural "%{count} rows"
msgstr[0] ""
msgstr[1] ""
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
defmodule TransportWeb.Live.GTFSDiffSelectLiveTest do
use ExUnit.Case, async: true
doctest TransportWeb.Live.GTFSDiffSelectLive, import: true
end

0 comments on commit 4bf0566

Please sign in to comment.