UNPKG

1.05 kBJavaScriptView Raw
1/** Copyright (c) 2018 Uber Technologies, Inc.
2 *
3 * This source code is licensed under the MIT license found in the
4 * LICENSE file in the root directory of this source tree.
5 *
6 * @flow
7 */
8
9import {createToken} from 'fusion-core';
10import type {FusionPlugin, Token} from 'fusion-core';
11
12import serverPlugin from './node';
13import clientPlugin, {HydrationStateToken} from './browser';
14import serverLoader from './loader';
15import type {
16 I18nDepsType,
17 I18nServiceType,
18 TranslationsObjectType,
19 TranslateFuncType,
20} from './types.js';
21import {I18nLoaderToken} from './tokens.js';
22
23const I18nToken: Token<I18nServiceType> = createToken('I18nToken');
24
25const plugin: FusionPlugin<I18nDepsType, I18nServiceType> = __NODE__
26 ? serverPlugin
27 : clientPlugin;
28
29const createI18nLoader: typeof serverLoader = __NODE__
30 ? serverLoader
31 : (void 0: any);
32
33export type {
34 I18nDepsType,
35 I18nServiceType,
36 TranslationsObjectType,
37 TranslateFuncType,
38};
39export default plugin;
40export {I18nToken, I18nLoaderToken, HydrationStateToken, createI18nLoader};