feat: translate the site in french

This commit is contained in:
Bruno Carlin 2025-06-20 02:33:45 +02:00
parent 3e98ac15b6
commit b47b193b20
Signed by: bcarlin
GPG key ID: 8E254EA0FFEB9B6D
81 changed files with 1327 additions and 251 deletions

View file

View file

@ -0,0 +1,6 @@
<h{{ .Level }} id="{{ .Anchor }}" {{- with .Attributes.class }} class="{{ . }}" {{- end }}>
{{ .Text }}
<a href="#{{ .Anchor }}">
{{- partial "icon.html" (dict "icon" "links-line" "label" (T "permalink_section")) -}}
</a>
</h{{ .Level }}>

View file

@ -0,0 +1,8 @@
{{- $u := urls.Parse .Destination -}}
<a href="{{ .Destination | safeURL }}"
{{- with .Title }} title="{{ . }}"{{ end -}}
{{- if $u.IsAbs }} rel="external"{{ end -}}
>
{{- with .Text }}{{ . }}{{ end -}}
</a>
{{- /* chomp trailing newline */ -}}

View file

@ -0,0 +1,14 @@
<p>
© {{ now.Year }} Bruno Carlin
<br>
{{ T "license" (dict
"link" "https://creativecommons.org/licenses/by-nc/4.0/"
"name" "Creative Commons Attribution-NonCommercial 4.0 International"
) | safeHTML }}
{{partial "icon.html" (dict "icon" "creative-commons-fill" "label" "Creative Commons Logo")}}
{{partial "icon.html" (dict "icon" "creative-commons-by-fill" "label" "Creative Commons Attribution Logo")}}
{{partial "icon.html" (dict "icon" "creative-commons-nc-fill" "label" "Creative Commons Non Commercial Logo")}}
<br>
{{ T "generated_with_hugo" | safeHTML }}
</p>

View file

@ -0,0 +1,36 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"/>
{{ hugo.Generator }}
<title>{{ if .IsHome }}{{ site.Title }}{{ else }}{{ printf "%s | %s" .Title site.Title }}{{ end }}</title>
<meta name="description" content="{{ default .Summary .Description }}">
<link rel="canonical" href="{{ .Permalink }}"/>
{{- if .IsTranslated }}
{{- range .Translations }}
<link rel="alternate" hreflang="{{ .Language.Lang }}" href="{{ .RelPermalink }}"/>
{{- end }}
{{- end }}
{{ with .Site.GetPage "/blog" }}
{{- with .OutputFormats.Get "rss" }}
{{- printf `<link rel=%q type=%q href=%q title=%q>` .Rel .MediaType.Type .Permalink site.Title | safeHTML }}
{{- end }}
{{- end }}
{{ if eq .Kind "term" }}
{{- with .OutputFormats.Get "rss" }}
{{- printf `<link rel=%q type=%q href=%q title='%s | %s'>` .Rel .MediaType.Type .Permalink $.Title site.Title | safeHTML }}
{{- end }}
{{- end }}
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<link rel="shortcut icon" href="/favicon.ico" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<meta name="apple-mobile-web-app-title" content="bcarlin.net" />
<link rel="manifest" href="/site.webmanifest" />
{{ template "_internal/opengraph.html" . }}
{{- template "_internal/schema.html" . }}
{{ partialCached "head/css.html" . }}
{{- partialCached "head/js.html" . }}

View file

@ -0,0 +1,29 @@
{{- with resources.Get "static/css/pico.min.css" }}
{{- if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}
{{- with resources.Get "static/css/remixicon.css" }}
{{- if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}
{{- with resources.Get "static/css/bcarlin.css" }}
{{- if hugo.IsDevelopment }}
<link rel="stylesheet" href="{{ .RelPermalink }}">
{{- else }}
{{- with . | minify | fingerprint }}
<link rel="stylesheet" href="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous">
{{- end }}
{{- end }}
{{- end }}

View file

@ -0,0 +1,19 @@
{{- with resources.Get "static/js/bcarlin.js" }}
{{- $opts := dict
"minify" (not hugo.IsDevelopment)
"sourceMap" (cond hugo.IsDevelopment "external" "")
"targetPath" "static/js/bcarlin.js"
}}
{{- with . | js.Build $opts }}
{{- if hugo.IsDevelopment }}
<script src="{{ .RelPermalink }}"></script>
{{- else }}
{{- with . | fingerprint }}
<script src="{{ .RelPermalink }}" integrity="{{ .Data.Integrity }}" crossorigin="anonymous"></script>
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if not hugo.IsDevelopment }}
<script defer data-domain="bcarlin.net" src="//stats.bcarlin.net/js/script.js"></script>
{{- end }}

