当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript core.setupI18n函数代码示例

本文整理汇总了TypeScript中@lingui/core.setupI18n函数的典型用法代码示例。如果您正苦于以下问题:TypeScript setupI18n函数的具体用法?TypeScript setupI18n怎么用?TypeScript setupI18n使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setupI18n函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: beforeAll

  beforeAll(() => {
    const container = new Container();
    const i18n = setupI18n();
    i18n._ = (id: string) => id;
    container.bind(TYPES.I18n).toConstantValue(i18n);
    container.bind(NotificationServiceType).toConstantValue(mockNS);
    loadNotifications(container);

    notifications = container.get<UIUpdateNotifications>(
      UIUpdateNotificationsType
    );
  });
开发者ID:dcos,项目名称:dcos-ui,代码行数:12,代码来源:notifications-test.ts

示例2: setupI18n

import { setupI18n } from "@lingui/core";

import UserLanguageStore from "./stores/UserLanguageStore";

import en from "#LOCALE/en/messages";
import zh from "#LOCALE/zh/messages";

const catalogs = { en, zh };
const language = UserLanguageStore.get();
const i18n = setupI18n({ language, catalogs });

export { catalogs, i18n };
开发者ID:dcos,项目名称:dcos-ui,代码行数:12,代码来源:i18n.ts

示例3: age

const selectIdResult = i18n.select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
});

const catalog: Catalog = {
    messages: {
        age(a) {
            return [a('age'), 'aĂąos de edad'];
        }
    }
};

function missingFn(language: string, id: string) {
   return id;
}

const catalogs: Catalogs = { es: catalog };
const setupResult: I18n = setupI18n({ catalogs, language: 'es' });
const setupResultLocales: I18n = setupI18n({ locales: ['en-UK', 'ar-AS'] });
const setupResultMissingText: I18n = setupI18n({ missing: 'missing' });
const setupResultMissingFn: I18n = setupI18n({ missing: missingFn });
const setupResultCombined: I18n = setupI18n({ catalogs, language: 'de', locales: ['en-UK', 'ar-AS'], missing: missingFn });

const formattedDate: string = date('en', { timeZone: 'UTC' })(new Date());
const formattedNumber: string = number('en', { style: 'currency', currency: 'EUR' })(1234.56);

const mark: string = i18nMark('mark');
开发者ID:ChaosinaCan,项目名称:DefinitelyTyped,代码行数:30,代码来源:lingui__core-tests.ts

示例4: age

        0: i18n.t`${host} does not give a party.`,
        1: i18n.t`${host} invites ${guest} to her party.`,
        2: i18n.t`${host} invites ${guest} and one other person to her party.`,
        other: i18n.t`${host} invites ${guest} and # other people to her party.`
    }),
    male: 'male',
    other: 'other'
});

const selectIdResult = i18n.select('selectId', {
    value: gender,
    female: 'female',
    male: 'male',
    other: 'other'
});

const catalog: Catalog = {
    messages: {
        age(a) {
            return [a('age'), 'aĂąos de edad'];
        }
    }
};
const catalogs: Catalogs = { es: catalog };
const setupResult: I18n = setupI18n({ catalogs, language: 'es' });

const formattedDate: string = date('en', { timeZone: 'UTC' })(new Date());
const formattedNumber: string = number('en', { style: 'currency', currency: 'EUR' })(1234.56);

const mark: string = i18nMark('mark');
开发者ID:Igorbek,项目名称:DefinitelyTyped,代码行数:30,代码来源:lingui__core-tests.ts


注:本文中的@lingui/core.setupI18n函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。