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
This hook exposes a `formatList` function which can be used to format lists of strings.
215
+
216
+
The first parameter is an array of strings to format.
217
+
218
+
It accepts an `options` as second parameter which is an [Intl.ListFormat `options` object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/ListFormat/ListFormat).
219
+
220
+
```js
221
+
import { useI18n } from'@scaleway/use-i18n'
222
+
223
+
constApp= () => {
224
+
const { formatList } =useI18n()
225
+
226
+
constcities= [
227
+
formatList(['Paris', 'New York', 'London']), // Paris, New York and London
228
+
formatList(['Paris', 'New York', 'London'], {
229
+
type:'disjunction'
230
+
}) // Paris, New York or London
231
+
]
232
+
233
+
return (
234
+
<div>
235
+
{cities}
236
+
</div>
237
+
)
238
+
}
239
+
```
240
+
212
241
### formatUnit
213
242
214
243
This hook also exposes a `formatUnit` function which can be used to format bits/bytes until [ECMA-402 Unit Preferences](https://github.com/tc39/proposal-smart-unit-preferences) is standardised
@@ -229,8 +258,8 @@ const App = () => {
229
258
const { formatUnit } =useI18n()
230
259
231
260
constunits= [
232
-
formatUnit(12, { unit:'kilobyte' }) // "12 KB" or "12 Ko" in fr an ro
233
-
formatUnit(10**8, { unit:'bytes-humanized' }) // "100 MB" or "100 Mo" in fr an ro
261
+
formatUnit(12, { unit:'kilobyte' }),// "12 KB" or "12 Ko" in fr an ro
262
+
formatUnit(10**8, { unit:'bytes-humanized' }),// "100 MB" or "100 Mo" in fr an ro
0 commit comments