feat: add i18n #3

Merged
vavakado merged 7 commits from i18n into main 2024-12-12 18:56:59 +02:00
7 changed files with 52 additions and 52 deletions
Showing only changes of commit 65308f8bda - Show all commits

View file

@ -83,7 +83,7 @@ defmodule ExmrWeb.CoreComponents do
</button>
</div>
<div id={"#{@id}-content"}>
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</div>
</.focus_wrap>
</div>
@ -128,9 +128,9 @@ defmodule ExmrWeb.CoreComponents do
<p :if={@title} class="flex items-center gap-1.5 text-sm font-semibold leading-6">
<.icon :if={@kind == :info} name="hero-information-circle-mini" class="h-4 w-4" />
<.icon :if={@kind == :error} name="hero-exclamation-circle-mini" class="h-4 w-4" />
<%= @title %>
{@title}
</p>
<p class="mt-2 text-sm leading-5"><%= msg %></p>
<p class="mt-2 text-sm leading-5">{msg}</p>
<button type="button" class="group absolute top-1 right-1 p-2" aria-label={gettext("close")}>
<.icon name="hero-x-mark-solid" class="h-5 w-5 opacity-40 group-hover:opacity-70" />
</button>
@ -161,7 +161,7 @@ defmodule ExmrWeb.CoreComponents do
phx-connected={hide("#client-error")}
hidden
>
<%= gettext("Attempting to reconnect") %>
{gettext("Attempting to reconnect")}
<.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" />
</.flash>
@ -173,7 +173,7 @@ defmodule ExmrWeb.CoreComponents do
phx-connected={hide("#server-error")}
hidden
>
<%= gettext("Hang in there while we get back on track") %>
{gettext("Hang in there while we get back on track")}
<.icon name="hero-arrow-path" class="ml-1 h-3 w-3 animate-spin" />
</.flash>
</div>
@ -207,12 +207,12 @@ defmodule ExmrWeb.CoreComponents do
~H"""
<.form :let={f} for={@for} as={@as} {@rest}>
<div class="mt-10 space-y-8 bg-white dark:bg-zinc-950">
<%= render_slot(@inner_block, f) %>
{render_slot(@inner_block, f)}
<div
:for={action <- @actions}
class="mt-2 flex items-center justify-between gap-6 dark:text-zinc-100"
>
<%= render_slot(action, f) %>
{render_slot(action, f)}
</div>
</div>
</.form>
@ -244,7 +244,7 @@ defmodule ExmrWeb.CoreComponents do
]}
{@rest}
>
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</button>
"""
end
@ -328,9 +328,9 @@ defmodule ExmrWeb.CoreComponents do
class="rounded border-zinc-300 text-zinc-900 focus:ring-0"
{@rest}
/>
<%= @label %>
{@label}
</label>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
@ -338,7 +338,7 @@ defmodule ExmrWeb.CoreComponents do
def input(%{type: "select"} = assigns) do
~H"""
<div>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<select
id={@id}
name={@name}
@ -346,10 +346,10 @@ defmodule ExmrWeb.CoreComponents do
multiple={@multiple}
{@rest}
>
<option :if={@prompt} value=""><%= @prompt %></option>
<%= Phoenix.HTML.Form.options_for_select(@options, @value) %>
<option :if={@prompt} value="">{@prompt}</option>
{Phoenix.HTML.Form.options_for_select(@options, @value)}
</select>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
@ -357,7 +357,7 @@ defmodule ExmrWeb.CoreComponents do
def input(%{type: "textarea"} = assigns) do
~H"""
<div>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<textarea
id={@id}
name={@name}
@ -368,7 +368,7 @@ defmodule ExmrWeb.CoreComponents do
]}
{@rest}
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
@ -377,7 +377,7 @@ defmodule ExmrWeb.CoreComponents do
def input(assigns) do
~H"""
<div>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<input
type={@type}
name={@name}
@ -390,7 +390,7 @@ defmodule ExmrWeb.CoreComponents do
]}
{@rest}
/>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
@ -404,7 +404,7 @@ defmodule ExmrWeb.CoreComponents do
def label(assigns) do
~H"""
<label for={@for} class="block text-sm font-semibold leading-6 text-zinc-800 dark:text-zinc-200">
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</label>
"""
end
@ -418,7 +418,7 @@ defmodule ExmrWeb.CoreComponents do
~H"""
<p class="mt-3 flex gap-3 text-sm leading-6 text-rose-600">
<.icon name="hero-exclamation-circle-mini" class="mt-0.5 h-5 w-5 flex-none" />
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</p>
"""
end
@ -437,13 +437,13 @@ defmodule ExmrWeb.CoreComponents do
<header class={[@actions != [] && "flex items-center justify-between gap-6", @class]}>
<div>
<h1 class="text-lg font-semibold leading-8 text-zinc-800 dark:text-zinc-200">
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</h1>
<p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600 dark:text-zinc-100">
<%= render_slot(@subtitle) %>
{render_slot(@subtitle)}
</p>
</div>
<div class="flex-none"><%= render_slot(@actions) %></div>
<div class="flex-none">{render_slot(@actions)}</div>
</header>
"""
end
@ -484,9 +484,9 @@ defmodule ExmrWeb.CoreComponents do
<table class="w-[40rem] mt-11 sm:w-full">
<thead class="text-sm text-left leading-6 text-zinc-500">
<tr>
<th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal"><%= col[:label] %></th>
<th :for={col <- @col} class="p-0 pb-4 pr-6 font-normal">{col[:label]}</th>
<th :if={@action != []} class="relative p-0 pb-4">
<span class="sr-only"><%= gettext("Actions") %></span>
<span class="sr-only">{gettext("Actions")}</span>
</th>
</tr>
</thead>
@ -504,7 +504,7 @@ defmodule ExmrWeb.CoreComponents do
<div class="block py-4 pr-6">
<span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-zinc-50 sm:rounded-l-xl" />
<span class={["relative", i == 0 && "font-semibold text-zinc-900"]}>
<%= render_slot(col, @row_item.(row)) %>
{render_slot(col, @row_item.(row))}
</span>
</div>
</td>
@ -515,7 +515,7 @@ defmodule ExmrWeb.CoreComponents do
:for={action <- @action}
class="relative ml-4 font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
>
<%= render_slot(action, @row_item.(row)) %>
{render_slot(action, @row_item.(row))}
</span>
</div>
</td>
@ -545,8 +545,8 @@ defmodule ExmrWeb.CoreComponents do
<div class="mt-14">
<dl class="-my-4 divide-y divide-zinc-100">
<div :for={item <- @item} class="flex gap-4 py-4 text-sm leading-6 sm:gap-8">
<dt class="w-1/4 flex-none text-zinc-500"><%= item.title %></dt>
<dd class="text-zinc-700"><%= render_slot(item) %></dd>
<dt class="w-1/4 flex-none text-zinc-500">{item.title}</dt>
<dd class="text-zinc-700">{render_slot(item)}</dd>
</div>
</dl>
</div>
@ -571,7 +571,7 @@ defmodule ExmrWeb.CoreComponents do
class="text-sm font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
>
<.icon name="hero-arrow-left-solid" class="h-3 w-3" />
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</.link>
</div>
"""

View file

@ -5,7 +5,7 @@
<img src={~p"/images/logo.svg"} width="36" />
</a>
<p class="bg-brand/5 text-brand rounded-full px-2 font-medium leading-6">
v<%= Application.spec(:exmr, :vsn) %>
v{Application.spec(:exmr, :vsn)}
</p>
</div>
</div>
@ -13,6 +13,6 @@
<main class="px-4 py-20 sm:px-6 lg:px-8">
<div class="mx-auto max-w-2xl">
<.flash_group flash={@flash} />
<%= @inner_content %>
{@inner_content}
</div>
</main>

View file

@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="csrf-token" content={get_csrf_token()} />
<.live_title suffix=" · Phoenix Framework">
<%= assigns[:page_title] || "Exmr" %>
{assigns[:page_title] || "Exmr"}
</.live_title>
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
<script>
@ -23,14 +23,14 @@
<DarkMode.button />
<%= if @current_user do %>
<li class="text-[0.8125rem] leading-6 text-zinc-900 dark:text-zinc-300">
<%= @current_user.email %>
{@current_user.email}
</li>
<li>
<.link
href={~p"/users/settings"}
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700 dark:text-zinc-300 dark:hover:text-zinc-100"
>
<%= gettext("Settings") %>
{gettext("Settings")}
</.link>
</li>
<li>
@ -39,7 +39,7 @@
method="delete"
class="text-[0.8125rem] leading-6 text-zinc-900 font-semibold hover:text-zinc-700 dark:text-zinc-300 dark:hover:text-zinc-100"
>
<%= gettext("Log out") %>
{gettext("Log out")}
</.link>
</li>
<% else %>
@ -61,6 +61,6 @@
</li>
<% end %>
</ul>
<%= @inner_content %>
{@inner_content}
</body>
</html>

View file

@ -44,14 +44,14 @@
<h1 class="mt-10 flex items-center text-sm font-semibold leading-6 text-purple-400">
ExMR
<small class="bg-brand/5 text-[0.8125rem] ml-3 rounded-full px-2 font-medium leading-6 text-purple-400">
v<%= Application.spec(:exmr, :vsn) %>
v{Application.spec(:exmr, :vsn)}
</small>
</h1>
<p class="text-[2rem] mt-4 font-semibold leading-10 tracking-tighter text-zinc-900 dark:text-zinc-200/90 text-balance">
<%= gettext("A simple, modern, and fast exam management system.") %>
{gettext("A simple, modern, and fast exam management system.")}
</p>
<p class="mt-4 text-base leading-7 text-zinc-600 dark:text-zinc-300">
<%= gettext("Built using Phoenix LiveView, Ecto, and TailwindCSS by @vavakado") %>
{gettext("Built using Phoenix LiveView, Ecto, and TailwindCSS by @vavakado")}
</p>
<div class="flex">
<div class="w-full sm:w-auto">
@ -93,7 +93,7 @@
</div>
<div class="text-center py-8 font-bold text-3xl text-red-600">
<.link navigate={~p"/exams"} class="underline hover:text-red-400 transition-all ease-in-out">
<%= gettext("Exams") %>
{gettext("Exams")}
</.link>
</div>
</div>

View file

@ -8,9 +8,9 @@ defmodule ExmrWeb.ExamLive.FormComponent do
~H"""
<div>
<.header>
<%= @title %>
{@title}
<:subtitle>
<%= gettext("Use this form to manage exam records in your database.") %>
{gettext("Use this form to manage exam records in your database.")}
</:subtitle>
</.header>
@ -25,7 +25,7 @@ defmodule ExmrWeb.ExamLive.FormComponent do
<.input field={@form[:description]} type="text" label={gettext("Description")} />
<.input field={@form[:date]} type="date" label={gettext("Date")} />
<:actions>
<.button phx-disable-with={gettext("Saving...")}><%= gettext("Save Exam") %></.button>
<.button phx-disable-with={gettext("Saving...")}>{gettext("Save Exam")}</.button>
</:actions>
</.simple_form>
</div>

