Skip to content

Commit 11f9b3d

Browse files
committed
Update E2E app
1 parent f2de6d7 commit 11f9b3d

File tree

12 files changed

+39
-47
lines changed

12 files changed

+39
-47
lines changed

apps/e2e/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# E2E App
22

3-
This is a Symfony application designed for end-to-end testing.
3+
This is a Symfony application designed for end-to-end testing.
44

5-
It serves for testing UX packages in a real-world scenario,
5+
It serves for testing UX packages in a real-world scenario,
66
to ensure they work as expected for multiple Symfony versions and various browsers.
77

88
## Requirements
@@ -16,7 +16,7 @@ to ensure they work as expected for multiple Symfony versions and various browse
1616

1717
```shell
1818
docker compose up -d
19-
symfony php ../.github/build-packages.php
19+
symfony php ../../.github/build-packages.php
2020

2121
SYMFONY_REQUIRE=6.4.* symfony composer update
2222
# or...

apps/e2e/assets/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { registerVueControllerComponents } from '@symfony/ux-vue';
22
import { registerSvelteControllerComponents } from '@symfony/ux-svelte';
33
import { registerReactControllerComponents } from '@symfony/ux-react';
44
import './bootstrap.js';
5+
import { trans } from "./translator.js";
6+
57
/*
68
* Welcome to your app's main JavaScript file!
79
*
@@ -16,3 +18,5 @@ console.log('This log comes from assets/app.js - welcome to AssetMapper! 🎉');
1618
registerReactControllerComponents();
1719
registerSvelteControllerComponents();
1820
registerVueControllerComponents();
21+
22+
export { trans }

apps/e2e/assets/translator.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { localeFallbacks } from '@app/translations/configuration';
2-
import { trans, getLocale, setLocale, setLocaleFallbacks } from '@symfony/ux-translator';
1+
import { createTranslator } from "@symfony/ux-translator";
2+
import { messages, localeFallbacks } from "../var/translations/index.js";
3+
34
/*
45
* This file is part of the Symfony UX Translator package.
56
*
@@ -9,8 +10,9 @@ import { trans, getLocale, setLocale, setLocaleFallbacks } from '@symfony/ux-tra
910
* If you use TypeScript, you can rename this file to "translator.ts" to take advantage of types checking.
1011
*/
1112

12-
setLocaleFallbacks(localeFallbacks);
13-
14-
export { trans };
13+
export const translator = createTranslator({
14+
messages,
15+
localeFallbacks,
16+
})
1517

16-
export * from '@app/translations';
18+
export const { trans, setLocale } = translator;

apps/e2e/importmap.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,6 @@
139139
'@symfony/ux-translator' => [
140140
'path' => './vendor/symfony/ux-translator/assets/dist/translator_controller.js',
141141
],
142-
'@app/translations' => [
143-
'path' => './var/translations/index.js',
144-
],
145-
'@app/translations/configuration' => [
146-
'path' => './var/translations/configuration.js',
147-
],
148142
'typed.js' => [
149143
'version' => '2.1.0',
150144
],

apps/e2e/templates/ux_translator/basic.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111
{% block javascripts %}
1212
{{ parent() }}
1313
<script type="module">
14-
import { trans } from '@symfony/ux-translator';
15-
import { HELLO } from '@app/translations';
14+
import { trans } from 'app';
1615
1716
function render() {
1817
document.querySelector('[data-testid="output"]').innerHTML = `
1918
<h2>Output</h2>
2019
<ul >
21-
<li>🇬🇧 ${trans(HELLO, {}, 'messages', 'en')}</li>
22-
<li>🇫🇷 ${trans(HELLO, {}, 'messages', 'fr')}</li>
20+
<li>🇬🇧 ${trans('hello', {}, 'messages', 'en')}</li>
21+
<li>🇫🇷 ${trans('hello', {}, 'messages', 'fr')}</li>
2322
</ul>
2423
`
2524
}

apps/e2e/templates/ux_translator/icu_date_time.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
{% block javascripts %}
1616
{{ parent() }}
1717
<script type="module">
18-
import { trans } from '@symfony/ux-translator';
19-
import { PUBLISHED_AT } from '@app/translations';
18+
import { trans } from 'app';
2019
2120
const inputDate = document.querySelector('#date');
2221
2322
function render() {
2423
document.querySelector('[data-testid="output"]').innerHTML = `
2524
<h2>Output</h2>
2625
<ul >
27-
<li>🇬🇧 ${trans(PUBLISHED_AT, { publication_date: new Date(inputDate.value) }, 'messages', 'en')}</li>
28-
<li>🇫🇷 ${trans(PUBLISHED_AT, { publication_date: new Date(inputDate.value) }, 'messages', 'fr')}</li>
26+
<li>🇬🇧 ${trans('published_at', { publication_date: new Date(inputDate.value) }, 'messages', 'en')}</li>
27+
<li>🇫🇷 ${trans('published_at', { publication_date: new Date(inputDate.value) }, 'messages', 'fr')}</li>
2928
</ul>
3029
`
3130
}

apps/e2e/templates/ux_translator/icu_number_currency.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
{% block javascripts %}
1616
{{ parent() }}
1717
<script type="module">
18-
import { trans } from '@symfony/ux-translator';
19-
import { VALUE_OF_OBJECT } from '@app/translations';
18+
import { trans } from 'app';
2019
2120
const inputPrice = document.querySelector('#price');
2221
2322
function render() {
2423
document.querySelector('[data-testid="output"]').innerHTML = `
2524
<h2>Output</h2>
2625
<ul >
27-
<li>🇬🇧 ${trans(VALUE_OF_OBJECT, { price: inputPrice.value }, 'messages', 'en')}</li>
28-
<li>🇫🇷 ${trans(VALUE_OF_OBJECT, { price: inputPrice.value }, 'messages', 'fr')}</li>
26+
<li>🇬🇧 ${trans('value_of_object', { price: inputPrice.value }, 'messages', 'en')}</li>
27+
<li>🇫🇷 ${trans('value_of_object', { price: inputPrice.value }, 'messages', 'fr')}</li>
2928
</ul>
3029
`
3130
}

apps/e2e/templates/ux_translator/icu_number_percent.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
{% block javascripts %}
1616
{{ parent() }}
1717
<script type="module">
18-
import { trans } from '@symfony/ux-translator';
19-
import { PROGRESS } from '@app/translations';
18+
import { trans } from 'app';
2019
2120
const inputProgress = document.querySelector('#progress');
2221
2322
function render() {
2423
document.querySelector('[data-testid="output"]').innerHTML = `
2524
<h2>Output</h2>
2625
<ul >
27-
<li>🇬🇧 ${trans(PROGRESS, { progress: inputProgress.value }, 'messages', 'en')}</li>
28-
<li>🇫🇷 ${trans(PROGRESS, { progress: inputProgress.value }, 'messages', 'fr')}</li>
26+
<li>🇬🇧 ${trans('progress', { progress: inputProgress.value }, 'messages', 'en')}</li>
27+
<li>🇫🇷 ${trans('progress', { progress: inputProgress.value }, 'messages', 'fr')}</li>
2928
</ul>
3029
`
3130
}

apps/e2e/templates/ux_translator/icu_plural.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,16 @@
1515
{% block javascripts %}
1616
{{ parent() }}
1717
<script type="module">
18-
import { trans } from '@symfony/ux-translator';
19-
import { NUM_OF_APPLES } from '@app/translations';
18+
import { trans } from 'app';
2019
2120
const inputApples = document.querySelector('#apples');
2221
2322
function render() {
2423
document.querySelector('[data-testid="output"]').innerHTML = `
2524
<h2>Output</h2>
2625
<ul >
27-
<li>🇬🇧 ${trans(NUM_OF_APPLES, { apples: inputApples.valueAsNumber }, 'messages', 'en')}</li>
28-
<li>🇫🇷 ${trans(NUM_OF_APPLES, { apples: inputApples.valueAsNumber }, 'messages', 'fr')}</li>
26+
<li>🇬🇧 ${trans('num_of_apples', { apples: inputApples.valueAsNumber }, 'messages', 'en')}</li>
27+
<li>🇫🇷 ${trans('num_of_apples', { apples: inputApples.valueAsNumber }, 'messages', 'fr')}</li>
2928
</ul>
3029
`
3130
}

apps/e2e/templates/ux_translator/icu_select.html.twig

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,16 @@
2020
{% block javascripts %}
2121
{{ parent() }}
2222
<script type="module">
23-
import { trans } from '@symfony/ux-translator';
24-
import { INVITATION_TITLE } from '@app/translations';
23+
import { trans } from 'app';
2524
2625
const selectGender = document.querySelector('#gender');
2726
2827
function render() {
2928
document.querySelector('[data-testid="output"]').innerHTML = `
3029
<h2>Output</h2>
3130
<ul >
32-
<li>🇬🇧 ${trans(INVITATION_TITLE, { organizer_gender: selectGender.value, organizer_name: 'Alex' }, 'messages', 'en')}</li>
33-
<li>🇫🇷 ${trans(INVITATION_TITLE, { organizer_gender: selectGender.value, organizer_name: 'Alex' }, 'messages', 'fr')}</li>
31+
<li>🇬🇧 ${trans('invitation_title', { organizer_gender: selectGender.value, organizer_name: 'Alex' }, 'messages', 'en')}</li>
32+
<li>🇫🇷 ${trans('invitation_title', { organizer_gender: selectGender.value, organizer_name: 'Alex' }, 'messages', 'fr')}</li>
3433
</ul>
3534
`
3635
}

0 commit comments

Comments
 (0)