Skip to content

Commit afcb2d9

Browse files
committed
Update Encore app
1 parent b41fe6a commit afcb2d9

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

apps/encore/assets/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import './bootstrap.js';
1111

1212
// any CSS you import will output into a single css file (app.css in this case)
1313
import './styles/app.css';
14-
import { THIS_FIELD_IS_MISSING, trans } from './translator';
14+
import { trans } from './translator';
1515

1616
registerReactControllerComponents(require.context('./react/controllers', true, /\.(j|t)sx?$/));
1717
registerSvelteControllerComponents(require.context('./svelte/controllers', true, /\.svelte$/));
1818
registerVueControllerComponents(require.context('./vue/controllers', true, /\.vue$/));
1919

2020
document.addEventListener('DOMContentLoaded', () => {
21-
console.log(trans(THIS_FIELD_IS_MISSING));
21+
console.log(trans('say_hello', { name: 'Fabien'}));
2222
})

apps/encore/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 '../var/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 '../var/translations';
18+
export const { trans, setLocale } = translator;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
say_hello: 'Hello {name}!'

0 commit comments

Comments
 (0)