View file

@ -1,6 +1,6 @@
<.header>
exam №<%= @exam.id %>
<:subtitle>очередная контрольная работа по <strong><%= @exam.subject %></strong></:subtitle>
exam №{@exam.id}
<:subtitle>очередная контрольная работа по <strong>{@exam.subject}</strong></:subtitle>
<:actions>
<.link patch={~p"/exams/#{@exam}/show/edit"} phx-click={JS.push_focus()}>
<.button>изменить</.button>
@ -9,8 +9,8 @@
</.header>
<.list>
<:item title="Description"><%= @exam.description %></:item>
<:item title="Date"><%= @exam.date %></:item>
<:item title="Description">{@exam.description}</:item>
<:item title="Date">{@exam.date}</:item>
</.list>
<.back navigate={~p"/exams"}>Back to exams</.back>

View file

@ -6,8 +6,8 @@ defmodule ExmrWeb.UserSettingsLive do
def render(assigns) do
~H"""
<.header class="text-center">
<%= gettext("Account Settings") %>
<:subtitle><%= gettext("Manage your account email address and password settings") %></:subtitle>
{gettext("Account Settings")}
<:subtitle>{gettext("Manage your account email address and password settings")}</:subtitle>
</.header>
<div class="space-y-12 divide-y">
@ -30,7 +30,7 @@ defmodule ExmrWeb.UserSettingsLive do
/>
<:actions>
<.button phx-disable-with={gettext("Changing...")}>
<%= gettext("Change Email") %>
{gettext("Change Email")}
</.button>
</:actions>
</.simple_form>
@ -73,7 +73,7 @@ defmodule ExmrWeb.UserSettingsLive do
/>
<:actions>
<.button phx-disable-with={gettext("Changing...")}>
<%= gettext("Change Password") %>
{gettext("Change Password")}
</.button>
</:actions>
</.simple_form>