Skip to content

Commit 9ef7767

Browse files
feat: Allow to choose the text size of the application
1 parent 48b502a commit 9ef7767

9 files changed

Lines changed: 179 additions & 23 deletions

File tree

locales/fr_FR/LC_MESSAGES/main.mo

497 Bytes
Binary file not shown.

locales/fr_FR/LC_MESSAGES/main.po

Lines changed: 51 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
msgid ""
22
msgstr ""
33
"Project-Id-Version: Flus\n"
4-
"POT-Creation-Date: 2026-04-20 11:35+0200\n"
5-
"PO-Revision-Date: 2026-04-20 11:36+0200\n"
4+
"POT-Creation-Date: 2026-04-20 12:17+0200\n"
5+
"PO-Revision-Date: 2026-04-20 12:17+0200\n"
66
"Last-Translator: Marien Fressinaud <dev@marienfressinaud.fr>\n"
77
"Language-Team: \n"
88
"Language: fr_FR\n"
@@ -210,11 +210,11 @@ msgstr "L’URL est invalide."
210210
msgid "You already have configured a Mastodon account."
211211
msgstr "Vous avez déjà configuré un compte Mastodon."
212212

213-
#: forms/security/AskResetPassword.php:22 models/User.php:60
213+
#: forms/security/AskResetPassword.php:22 models/User.php:62
214214
msgid "The address email is required."
215215
msgstr "L’adresse courriel est obligatoire."
216216

217-
#: forms/security/AskResetPassword.php:25 models/User.php:63
217+
#: forms/security/AskResetPassword.php:25 models/User.php:65
218218
msgid "The address email is invalid."
219219
msgstr "L’adresse courriel est invalide."
220220

@@ -235,11 +235,11 @@ msgstr "L’une des collections associées n’existe pas."
235235
msgid "Sorry but you cannot do that in the demo 😉"
236236
msgstr "Désolé mais vous ne pouvez pas faire ça dans la démo 😉"
237237

238-
#: forms/traits/Locale.php:19 models/User.php:92
238+
#: forms/traits/Locale.php:19 models/User.php:94
239239
msgid "The locale is required."
240240
msgstr "La langue est obligatoire."
241241

242-
#: forms/traits/Locale.php:22 models/User.php:95
242+
#: forms/traits/Locale.php:22 models/User.php:97
243243
msgid "The locale is invalid."
244244
msgstr "La langue est invalide."
245245

@@ -255,6 +255,18 @@ msgstr ""
255255
msgid "The token has expired or has been invalidated."
256256
msgstr "Le token a expiré ou a été invalidé."
257257

258+
#: forms/users/Preferences.php:47
259+
msgid "Small"
260+
msgstr "Petite"
261+
262+
#: forms/users/Preferences.php:48
263+
msgid "Medium"
264+
msgstr "Moyenne"
265+
266+
#: forms/users/Preferences.php:49
267+
msgid "Large"
268+
msgstr "Grande"
269+
258270
#: mailers/Support.php:32
259271
#, php-format
260272
msgid "[%s] Contact: %s"
@@ -339,26 +351,38 @@ msgstr "Le nom est obligatoire."
339351
msgid "The label must be less than {max} characters."
340352
msgstr "Le nom doit faire moins de {max} caractères."
341353

342-
#: models/User.php:66
354+
#: models/User.php:68
343355
msgid "An account already exists with this email address."
344356
msgstr "Un compte existe déjà avec cette adresse courriel."
345357

346-
#: models/User.php:72
358+
#: models/User.php:74
347359
msgid "The username is required."
348360
msgstr "Le nom d’utilisateur·ice est obligatoire."
349361

350-
#: models/User.php:76
362+
#: models/User.php:78
351363
msgid "The username must be less than {max} characters."
352364
msgstr "Le nom d’utilisateur·ice ne doit pas faire plus de {max} caractères."
353365

354-
#: models/User.php:80
366+
#: models/User.php:82
355367
msgid "The username cannot contain the character ‘@’."
356368
msgstr "Le nom d’utilisateur·ice ne doit pas contenir le caractère ‘@’."
357369

358-
#: models/User.php:86
370+
#: models/User.php:88
359371
msgid "The password is required."
360372
msgstr "Le mot de passe est obligatoire."
361373

