Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit 0b73dce

Browse files
alxmythfusion-bot[bot]
authored and
fusion-bot[bot]
committed
Add Token dependencies to readme
#85
1 parent 7561d15 commit 0b73dce

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

README.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -176,23 +176,27 @@ Usage:
176176
#### Dependency registration
177177

178178
```js
179-
import I18n, {I18nToken, I18nLoaderToken} from 'fusion-plugin-i18n-react';
179+
import {I18nLoaderToken, HydrationStateToken} from 'fusion-plugin-i18n';
180180
import {FetchToken} from 'fusion-tokens';
181181

182-
app.register(I18nToken, I18n);
183-
__NODE__
184-
? app.register(I18nLoaderToken, I18nLoader);
185-
: app.register(FetchToken, fetch);
182+
__NODE__ && app.register(I18nLoaderToken, I18nLoader);
183+
__BROWSER__ && app.register(FetchToken, fetch);
184+
185+
// some-test.js
186+
__BROWSER__ && app.register(HydrationStateToken, hydrationState);
186187
```
187188

188-
- `I18n` - the core I18n library
189-
- `I18nLoader: (ctx: Context) => ({locale: string, translations: Object<string, string>})` - A function that provides translations
190-
- `ctx: FusionContext` - A [FusionJS context](https://github.com/fusionjs/fusion-core#context) object.
191-
- `fetch` - a [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) implementation
189+
##### Optional dependencies
190+
191+
Name | Type | Default | Description
192+
-|-|-|-
193+
`I18nLoaderToken` | `{from: (ctx: Context) => ({locale: string, translations: Object<string, string>})}` | `createI18nLoader()` | A function that provides translations. `ctx: {headers: {'accept-language': string}}` is a Koa context object. Server-side only.
194+
`HydrationStateToken` | `{chunks: Array, translations: Object}` | `undefined` | Sets the hydrated state in the client, and can be useful for testing purposes. Browser only.
195+
`FetchToken` | `(url: string, options: Object) => Promise` | `window.fetch` | A [`fetch`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) implementation. Browser-only.
192196

193197
#### Factory
194198

195-
`const i18n = I18n(ctx)`
199+
`const i18n = I18n.from(ctx)`
196200

197201
- `ctx: FusionContext` - Required. A [FusionJS context](https://github.com/fusionjs/fusion-core#context) object.
198202

0 commit comments

Comments
 (0)