Skip to content

Commit b2489a1

Browse files
committed
Cleanup translations
- Translations of unknown sounce were added to the translations.html.twig so they are not cleaned up. - validation messages, mostly from 3rd party bundles are not cleaned up. - Use TranslatableMessage class in places where translations were not detected before - Cleanup some untranslated and unknown translations
1 parent fe6a8f6 commit b2489a1

12 files changed

Lines changed: 65 additions & 35 deletions

File tree

.github/workflows/test-integration.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
name: test-integration
2-
on: [pull_request, push]
2+
on:
3+
pull_request:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
38
jobs:
49
build:
510
runs-on: ubuntu-latest

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mock service was created for end to end test purposes, but could be utilized in
3838

3939
### Translations
4040
Gateway uses the default symfony translations bundle. To extract / update the translations, run:
41-
`./bin/console trans:extract nl_NL --force ; ./bin/console trans:extract en_GB --force`
41+
`./bin/extract-translations.sh`
4242
Then modify and commit the changes.
4343

4444
### Frontend Development

bin/extract-translations.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
11
#!/bin/bash
2-
bin/console translation:extract --config=default --env=dev
2+
# Extract from main application code
3+
# Use --clean for messages domain to remove unused translations
4+
bin/console trans:extract nl_NL --force --clean --domain=messages
5+
bin/console trans:extract en_GB --force --clean --domain=messages
6+
7+
# Extract validators without --clean to preserve vendor translations
8+
bin/console trans:extract nl_NL --force --domain=validators
9+
bin/console trans:extract en_GB --force --domain=validators

config/packages/translation.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ framework:
33
translator:
44
default_path: '%kernel.project_dir%/translations'
55
fallbacks:
6-
- "%default_locale%"
6+
- "%default_locale%"

src/Surfnet/StepupGateway/GatewayBundle/Form/Type/CancelAuthenticationType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
use Symfony\Component\Form\AbstractType;
2222
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
2323
use Symfony\Component\Form\FormBuilderInterface;
24+
use Symfony\Component\Translation\TranslatableMessage;
2425