374+
#: models/User.php:112
375+
msgid "The text size is required. Please select an option from the list."
376+
msgstr ""
377+
"La taille de texte est obligatoire. Veuillez sélectionner une valeur depuis "
378+
"la liste."
379+
380+
#: models/User.php:116
381+
msgid "The text size is invalid. Please select an option from the list."
382+
msgstr ""
383+
"La taille de texte est invalide. Veuillez sélectionner une valeur depuis la "
384+
"liste."
385+
362386
#: navigations/AccountNavigation.php:16
363387
msgid "Account & data menu"
364388
msgstr "Menu compte & données"
@@ -630,7 +654,8 @@ msgstr "(max. %d caractères)"
630654
#: views/links/searches/show.html.twig:39 views/links/show.html.twig:347
631655
#: views/mastodon/show.html.twig:62 views/mastodon/show.html.twig:139
632656
#: views/my/account/deletion.html.twig:38 views/my/avatar/edit.html.twig:20
633-
#: views/my/preferences/edit.html.twig:28 views/my/profile/edit.html.twig:20
657+
#: views/my/preferences/edit.html.twig:35
658+
#: views/my/preferences/edit.html.twig:66 views/my/profile/edit.html.twig:20
634659
#: views/my/profile/edit.html.twig:50
635660
#: views/my/security/confirmation.html.twig:40
636661
#: views/my/security/show.html.twig:31 views/my/security/show.html.twig:59
@@ -705,7 +730,7 @@ msgstr "Modification d'une collection"
705730
#: views/collections/filters/edit.html.twig:96
706731
#: views/collections/groups/edit.html.twig:99 views/groups/edit.html.twig:43
707732
#: views/links/edit.html.twig:80 views/mastodon/show.html.twig:96
708-
#: views/my/preferences/edit.html.twig:102 views/my/profile/edit.html.twig:74
733+
#: views/my/preferences/edit.html.twig:140 views/my/profile/edit.html.twig:74
709734
#: views/my/security/show.html.twig:98 views/notes/edit.html.twig:49
710735
msgid "Save changes"
711736
msgstr "Enregistrer les modifications"
@@ -1352,11 +1377,11 @@ msgstr ""
13521377
"Collectez, organisez, annotez et partagez les liens<br><strong>provenant de "
13531378
"l'ensemble du Web.</strong>"
13541379

1355-
#: views/layouts/base.html.twig:44
1380+
#: views/layouts/base.html.twig:48
13561381
msgid "Skip to main content"
13571382
msgstr "Accéder au contenu principal"
13581383

1359-
#: views/layouts/base.html.twig:61 views/pages/about.html.twig:3
1384+
#: views/layouts/base.html.twig:65 views/pages/about.html.twig:3
13601385
#: views/pages/about.html.twig:11 views/pages/about.html.twig:15
13611386
#: views/support/show.html.twig:124
13621387
#, php-format
@@ -1968,33 +1993,38 @@ msgstr "Photo de profil"
19681993
msgid "Upload a photo"
19691994
msgstr "Téléverser une photo"
19701995

1971-
#: views/my/preferences/edit.html.twig:23
1996+
#: views/my/preferences/edit.html.twig:30
19721997
msgid "Your language"
19731998
msgstr "Votre langue"
19741999

1975-
#: views/my/preferences/edit.html.twig:62
2000+
#: views/my/preferences/edit.html.twig:61
2001+
msgid "Text size"
2002+
msgstr "Taille du texte"
2003+
2004+
#: views/my/preferences/edit.html.twig:100
19762005
msgid "Enable compact mode"
19772006
msgstr "Activer le mode compact"
19782007

1979-
#: views/my/preferences/edit.html.twig:66
2008+
#: views/my/preferences/edit.html.twig:104
19802009
msgid ""
19812010
"In compact mode, you see more links at a glance, but you may feel "
19822011
"overwhelmed by the information."
19832012
msgstr ""
19842013
"En mode compact, vous voyez plus de liens en un coup d’œil, mais vous "
19852014
"pourriez vous sentir submergé par la quantité d’informations."
19862015

1987-
#: views/my/preferences/edit.html.twig:79 views/registrations/new.html.twig:148
2016+
#: views/my/preferences/edit.html.twig:117
2017+
#: views/registrations/new.html.twig:148
19882018
msgid "Accept to be contacted by email to help improve the service (optional)."
19892019
msgstr ""
19902020
"Accepter d’être contacté‧e par courriel pour aider à améliorer le service "
19912021
"(facultatif)."
19922022

1993-
#: views/my/preferences/edit.html.twig:93
2023+
#: views/my/preferences/edit.html.twig:131
19942024
msgid "Enable beta features"
19952025
msgstr "Activer les fonctionnalités bêta"
19962026

1997-
#: views/my/preferences/edit.html.twig:97
2027+
#: views/my/preferences/edit.html.twig:135
19982028
msgid ""
19992029
"With beta features you test some features before everyone else, but you "
20002030
"enter a turbulent zone."

src/assets/stylesheets/application.css

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,29 @@
3232
:root {
3333
background-color: var(--color-background);
3434
}
35+
36+
:root[data-text-size="small"] {
37+
font-size: 100%;
38+
}
39+
40+
:root[data-text-size="medium"] {
41+
font-size: 105%;
42+
}
43+
44+
:root[data-text-size="large"] {
45+
font-size: 115%;
46+
}
47+
48+
@media (min-width: 800px) {
49+
:root[data-text-size="small"] {
50+
font-size: 105%;
51+
}
52+
53+
:root[data-text-size="medium"] {
54+
font-size: 115%;
55+
}
56+
57+
:root[data-text-size="large"] {
58+
font-size: 125%;
59+
}
60+
}