View file

@ -0,0 +1,22 @@
<a id="menu-close">
{{partial "icon.html" (dict "icon" "close-large-fill" "label" (T `close_menu`))}}
</a>
<nav id="main-menu" aria-label="{{ T `main_menu` }}">
<ul>
<li>
<a href="{{ .Site.Home.Permalink }}" class="contrast">
<img class="u-logo" src="/static/logo.svg" alt="{{T `logo`}}"/>
</a>
</li>
<li>
<span class="title p-name">
<a href="{{ .Site.Home.Permalink }}" class="contrast">{{ .Site.Title }}</a>
</span>
</li>
</ul>
{{ partial "menu.html" (dict "menuID" "main" "class" "menu-primary" "page" .) }}
{{ partial "menu.html" (dict "menuID" "secondary" "class" "menu-secondary" "page" .) }}
</nav>

View file

@ -0,0 +1 @@
<i class="ri-{{ .icon }}" role="img" title="{{ .label }}"></i>

View file

@ -0,0 +1,62 @@
{{- /*
Renders a menu for the given menu ID.
@context {page} page The current page.
@context {string} menuID The menu ID.
@example: {{ partial "menu.html" (dict "menuID" "main" "page" .) }}
*/}}
{{- $page := .page }}
{{- $menuID := .menuID }}
{{- $menuClass := .class }}
{{- with index site.Menus $menuID }}
<ul class="{{ $menuClass }}">
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
</ul>
{{- end }}
{{- define "_partials/inline/menu/walk.html" }}
{{- $page := .page }}
{{- range .menuEntries }}
{{- $attrs := dict "href" .URL "class" "" }}
{{- if $page.IsMenuCurrent .Menu . }}
{{- $attrs = merge $attrs (dict "class" "active" "aria-current" "page") }}
{{- else if $page.HasMenuCurrent .Menu .}}
{{- $attrs = merge $attrs (dict "class" "ancestor" "aria-current" "true") }}
{{- end }}
{{- $attrs = merge $attrs (dict "class" (print $attrs.class " contrast")) }}
{{- if (ne .Params.class nil) }}
{{- $attrs = merge $attrs (dict "class" (print $attrs.class " " .Params.class)) }}
{{- end }}
{{- if (ne .Params.rel nil) }}
{{- $attrs = merge $attrs (dict "rel" .Params.rel) }}
{{- end }}
{{- $name := .Name }}
{{- with .Identifier }}
{{- with T . }}
{{- $name = . }}
{{- end }}
{{- end }}
<li>
<a
{{- range $k, $v := $attrs }}
{{- with $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end -}}
>
{{- if (ne .Params.iconName nil) }}
{{partial "icon.html" (dict "icon" .Params.iconName "label" .Params.iconTitle)}}
{{- end }}
{{ $name }}
</a>
{{- with .Children }}
<ul>
{{- partial "inline/menu/walk.html" (dict "page" $page "menuEntries" .) }}
</ul>
{{- end }}
</li>
{{- end }}
{{- end }}

View file

@ -0,0 +1,9 @@
{{- with $terms := .GetTerms "tags" }}
<p class="tags">
{{ partial "icon.html" (dict "icon" "price-tag-3-line" "label" (T "tags")) }}
{{- range $idx, $it := $terms }}
<a href="{{ $it.RelPermalink }}" rel="tag" class="p-category">{{ $it.LinkTitle }}</a>
{{- if ne $idx (sub $terms.Len 1) }}<span aria-hidden="true">, </span>{{ end }}
{{- end }}
</p>
{{- end }}