2526
class CancelAuthenticationType extends AbstractType
2627
{
2728
public function buildForm(FormBuilderInterface $builder, array $options): void
2829
{
2930
$builder->add('cancel', SubmitType::class, [
30-
'label' => 'gateway.form.cancel_authentication.button.cancel',
31+
'label' => new TranslatableMessage('gateway.form.cancel_authentication.button.cancel'),
3132
'attr' => ['class' => 'btn-link', 'formnovalidate' => 'formnovalidate'],
3233
]);
3334
}

src/Surfnet/StepupGateway/GatewayBundle/Form/Type/CancelSecondFactorVerificationType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121
use Symfony\Component\Form\AbstractType;
2222
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
2323
use Symfony\Component\Form\FormBuilderInterface;
24+
use Symfony\Component\Translation\TranslatableMessage;
2425

2526
final class CancelSecondFactorVerificationType extends AbstractType
2627
{
2728
public function buildForm(FormBuilderInterface $builder, array $options): void
2829
{
2930
$builder->add('cancel', SubmitType::class, [
30-
'label' => 'gateway.form.gateway_cancel_second_factor_verification.button.cancel_verification',
31+
'label' => new TranslatableMessage('gateway.form.gateway_cancel_second_factor_verification.button.cancel_verification'),
3132
'attr' => ['class' => 'btn btn-danger'],
3233
]);
3334
}

src/Surfnet/StepupGateway/GatewayBundle/Form/Type/ChooseSecondFactorType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
2424
use Symfony\Component\Form\FormBuilderInterface;
2525
use Symfony\Component\OptionsResolver\OptionsResolver;
26+
use Symfony\Component\Translation\TranslatableMessage;
2627

2728
class ChooseSecondFactorType extends AbstractType
2829
{
@@ -34,7 +35,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
3435
foreach ($data->secondFactors as $secondFactor) {
3536
$type = $secondFactor->secondFactorType;
3637
$builder->add('choose_' . $type, SubmitType::class, [
37-
'label' => 'gateway.second_factor.choose_second_factor.select',
38+
'label' => new TranslatableMessage('gateway.second_factor.choose_second_factor.select'),
3839
'attr' => [
3940
'class' => 'btn btn-primary',
4041
'value' => $secondFactor->secondFactorType

src/Surfnet/StepupGateway/GatewayBundle/Form/Type/SendSmsChallengeType.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@
2222
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
2323
use Symfony\Component\Form\FormBuilderInterface;
2424
use Symfony\Component\OptionsResolver\OptionsResolver;
25+
use Symfony\Component\Translation\TranslatableMessage;
2526

2627
class SendSmsChallengeType extends AbstractType
2728
{
2829
public function buildForm(FormBuilderInterface $builder, array $options): void
2930
{
3031
$builder->add('send_challenge', SubmitType::class, [
31-
'label' => 'gateway.form.gateway_send_sms_challenge.button.send_challenge',
32+
'label' => new TranslatableMessage('gateway.form.gateway_send_sms_challenge.button.send_challenge'),
3233
'attr' => [ 'class' => 'btn btn-primary' ],
3334
]);
3435
}

src/Surfnet/StepupGateway/GatewayBundle/Form/Type/VerifySmsChallengeType.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use Symfony\Component\Form\Extension\Core\Type\TextType;
2424
use Symfony\Component\Form\FormBuilderInterface;
2525
use Symfony\Component\OptionsResolver\OptionsResolver;
26+
use Symfony\Component\Translation\TranslatableMessage;
2627

2728
class VerifySmsChallengeType extends AbstractType
2829
{
@@ -34,15 +35,15 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
3435
'attr' => [
3536
'autofocus' => true,
3637
'autocomplete' => 'one-time-code',
37-
'placeholder' => 'gateway.form.verify_sms_challenge.button.challenge_placeholder'
38+
'placeholder' => new TranslatableMessage('gateway.form.verify_sms_challenge.button.challenge_placeholder'),
3839
]
3940
]);
4041
$builder->add('verify_challenge', SubmitType::class, [
41-
'label' => 'gateway.form.verify_sms_challenge.button.verify_challenge',
42+
'label' => new TranslatableMessage('gateway.form.verify_sms_challenge.button.verify_challenge'),
4243
'attr' => ['class' => 'btn btn-primary'],
4344
]);
4445
$builder->add('resend_challenge', AnchorType::class, [
45-
'label' => 'gateway.form.verify_sms_challenge.button.resend_challenge',
46+
'label' => new TranslatableMessage('gateway.form.verify_sms_challenge.button.resend_challenge'),
4647
'attr' => ['class' => 'btn btn-link'],
4748
'route' => 'gateway_verify_second_factor_sms',
4849
]);

templates/translations.html.twig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{# Store hidden translation keys here so they will be picked up by JMSTranslationBundle #}
2+
3+
{# Yubikey OTP verification controller action #}
4+
{{ 'gateway.form.verify_yubikey.otp_verification_failed'|trans }}
5+
{{ 'gateway.form.verify_yubikey.public_id_mismatch'|trans }}
6+
7+
{# SMS verification #}
8+
{{ 'gateway.form.send_sms_challenge.sms_sending_failed'|trans }}
9+
{{ 'gateway.form.send_sms_challenge.sms_challenge_incorrect'|trans }}
10+
{{ 'gateway.form.send_sms_challenge.too_many_attempts'|trans }}
11+
{{ 'gateway.second_factor.sms.text.otp_requests_remaining'|trans }}
12+
13+
{# Choose second factor form (WAYG) #}
14+
{{ 'gateway.form.gateway_choose_second_factor.unknown_second_factor_type'|trans }}
15+
16+
{# Second factor type translations #}
17+
{{ 'gateway.second_factor.search.type.sms'|trans }}
18+
{{ 'gateway.second_factor.search.type.yubikey'|trans }}
19+
20+
{# Messages of unknown orgin #}
21+
{{ 'stepup.error.authentication_error.description'|trans }}
22+
{{ 'stepup.error.authentication_error.title'|trans }}
23+
{{ 'stepup.error.authn_failed.description'|trans }}
24+
{{ 'stepup.error.authn_failed.title'|trans }}
25+
{{ 'stepup.error.generic_error.description'|trans }}
26+
{{ 'stepup.error.generic_error.title'|trans }}
27+
{{ 'stepup.error.precondition_not_met.description'|trans }}
28+
{{ 'stepup.error.precondition_not_met.title'|trans }}
29+
{{ 'stepup.error.signature_validation_failed.description'|trans }}
30+
{{ 'stepup.error.unknown_service_provider.title'|trans }}
31+
{{ 'stepup.error.signature_validation_failed.title'|trans }}
32+
33+
{{ 'stepup.error.unknown_service_provider.title'|trans }}
34+
{{ 'stepup.error.unsigned_request.description'|trans }}
35+
{{ 'stepup.error.unsigned_request.title'|trans }}
36+
{{ 'stepup.error.unsupported_signature.description'|trans }}
37+
{{ 'stepup.error.unsupported_signature.title'|trans }}

0 commit comments

Comments
 (0)