src/forms/users/Preferences.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ class Preferences extends BaseForm
1717
{
1818
use traits\Locale;
1919

20+
#[Form\Field]
21+
public string $option_text_size = 'medium';
22+
2023
#[Form\Field]
2124
public bool $option_compact_mode = false;
2225

@@ -37,4 +40,16 @@ public function __construct(array $default_values = [], ?models\User $model = nu
3740

3841
parent::__construct($default_values, $model);
3942
}
43+
44+
/**
45+
* @return array<string, string>
46+
*/
47+
public function textSizeValues(): array
48+
{
49+
return [
50+
'small' => \Minz\Template\TwigExtension::translate('Small'),
51+
'medium' => \Minz\Template\TwigExtension::translate('Medium'),
52+
'large' => \Minz\Template\TwigExtension::translate('Large'),
53+
];
54+
}
4055
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace App\migrations;
4+
5+
class Migration202604200001AddOptionTextSizeToUsers
6+
{
7+
public function migrate(): bool
8+
{
9+
$database = \Minz\Database::get();
10+
11+
$database->exec(<<<'SQL'
12+
ALTER TABLE users
13+
ADD COLUMN option_text_size TEXT NOT NULL DEFAULT 'medium';
14+
SQL);
15+
16+
return true;
17+
}
18+
19+
public function rollback(): bool
20+
{
21+
$database = \Minz\Database::get();
22+
23+
$database->exec(<<<'SQL'
24+
ALTER TABLE users
25+
DROP COLUMN option_text_size;
26+
SQL);
27+
28+
return true;
29+
}
30+
}

src/models/User.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ class User
2222
use utils\Memoizer;
2323
use Validable;
2424

25+
public const VALID_TEXT_SIZES = ['small', 'medium', 'large'];
26+
2527
public const USERNAME_MAX_LENGTH = 50;
2628

2729
public const DEMO_EMAIL = 'demo@flus.fr';
@@ -105,6 +107,16 @@ class User
105107
#[Database\Column]
106108
public ?string $autoload_modal;
107109

110+
#[Database\Column]
111+
#[Validable\Presence(
112+
message: new Translatable('The text size is required. Please select an option from the list.'),
113+
)]
114+
#[Validable\Inclusion(
115+
in: self::VALID_TEXT_SIZES,
116+
message: new Translatable('The text size is invalid. Please select an option from the list.'),
117+
)]
118+
public string $option_text_size = 'medium';
119+
108120
#[Database\Column]
109121
public bool $option_compact_mode;
110122

src/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ CREATE TABLE users (
3939
avatar_filename TEXT,
4040
biography TEXT NOT NULL DEFAULT '',
4141
autoload_modal TEXT NOT NULL DEFAULT '',
42+
option_text_size TEXT NOT NULL DEFAULT 'medium',
4243
option_compact_mode BOOLEAN NOT NULL DEFAULT false,
4344
accept_contact BOOLEAN NOT NULL DEFAULT false,
4445

src/views/layouts/base.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<!DOCTYPE html>
2-
<html lang="{{ app.locale | locale_to_bcp_47 }}" data-color-scheme="light">
2+
<html
3+
lang="{{ app.locale | locale_to_bcp_47 }}"
4+
data-color-scheme="light"
5+
data-text-size="{{ app.user ? app.user.option_text_size : 'medium' }}"
6+
>
37
<head>
48
<meta charset="UTF-8" />
59
<title>{{ include('layouts/_title.html.twig', { title: block('title') }) }}</title>

src/views/my/preferences/edit.html.twig

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
{% block body %}
1515
<h1 class="text--center">{{ t('Preferences') }}</h1>
1616

17-
<form method="post" action="{{ url('update preferences') }}" class="flow">
17+
<form
18+
method="post"
19+
action="{{ url('update preferences') }}"
20+
class="flow"
21+
{# Disable Turbo as changing the "text size" option sets a "data-"
22+
# attribute on the <html> tag. #}
23+
data-turbo="false"
24+
>
1825
{{ include('alerts/_error.html.twig', { message: form.error('@base') }) }}
1926

2027
<div class="form-group">
@@ -49,6 +56,37 @@
4956
</select>
5057
</div>
5158

59+
<div class="form-group">
60+
<label for="option-text-size">
61+
{{ t('Text size') }}
62+
</label>
63+
64+
{% if form.isInvalid('option_text_size') %}
65+
<p id="option-text-size-error" class="form-group__error">
66+
{{ t('Error:') }}
67+
{{ form.error('option_text_size') }}
68+
</p>
69+
{% endif %}
70+
71+
<select
72+
id="option-text-size"
73+
name="option_text_size"
74+
{% if form.isInvalid('option_text_size') %}
75+
aria-errormessage="option-text-size-error"
76+
aria-invalid="true"
77+
{% endif %}
78+
>
79+
{% for text_size_value, text_size_label in form.textSizeValues %}
80+
<option
81+
value="{{ text_size_value }}"
82+
{{ text_size_value === form.option_text_size ? 'selected' : '' }}
83+
>
84+
{{ text_size_label }}
85+
</option>
86+
{% endfor %}
87+
</select>
88+
</div>
89+
5290
<div>
5391
<input
5492
type="checkbox"

0 commit comments

Comments
 (0)