54
layouts/baseof.html Normal file
View file

@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="{{ site.Language.LanguageCode }}" dir="{{ or site.Language.LanguageDirection `ltr` }}">
<head>
{{ partial "head.html" . }}
</head>
<body>
<nav class="mobile-header" aria-label="{{ T `mobile_menu` }}">
<ul>
<li>
<a href="{{ .Site.Home.Permalink }}">
<img src="/static/logo.svg" alt="{{ T `logo` }}"/>
</a>
</li>
</ul>
<ul>
<li>
<a href="{{ .Site.Home.Permalink }}" class="contrast">{{ .Site.Title }}</a>
</li>
</ul>
<ul>
<li>
<a
id="menu-toggle"
aria-controls="menu"
aria-expanded="false"
aria-label="{{ T `toggle_menu` }}"
>
{{partial "icon.html" (dict "icon" "menu-fill" "label" (T `open_menu`))}}
</a>
</li>
</ul>
</nav>
<header id="menu" class="h-card">
{{ partial "header.html" . }}
</header>
<main class="container">
{{- if .IsTranslated }}
{{- range .Translations }}
<div class="translations">
{{ T `also_available_in` }}
<a hreflang="{{ .Language.LanguageCode }}" href="{{ .RelPermalink }}" title="{{ .Language.LanguageName }}">
{{ if eq .Language.Lang "en" }}🇬🇧{{ else if eq .Language.Lang "fr" }}🇫🇷{{ else }}{{ .Language.LanguageName }}{{ end }}
</a>
</div>
{{- end }}
{{- end }}
{{ block "main" . }}{{ end }}
</main>
<footer class="container">
{{ partial "footer.html" . }}
</footer>
</body>
</html>

View file

@ -0,0 +1,11 @@
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format ":date_short" }}
<article class="h-entry">
<p>
<a class="u-url p-name" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
(<time class="dt-published" datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>)
</p>
<p class="p-summary">
{{ .Summary }}
</p>
</article>

19
layouts/blog/list.html Normal file
View file

@ -0,0 +1,19 @@
{{ define "main" }}
<article class="h-feed">
<header>
<h1 class="p-name">{{ .Title }}</h1>
</header>
{{ .Content }}
{{ range .Site.RegularPages.GroupByDate "2006" }}
<section>
<h2>{{ .Key }}</h2>
{{- range .Pages }}
{{ .Render "list-item" }}
{{- end }}
</section>
{{- end }}
</article>
{{ end }}

30
layouts/blog/single.html Normal file
View file

@ -0,0 +1,30 @@
{{ define "main" }}
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format ":date_short" }}
<article class="h-entry">
<header>
{{ with .GetTerms "categories" }}
<p class="category">
{{ range . }}
<a class="p-category" rel="tag" href="{{ .RelPermalink }}">{{ .LinkTitle }}</a>
{{ break }}
{{ end }}
</p>
{{ end }}
<h1 class="p-name">
{{ .Title }}
</h1>
<div class="metadata">
<p>
{{ T "posted" }}
<time class="dt-published" datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
</p>
{{ partial "tags.html" . }}
</div>
</header>
<section class="e-content">
{{ .Content }}
</section>
</article>
{{ end }}

17
layouts/home.html Normal file
View file

@ -0,0 +1,17 @@
{{ define "main" }}
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
<section class="h-feed">
<h2 class="p-name">{{ T "recent_posts" }}</h2>
{{- $posts := where .Site.RegularPages "Section" "blog" }}
{{- range first 5 $posts }}
{{ .Render "list-item" }}
{{- end }}
</section>
</article>
{{ end }}

17
layouts/page.html Normal file
View file

@ -0,0 +1,17 @@
{{ define "main" }}
{{ $dateMachine := .Date | time.Format "2006-01-02T15:04:05-07:00" }}
{{ $dateHuman := .Date | time.Format ":date_short" }}
<article class="h-entry">
<header>
<h1 class="p-name">{{ .Title }}</h1>
<p>
{{ T "posted" }}
<time class="dt-published" datetime="{{ $dateMachine }}">{{ $dateHuman }}</time>
</p>
</header>
<section class="e-content">
{{ .Content }}
</section>
</article>
{{ end }}

