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
{{ message }}
This repository was archived by the owner on Dec 31, 2024. It is now read-only.
⭐ new(interpolation): list formatting refactor and places/place feature (#218) by @myst729
* fix: test case typo
* improvement(interpolation): enable array-like named values for list tokens
* feature(component): place and places prop for component interpolation
* docs(formatting): enable array-like object values for list formatting
* docs(component): named formatting with place/places
Copy file name to clipboardExpand all lines: gitbook/en/interpolation.md
+78-1Lines changed: 78 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,4 +85,81 @@ About the above example, see the [example](https://github.com/kazupon/vue-i18n/t
85
85
86
86
The children of `i18n` functional component is interpolated with locale message of `path` prop. In the above example, `<a :href="url" target="_blank">{{ $t('tos') }}</a>` is interplated with `term` locale message.
87
87
88
-
The component interpolations follows the **list formatting**. The named formatting is not support. The children of `i18n` functional component is interpolated with order of list formatting.
88
+
In above example, the component interpolation follows the **list formatting**. The children of `i18n` functional component are interpolated by their orders of appearance.
89
+
90
+
> :warning: NOTE: In `i18n` component, text content consists of only white spaces will be omitted.
91
+
92
+
Named formatting is supported with the help of `place` attribute. For example:
info:'You can {action} until {limit} minutes from departure.',
109
+
change:'change your flight',
110
+
refund:'refund the ticket'
111
+
}
112
+
}
113
+
114
+
consti18n=newVueI18n({
115
+
locale:'en',
116
+
messages
117
+
})
118
+
newVue({
119
+
i18n,
120
+
data: {
121
+
changeUrl:'/change',
122
+
refundUrl:'/refund',
123
+
changeLimit:15,
124
+
refundLimit:30
125
+
}
126
+
}).$mount('#app')
127
+
```
128
+
129
+
Outputs:
130
+
131
+
```html
132
+
<divid="app">
133
+
<!-- ... -->
134
+
<p>
135
+
You can <ahref="/change">change your flight</a> until <span>15</span> minutes from departure.
136
+
</p>
137
+
<!-- ... -->
138
+
</div>
139
+
```
140
+
141
+
> :warning: NOTE: To use named formatting, all children of `i18n` component must have `place` attribute set. Otherwise it will fallback to list formatting.
142
+
143
+
If you still want to interpolate text content in named formatting, you could define `places` property on `i18n` component. For example:
0 commit comments