Skip to content

Commit 98c5e34

Browse files
ISSUE #1631: Improve ExtractTranslationsConsoleCommand
1 parent c0c6b39 commit 98c5e34

15 files changed

+96
-83
lines changed

config/reference.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,17 +1098,6 @@
10981098
* doctrine?: DoctrineConfig,
10991099
* doctrine_migrations?: DoctrineMigrationsConfig,
11001100
* twig?: TwigConfig,
1101-
* "when@dev"?: array{
1102-
* imports?: ImportsConfig,
1103-
* parameters?: ParametersConfig,
1104-
* services?: ServicesConfig,
1105-
* framework?: FrameworkConfig,
1106-
* flysystem?: FlysystemConfig,
1107-
* monolog?: MonologConfig,
1108-
* doctrine?: DoctrineConfig,
1109-
* doctrine_migrations?: DoctrineMigrationsConfig,
1110-
* twig?: TwigConfig,
1111-
* },
11121101
* "when@prod"?: array{
11131102
* imports?: ImportsConfig,
11141103
* parameters?: ParametersConfig,
@@ -1211,7 +1200,6 @@ public static function config(array $config): array
12111200
* deprecated?: array{package:string, version:string, message?:string},
12121201
* }
12131202
* @psalm-type RoutesConfig = array{
1214-
* "when@dev"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12151203
* "when@prod"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12161204
* "when@test"?: array<string, RouteConfig|ImportConfig|AliasConfig>,
12171205
* ...<string, RouteConfig|ImportConfig|AliasConfig>
-21.2 KB
Binary file not shown.
440 KB
Loading

docs/configuration/dashboard-widgets.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ This widget summarizes how you train. Each axis reflects a different normalized
169169
{ 'widget': 'athleteProfile', 'width': 33, 'enabled': true }
170170
```
171171

172-
![athleteProfile widget](../assets/images/dashboard-widgets/athlete-profile.jpeg)
172+
![athleteProfile widget](../assets/images/dashboard-widgets/athlete-profile.png)
173173

174174
## eddington
175175

public/manifest.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"id": "http://localhost:8080/",
3-
"name": "Statistics for Strava | Robin Ingelbrecht 🦖",
2+
"id": "[APP_HOST]",
3+
"name": "[APP_NAME]",
44
"short_name": "Statistics for Strava",
55
"description": "Statistics for Strava is a self-hosted web app designed to provide you with better stats.",
66
"categories": [
@@ -9,7 +9,7 @@
99
"utilities"
1010
],
1111
"start_url": "/",
12-
"scope": "http://localhost:8080/",
12+
"scope": "[APP_HOST]",
1313
"display": "standalone",
1414
"display_override": [
1515
"fullscreen",
@@ -20,49 +20,49 @@
2020
"background_color": "#f9fafb",
2121
"icons": [
2222
{
23-
"src": "/assets/images/manifest/icon-192.png",
23+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-192.png",
2424
"sizes": "192x192",
2525
"type": "image/png"
2626
},
2727
{
28-
"src": "/assets/images/manifest/icon-192.maskable.png",
28+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-192.maskable.png",
2929
"sizes": "192x192",
3030
"type": "image/png",
3131
"purpose": "maskable"
3232
},
3333
{
34-
"src": "/assets/images/manifest/icon-512.png",
34+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-512.png",
3535
"sizes": "512x512",
3636
"type": "image/png"
3737
},
3838
{
39-
"src": "/assets/images/manifest/icon-512.maskable.png",
39+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-512.maskable.png",
4040
"sizes": "512x512",
4141
"type": "image/png",
4242
"purpose": "maskable"
4343
},
4444
{
45-
"src": "/assets/images/manifest/icon-512.png",
45+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-512.png",
4646
"sizes": "any",
4747
"type": "image/png"
4848
},
4949
{
50-
"src": "/assets/images/manifest/icon-512.maskable.png",
50+
"src": "[APP_BASE_PATH]/assets/images/manifest/icon-512.maskable.png",
5151
"sizes": "any",
5252
"type": "image/png",
5353
"purpose": "maskable"
5454
}
5555
],
5656
"screenshots": [
5757
{
58-
"src": "/assets/images/manifest/screenshots/dashboard.jpeg",
58+
"src": "[APP_BASE_PATH]/assets/images/manifest/screenshots/dashboard.jpeg",
5959
"sizes": "750x1600",
6060
"type": "image/jpeg",
6161
"form_factor": "narrow",
6262
"label": "Dashboard"
6363
},
6464
{
65-
"src": "/assets/images/manifest/screenshots/heatmap.jpeg",
65+
"src": "[APP_BASE_PATH]/assets/images/manifest/screenshots/heatmap.jpeg",
6666
"sizes": "750x1600",
6767
"type": "image/jpeg",
6868
"form_factor": "narrow",

src/Console/ExtractTranslationsConsoleCommand.php

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use App\Infrastructure\ValueObject\String\KernelProjectDir;
99
use Symfony\Component\Console\Attribute\AsCommand;
1010
use Symfony\Component\Console\Command\Command;
11-
use Symfony\Component\Console\Input\InputArgument;
1211
use Symfony\Component\Console\Input\InputInterface;
1312
use Symfony\Component\Console\Input\InputOption;
1413
use Symfony\Component\Console\Output\OutputInterface;
@@ -22,10 +21,11 @@ class ExtractTranslationsConsoleCommand extends Command
2221
{
2322
public function __construct(
2423
private readonly ExtractorInterface $extractor,
25-
private readonly KernelProjectDir $kernelProjectDir
26-
){
24+
private readonly KernelProjectDir $kernelProjectDir,
25+
) {
2726
parent::__construct();
2827
}
28+
2929
protected function configure(): void
3030
{
3131
$this->addOption('removeObsoleteTranslatables', null, InputOption::VALUE_NONE);
@@ -53,18 +53,34 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5353
$output->writeln(sprintf('<info>Extracted translations for "%s"</info>', $locale->value));
5454
}
5555

56-
if($input->getOption('removeObsoleteTranslatables')){
57-
$messages = new MessageCatalogue(Locale::en_US->value);
56+
if (!$input->getOption('removeObsoleteTranslatables')) {
57+
return Command::SUCCESS;
58+
}
59+
60+
$messages = new MessageCatalogue(Locale::en_US->value);
61+
62+
$this->extractor->extract($this->kernelProjectDir.'/templates', $messages);
63+
$this->extractor->extract($this->kernelProjectDir.'/src', $messages);
64+
$translatables = $messages->all()['messages'];
65+
66+
$translatableKeys = array_keys($translatables ?? []);
5867

59-
$this->extractor->extract($this->kernelProjectDir.'/templates', $messages);
60-
$this->extractor->extract($this->kernelProjectDir.'/src', $messages);
61-
$translatables = $messages->all()['messages'];
68+
$translationFilePath = sprintf('%s/translations/messages%s.%s.yaml', $this->kernelProjectDir, MessageCatalogue::INTL_DOMAIN_SUFFIX, Locale::en_US->value);
69+
$parsedTranslations = Yaml::parse(file_get_contents($translationFilePath) ?: '');
70+
71+
if (!$translationKeysToRemove = array_diff(array_keys($parsedTranslations), $translatableKeys)) {
72+
return Command::SUCCESS;
73+
}
74+
75+
foreach (Locale::cases() as $locale) {
76+
$translationFilePath = sprintf('%s/translations/messages%s.%s.yaml', $this->kernelProjectDir, MessageCatalogue::INTL_DOMAIN_SUFFIX, $locale->value);
77+
$parsedTranslations = Yaml::parse(file_get_contents($translationFilePath) ?: '');
6278

63-
$translatableKeys = array_keys($translatables ?? []);
79+
foreach ($translationKeysToRemove as $keyToRemove) {
80+
unset($parsedTranslations[$keyToRemove]);
81+
}
6482

65-
$translationFilePath = sprintf('%s/translations/messages%s.%s.yaml', $this->kernelProjectDir, MessageCatalogue::INTL_DOMAIN_SUFFIX, Locale::en_US->value);
66-
$parsedTranslations = Yaml::parse(file_get_contents($translationFilePath));
67-
$translationKeysToRemove = array_diff(array_keys($parsedTranslations), $translatableKeys);
83+
file_put_contents($translationFilePath, Yaml::dump($parsedTranslations));
6884
}
6985

7086
return Command::SUCCESS;

translations/messages+intl-icu.de_DE.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ Hikes: Wanderungen
136136
History: Verlauf
137137
'History chart': 'History chart'
138138
'How diverse is your training': 'How diverse is your training'
139-
'How hard do you train': 'How hard do you train'
140-
'How long are your sessions': 'How long are your sessions'
141-
'How much do you train': 'How much do you train'
139+
'How hard is your typical training session': 'How hard is your typical training session'
140+
'How long is your typical training session': 'How long is your typical training session'
141+
'How much do you train on average per week': 'How much do you train on average per week'
142+
'How much training you do in total on days you train.': 'How much training you do in total on days you train.'
142143
'How often do you train': 'How often do you train'
143-
'How packed is your training': 'How packed is your training'
144144
'Ice Skate': Eislaufen
145145
Id: Id
146146
'Image "{imgSrc}" is referenced in your maintenance config file, but was not found in "storage/gear-maintenance"': 'Das Bild "{imgSrc}" wurde in deiner maintenance config Datei referenziert, aber es wurde nicht unter "storage/gear-maintenance" gefunden'
@@ -273,6 +273,7 @@ Socials: 'Soziale Medien'
273273
Speed: Geschwindigkeit
274274
'Speed distribution': 'Speed distribution'
275275
Splits: Zwischenzeiten
276+
'Sport variety': 'Sport variety'
276277
Squash: Squash
277278
'Stair Stepper': Stufen-Stepper
278279
'Stand Up Paddling': Stand-Up-Paddeln
@@ -281,6 +282,7 @@ Squash: Squash
281282
'Statistics for Strava': 'Statistiken für Strava'
282283
Stats: Statistiken
283284
'Stats per weekday': 'Statistiken pro Wochentag'
285+
'Streak started on {date}': 'Streak started on {date}'
284286
Streaks: Serien
285287
Sun: So
286288
Sunday: Sonntag
@@ -325,7 +327,6 @@ Tuesday: Dienstag
325327
Unspecified: 'Nicht spezifiziert'
326328
'Updated on': 'Aktualisiert am'
327329
'User badge': 'Benutzer Abzeichen'
328-
Variety: Variety
329330
'Velo Mobiles': Velomobil
330331
'Very fresh – possible detraining': 'Sehr erholt – möglicher Leistungsabbau'
331332
'Very high': 'Sehr hoch'

translations/messages+intl-icu.en_US.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ Hikes: Hikes
136136
History: History
137137
'History chart': 'History chart'
138138
'How diverse is your training': 'How diverse is your training'
139-
'How hard do you train': 'How hard do you train'
140-
'How long are your sessions': 'How long are your sessions'
141-
'How much do you train': 'How much do you train'
139+
'How hard is your typical training session': 'How hard is your typical training session'
140+
'How long is your typical training session': 'How long is your typical training session'
141+
'How much do you train on average per week': 'How much do you train on average per week'
142+
'How much training you do in total on days you train.': 'How much training you do in total on days you train.'
142143
'How often do you train': 'How often do you train'
143-
'How packed is your training': 'How packed is your training'
144144
'Ice Skate': 'Ice Skate'
145145
Id: Id
146146
'Image "{imgSrc}" is referenced in your maintenance config file, but was not found in "storage/gear-maintenance"': 'Image "{imgSrc}" is referenced in your maintenance config file, but was not found in "storage/gear-maintenance"'
@@ -273,6 +273,7 @@ Socials: Socials
273273
Speed: Speed
274274
'Speed distribution': 'Speed distribution'
275275
Splits: Splits
276+
'Sport variety': 'Sport variety'
276277
Squash: Squash
277278
'Stair Stepper': 'Stair Stepper'
278279
'Stand Up Paddling': 'Stand Up Paddling'
@@ -281,6 +282,7 @@ Squash: Squash
281282
'Statistics for Strava': 'Statistics for Strava'
282283
Stats: Stats
283284
'Stats per weekday': 'Stats per weekday'
285+
'Streak started on {date}': 'Streak started on {date}'
284286
Streaks: Streaks
285287
Sun: Sun
286288
Sunday: Sunday
@@ -325,7 +327,6 @@ Tuesday: Tuesday
325327
Unspecified: Unspecified
326328
'Updated on': 'Updated on'
327329
'User badge': 'User badge'
328-
Variety: Variety
329330
'Velo Mobiles': 'Velo Mobiles'
330331
'Very fresh – possible detraining': 'Very fresh – possible detraining'
331332
'Very high': 'Very high'

translations/messages+intl-icu.fr_FR.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ Hikes: Randonnées
136136
History: Historique
137137
'History chart': 'History chart'
138138
'How diverse is your training': 'How diverse is your training'
139-
'How hard do you train': 'How hard do you train'
140-
'How long are your sessions': 'How long are your sessions'
141-
'How much do you train': 'How much do you train'
139+
'How hard is your typical training session': 'How hard is your typical training session'
140+
'How long is your typical training session': 'How long is your typical training session'
141+
'How much do you train on average per week': 'How much do you train on average per week'
142+
'How much training you do in total on days you train.': 'How much training you do in total on days you train.'
142143
'How often do you train': 'How often do you train'
143-
'How packed is your training': 'How packed is your training'
144144
'Ice Skate': 'Patin à glace'
145145
Id: Id
146146
'Image "{imgSrc}" is referenced in your maintenance config file, but was not found in "storage/gear-maintenance"': 'L''image "{imgSrc}" est référencée dans votre fichier de configuration de maintenance, mais n''a pas été trouvée dans "storage/gear-maintenance"'
@@ -273,6 +273,7 @@ Socials: 'Réseaux sociaux'
273273
Speed: Vitesse
274274
'Speed distribution': 'Répartition de la vitesse'
275275
Splits: Splits
276+
'Sport variety': 'Sport variety'
276277
Squash: Squash
277278
'Stair Stepper': Steppeur
278279
'Stand Up Paddling': 'Paddle debout'
@@ -281,6 +282,7 @@ Squash: Squash
281282
'Statistics for Strava': 'Statistiques pour Strava'
282283
Stats: Statistiques
283284
'Stats per weekday': 'Statistiques par jour de la semaine'
285+
'Streak started on {date}': 'Streak started on {date}'
284286
Streaks: Séries
285287
Sun: Dim
286288
Sunday: Dimanche
@@ -325,7 +327,6 @@ Tuesday: Mardi
325327
Unspecified: 'Non spécifié'
326328
'Updated on': 'Mis à jour le'
327329
'User badge': "Badge d'utilisateur"
328-
Variety: Variety
329330
'Velo Mobiles': Vélomobiles
330331
'Very fresh – possible detraining': 'Très frais – risque de désentraînement'
331332
'Very high': 'Très élevé'

translations/messages+intl-icu.it_IT.yaml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ Hikes: Escursioni
136136
History: Cronologia
137137
'History chart': 'History chart'
138138
'How diverse is your training': 'How diverse is your training'
139-
'How hard do you train': 'How hard do you train'
140-
'How long are your sessions': 'How long are your sessions'
141-
'How much do you train': 'How much do you train'
139+
'How hard is your typical training session': 'How hard is your typical training session'
140+
'How long is your typical training session': 'How long is your typical training session'
141+
'How much do you train on average per week': 'How much do you train on average per week'
142+
'How much training you do in total on days you train.': 'How much training you do in total on days you train.'
142143
'How often do you train': 'How often do you train'
143-
'How packed is your training': 'How packed is your training'
144144
'Ice Skate': 'Pattinaggio su ghiaccio'
145145
Id: ID
146146
'Image "{imgSrc}" is referenced in your maintenance config file, but was not found in "storage/gear-maintenance"': 'L''immagine "{imgSrc}" è referenziata nel tuo file di configurazione della manutenzione, ma non è stata trovata in "storage/gear-maintenance"'
@@ -273,6 +273,7 @@ Socials: Social
273273
Speed: Velocità
274274
'Speed distribution': 'Distribuzione della velocità'
275275
Splits: Intertempi
276+
'Sport variety': 'Sport variety'
276277
Squash: Squash
277278
'Stair Stepper': 'Stepper a gradini'
278279
'Stand Up Paddling': 'Stand up paddle'
@@ -281,6 +282,7 @@ Squash: Squash
281282
'Statistics for Strava': 'Statistiche per Strava'
282283
Stats: Statistiche
283284
'Stats per weekday': 'Statistiche giornaliere'
285+
'Streak started on {date}': 'Streak started on {date}'
284286
Streaks: Serie
285287
Sun: Dom
286288
Sunday: Domenica
@@ -325,7 +327,6 @@ Tuesday: Martedì
325327
Unspecified: 'Non specificato'
326328
'Updated on': 'Aggiornato il'
327329
'User badge': 'Badge utente'
328-
Variety: Variety
329330
'Velo Mobiles': Velomobili
330331
'Very fresh – possible detraining': 'Molto fresco – possibile perdita di forma'
331332
'Very high': 'Molto alto'

0 commit comments

Comments
 (0)