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
fix: Emit INVALID_TOKEN_IN_PLACEHOLDER instead of UNTERMINATED_CLOSING_BRACE when invalid token is in placeholder and update docs (#2255)
* Emit INVALID_TOKEN_IN_PLACEHOLDER instead of UNTERMINATED_CLOSING_BRACE when invalid token is in placeholder and update docs (#2252)
* chore: drop node v18
---------
Co-authored-by: lutejka <[email protected]>
Copy file name to clipboardExpand all lines: docs/guide/essentials/syntax.md
+71Lines changed: 71 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,6 +26,10 @@ The locale messages is the resource specified by the `messages` option of `creat
26
26
27
27
Named interpolation allows you to specify variables defined in JavaScript. In the locale message above, you can localize it by giving the JavaScript defined `msg` as a parameter to the translation function.
28
28
29
+
The variable name inside `{}` must starts with a letter (a-z, A-Z) or an underscore (`_`), followed by any combination of letters, digits, underscores (`_`), hyphens (`-`), or dollar signs (`$`).
In this case, the values for `{0}` and `{1}` are passed as an array. The keys `name` and `day` are resolved using list interpolation and transformed with modifiers.
288
+
289
+
```html
290
+
<p>{{ $t('welcome', ['bob', 'MONDAY']) }}</p>
291
+
```
292
+
293
+
As result, the below
294
+
295
+
```html
296
+
<p>Welcome, BOB! Today is Monday.</p>
297
+
```
298
+
299
+
### Literal interpolation with modifier
300
+
301
+
In this example, we use a literal string inside the message and apply the `.lower` modifier.
302
+
303
+
```html
304
+
<p>{{ $t('literalMessage') }}</p>
305
+
```
306
+
307
+
Here, the modifier is applied to the content inside `domain`, and the `@` is preserved as literal output.
308
+
309
+
As result, the below
310
+
311
+
```html
312
+
<p>This is an email: foo@shouting</p>
313
+
```
314
+
244
315
## Special Characters
245
316
246
317
The following characters used in the message format syntax are processed by the compiler as special characters:
0 commit comments