Add localized URLs; will expand in the future

master
Tait Hoyem 1 year ago
parent 72ad6946e6
commit 25d5e4c1fa

@ -8,9 +8,6 @@ use askama::i18n::{langid, Locale};
askama::i18n::load!(LOCALES);
use crate::model::{Division, Game, GamePlayer, League, Player, Shot, Team, Language};
use serde::{Serialize, Deserialize};
use views::{GoalDetails, PlayerStats, ShotDetails, TeamStats, IihfStatsI64};
use languages::SupportedLanguage;
@ -28,7 +25,7 @@ use sqlx::{Pool, Postgres};
use std::net::SocketAddr;
use std::sync::Arc;
const VERSION: &str = "0.2.9";
const VERSION: &str = "0.2.10";
#[derive(Template)]
#[template(path = "hello.html")]
@ -102,6 +99,8 @@ struct IihfTeamStatsTableTemplate<'a> {
#[derive(Template)]
#[template(path = "game_list.html")]
struct GameListTemplate<'a> {
#[locale]
locale: Locale<'a>,
division: Division,
iihf_team_stats_table: IihfTeamStatsTableTemplate<'a>,
games: Vec<Game>,
@ -294,6 +293,7 @@ async fn games_for_division_html(
.await
.unwrap();
let games_template = GameListTemplate {
locale: lang.into(),
division,
iihf_team_stats_table: IihfTeamStatsTableTemplate {
locale: lang.into(),

@ -10,10 +10,10 @@
<h2 id="games">Games</h2>
<ol aria-labelledby="games">
{% for game in games %}
<li><a href="/en/game/{{ game.id }}/">{{ game.name }}</a></li>
<li><a href="{{ localize("game_url_tmpl", lang: lang.to_string(), id: game.id) }}">{{ game.name }}</a></li>
{% endfor %}
</ol>
{% else %}
<p>No games have been recorded.</p>
<p>{{ localize("no-games") }}</p>
{% endif %}
{% endblock %}

@ -1,7 +1,7 @@
<table>
<thead>
<tr>
<th>{{ localize("game_plural") }}</th>
<th>{{ localize("team") }}</th>
<th>{{ localize("point_plural") }}</th>
<th>{{ localize("reg_wins_short") }}</th>
<th>{{ localize("reg_losses_short") }}</th>

@ -17,9 +17,9 @@
<td>{{ shot.player_number }}</td>
<td>
{% if shot.is_goal %}
Goal
{{ localize("goal") }}
{% else %}
Shot
{{ localize("shot") }}
{% endif %}
</td>
<td>{{ shot.period_short_name }}</td>

@ -1,4 +1,5 @@
game-of-division = { $game } of the { $division }
no-games = No games have been recorded.
play-by-play = play-by-play
box-score = box score
individual = individual
@ -12,6 +13,8 @@ league_ibihf = IBIHF Leagues
language_selection = Please choose your language
game = game
game_plural = games
shot = shot
shot_plural = shots
point = point
point_plural = points
goal = goal

@ -1,5 +1,5 @@
game_url = /:lang/games/:id/
game_url_tmpl = /{ $lang }/games/{ $id }/
game_url = /:lang/game/:id/
game_url_tmpl = /{ $lang }/game/{ $id }/
league_url = /:lang/league/:id/
league_url_tmpl = /{ $lang }/league/{ $id }/
division_url = /:lang/division/:id/

@ -1,4 +1,5 @@
game-of-division = { $game } de le { $division }
no-games = Aucun match na été enregistré.
play-by-play = jeu-par-jeu
box-score = score de la boîte
individual = individu
@ -15,6 +16,8 @@ point = point
point_plural = points
goal = but
goal_plural = buts
shot = tiré
shot_plural = tirs
assist = aide
assist_plural = aides
name = nom

Loading…
Cancel
Save