本文整理汇总了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
);
});
示例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 };
示例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');
示例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');