Skip to content

Commit d028853

Browse files
authored
Update create-i18n.md (#37)
- Improved the description of arguments to the add(items, locale, prefix) function; - Added a table describing allowed arguments to the setPluralizationRule(locale, rule, options) function.
1 parent 434d3d2 commit d028853

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/i18n/create-i18n.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ The following arguments can be passed to the `add()` method.
4040

4141
| Argument | Type | Required | Description |
4242
| --- | --- | --- | --- |
43-
| `items` | `object` | Yes | The object containing messages |
43+
| `items` | `object` | Yes | The object containing messages. The value of each message can be a simple string or, in the case of pluralized messages, an array of strings. |
4444
| `locale` | `string` | | An optional locale for the messages. For example `es`. The default is `en` |
45-
| `prefix` | `string` | | An optional prefix for the messages |
45+
| `prefix` | `string` | | An optional prefix for the messages. It will be automatically prepended to each item's key. |
4646

4747
Pluralization is set by adding an array of messages to the `items` object.
4848

@@ -155,6 +155,12 @@ const value = i18n.t('welcomeMessage', { userName: 'George' })
155155

156156
The `setPluralizationRule()` method sets a locale-specific pluralization rule function to determine plural form variation index.
157157

158+
| Argument | Type | Required | Description |
159+
| --- | --- | --- | --- |
160+
| `locale` | `string` | Yes | The locale that the `rule` function is defined for |
161+
| `rule` | `function` | Yes | A locale-specific function that receive a count as parameter and returns an index into the array of pluralized translated messages |
162+
| `options` | `object` | | An optional set of locale-specific options for the pluralization rule |
163+
158164
```js
159165
i18n.setPluralizationRule('en', function (count) {
160166
return (1 === count) ? 0 : 1

0 commit comments

Comments
 (0)