本文整理匯總了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');