當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。