You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Presets can also contain variables that can be substituted by using the translation system. Take the following example where you have a preset showing a personalised welcome message to the user.
292
+
293
+
```php
294
+
<?php // config/flasher.php
295
+
296
+
return [
297
+
'presets' => [
298
+
'hello_user' => [
299
+
'type' => '{{ type }}',
300
+
'message' => 'welcome_back_user',
301
+
],
302
+
],
303
+
];
304
+
```
305
+
306
+
In the translations file you can define `welcome_back_user` with the message containing the variable `:username`.
If you want to substitute the `:username` in the above translation with a username in the controller, you can achieve this by passing an array of values to be substituted as the second argument.
Presets can also contain variables that can be substituted by using the translation system. Take the following example where you have a preset showing a personalised welcome message to the user.
272
+
273
+
```yaml
274
+
# config/packages/flasher.yaml
275
+
276
+
flasher:
277
+
presets:
278
+
hello_user:
279
+
type: {{ type }}
280
+
message: welcome_back_user
281
+
```
282
+
283
+
In the translations file you can define `welcome_back_user` with the message containing the variable `:username`.
284
+
285
+
```yaml
286
+
# translations/flasher.en.yaml
287
+
288
+
welcome_back_user: Welcome back :username
289
+
```
290
+
291
+
If you want to substitute the `:username` in the above translation with a username in the controller, you can achieve this by passing an array of values to be substituted as the second argument.
0 commit comments