9
layouts/section.html Normal file
View file

@ -0,0 +1,9 @@
{{ define "main" }}
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
{{ .Content }}
<article>
{{ end }}

59
layouts/section.rss.xml Normal file
View file

@ -0,0 +1,59 @@
{{- $authorEmail := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .email }}
{{- $authorEmail = . }}
{{- end }}
{{- end }}
{{- end }}
{{- $authorName := "" }}
{{- with site.Params.author }}
{{- if reflect.IsMap . }}
{{- with .name }}
{{- $authorName = . }}
{{- end }}
{{- else }}
{{- $authorName = . }}
{{- end }}
{{- end }}
{{- $pctx := . }}
{{- if .IsHome }}{{ $pctx = .Site }}{{ end }}
{{- $pages := slice }}
{{- if or $.IsHome $.IsSection }}
{{- $pages = $pctx.RegularPages }}
{{- else }}
{{- $pages = $pctx.Pages }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit }}
{{- if ge $limit 1 }}
{{- $pages = $pages | first $limit }}
{{- end }}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{ . }} on {{ end }}{{ .Site.Title }}{{ end }}</title>
<link>{{ .Permalink }}</link>
<description>Recent content {{ if ne .Title .Site.Title }}{{ with .Title }}in {{ . }} {{ end }}{{ end }}on {{ .Site.Title }}</description>
<generator>Hugo</generator>
<language>{{ site.Language.LanguageCode }}</language>{{ with $authorEmail }}
<managingEditor>{{.}}{{ with $authorName }} ({{ . }}){{ end }}</managingEditor>{{ end }}{{ with $authorEmail }}
<webMaster>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</webMaster>{{ end }}{{ with .Site.Copyright }}
<copyright>{{ . }}</copyright>{{ end }}{{ if not .Date.IsZero }}
<lastBuildDate>{{ (index $pages.ByLastmod.Reverse 0).Lastmod.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</lastBuildDate>{{ end }}
{{- with .OutputFormats.Get "RSS" }}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end }}
{{- range $pages }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<pubDate>{{ .PublishDate.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{- with $authorEmail }}<author>{{ . }}{{ with $authorName }} ({{ . }}){{ end }}</author>{{ end }}
<guid>{{ .Permalink }}</guid>
<description>{{ .Content | transform.XMLEscape | safeHTML }}</description>
</item>
{{- end }}
</channel>
</rss>

View file

@ -0,0 +1,7 @@
<aside class="admonition note">
<p class="title">
{{partial "icon.html" (dict "icon" "information-fill" "label" (T "information_icon"))}}
{{ T "note" }}
</p>
{{ .Inner | .Page.RenderString }}
</aside>

View file

@ -0,0 +1,7 @@
<aside class="admonition warning">
<p class="title">
{{partial "icon.html" (dict "icon" "error-warning-fill" "label" (T "warning_icon")) -}}
{{ T "warning" }}
</p>
{{ .Inner | .Page.RenderString }}
</aside>

16
layouts/taxonomy.html Normal file
View file

@ -0,0 +1,16 @@
{{ define "main" }}
<article>
<header>
<h1>{{ .Title }}</h1>
</header>
<ul>
{{ range .Data.Terms.Alphabetical }}
<li>
<a href="{{ .Page.RelPermalink }}">{{ .Page.LinkTitle }}</a>
({{ .Count }})
</li>
{{ end }}
</ul>
</article>
{{ end }}

13
layouts/term.html Normal file
View file

@ -0,0 +1,13 @@
{{ define "main" }}
<article class="h-feed">
<header>
<h1 class="p-name">{{ .Title }}</h1>
</header>
{{ .Content }}
{{ range .Pages.ByPublishDate.Reverse }}
{{ .Render "list-item" }}
{{ end }}
</article>
{{ end }}