本文整理汇总了TypeScript中i18next.init函数的典型用法代码示例。如果您正苦于以下问题:TypeScript init函数的具体用法?TypeScript init怎么用?TypeScript init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: initTest
function initTest() {
const i18nextOptions = {};
i18next
.use(sprintfA)
.use(sprintfB)
.init(i18nextOptions);
i18next
.init({ overloadTranslationOptionHandler: sprintfA.overloadTranslationOptionHandler });
i18next
.init({ overloadTranslationOptionHandler: sprintfB.overloadTranslationOptionHandler });
}
开发者ID:0815fox,项目名称:DefinitelyTyped,代码行数:11,代码来源:i18next-sprintf-postprocessor-tests.ts
示例2: resolve
web.lists.getById(_spPageContextInfo.pageListId.replace(/{|}/g, "")).items.getById(_spPageContextInfo.pageItemId).select("IntranetContentLanguage").get().then((item) => {
const itemLanguage: string = item.IntranetContentLanguage;
// Default language for the intranet
let workingLanguage: string = "en";
if (itemLanguage) {
workingLanguage = itemLanguage.toLowerCase();
}
i18n.init({
// Init the working language and resource files for the entire application
fallbackLng: "en",
lng: workingLanguage,
resources: {
en: {
translation: enUSResources,
},
fr: {
translation: frFRResources,
},
},
}, (err, t) => {
resolve();
});
});
开发者ID:ScoutmanPt,项目名称:PnP,代码行数:30,代码来源:LocalizationModule.ts
示例3: Promise
return new Promise((resolve, reject) => {
// See https://github.com/i18next/ng-i18next
i18use(XHR);
i18init(
{
initImmediate: true,
debug: $DIM_FLAVOR === 'dev',
lng: defaultLanguage(),
fallbackLng: 'en',
lowerCaseLng: true,
load: 'currentOnly',
interpolation: {
escapeValue: false,
format(val, format) {
if (format === 'pct') {
return percent(parseFloat(val));
} else if (format === 'humanBytes') {
return humanBytes(parseInt(val, 10));
}
return val;
}
},
backend: {
loadPath(lng) {
const path = {
en,
it,
de,
fr,
es,
'es-mx': esMX,
ja,
'pt-br': ptBR,
pl,
ru,
ko,
'zh-cht': zhCHT,
'zh-chs': zhCHS
}[lng];
if (!path) {
throw new Error(`unsupported language ${lng}`);
}
return path;
}
},
returnObjects: true
},
(error) => {
if (error) {
reject(error);
} else {
resolve();
}
}
);
});
开发者ID:w1cked,项目名称:DIM,代码行数:56,代码来源:i18n.ts
示例4: revertToEnglish
export async function revertToEnglish() {
init(await detectLanguage("en"), noop);
}
开发者ID:RickCarlino,项目名称:farmbot-web-app,代码行数:3,代码来源:revert_to_english.ts
示例5: getConfigRoot
import * as i18next from 'i18next';
import { en, ja } from './stringResources';
import { getConfigRoot } from './configUtil';
let lng = 'en';
try {
lng = getConfigRoot().language;
} catch (ex) {
console.log(ex.message);
}
i18next.init({
lng,
fallbackLng: 'en',
resources: {
en: {
translation: en
},
ja: {
translation: ja
}
}
});
export default function translateTaggedTemplate(strings: TemplateStringsArray, ...keys: string[]): string {
return i18next.t(strings.raw[0]);
}
开发者ID:tangkaisky,项目名称:r2,代码行数:28,代码来源:intl.ts
示例6:
import * as i18next from 'i18next';
i18next.init({
lng: "en",
debug: true,
resources: {
en: {
translation: {
key: "hello world"
}
}
}
}, (err: any, t: i18next.TranslationFunction) => {
// initialized and ready to go!
const value: string = i18next.t('key');
});
i18next.init({ initImmediate: false });
i18next.init({
lng: 'en',
debug: true,
resources: {
en: {
translation: {
key: "hello world"
}
},
de: {
translation: {
key: "hello welt"
开发者ID:AbraaoAlves,项目名称:DefinitelyTyped,代码行数:31,代码来源:i18next-tests.ts
示例7:
import * as i18n from "i18next";
import * as LanguageDetector from "i18next-browser-languagedetector";
import * as XHR from "i18next-xhr-backend";
i18n.use(XHR);
i18n.use(LanguageDetector);
i18n.init({
defaultNS: "dashboard",
fallbackLng: "en",
interpolation: {
escapeValue: false
},
keySeparator: false,
ns: ["dashboard"],
nsSeparator: false
});
export default i18n;
开发者ID:elwoodxblues,项目名称:saleor,代码行数:18,代码来源:i18n.ts
示例8: function
ns: "general",
nsseparator: "::",
resStore: translations,
returnObjectTrees: true,
};
if(__DEV__) {
var missingKeys = {};
i18nOptions.sendMissing = true;
i18nOptions.missingKeyHandler = function(lng, ns, key, all) {
if(!missingKeys[all]) {
console.warn(
"Missing localized key: lng: %s, namespace: %s, key: %s. args:",
lng, ns, key, arguments
);
missingKeys[all] = arguments;
}
}
}
i18n.init(i18nOptions, function(){
// Post processor to capitalize the first letter of a key.
i18n.addPostProcessor("ucfirst", function(translated) {
return translated.charAt(0).toUpperCase() + translated.slice(1);
});
synchronizeLanguage(i18n.lng());
});
export var __ = i18n.t;
开发者ID:my-koop,项目名称:service.website,代码行数:30,代码来源:language.ts
示例9:
import * as i18next from 'i18next'
import * as moment from 'moment-timezone'
import { default as zh } from '../../../common/locales/zh'
import { default as en } from '../../../common/locales/en'
i18next
.init({
lng: 'zh',
fallbackLng: 'en',
ns: ['base', 'api', 'consumer'],
defaultNS: 'api',
resources: {
zh,
en
}
})
.on('languageChanged', (lng) => {
moment.locale(lng)
})
export { i18next }
开发者ID:yeegr,项目名称:SingularJS,代码行数:22,代码来源:lang.ts
示例10: getConfigRoot
import * as i18next from 'i18next';
import { en, ja } from './stringResources';
import { getConfigRoot } from './configUtil';
i18next.init({
lng: getConfigRoot().language,
fallbackLng: 'en',
resources: {
en: {
translation: en
},
ja: {
translation: ja
}
}
});
export default function translateTaggedTemplate(strings: TemplateStringsArray, ...keys: string[]): string {
return i18next.t(strings.raw[0]);
}
开发者ID:HarryTmetic,项目名称:r2,代码行数:20,代码来源:intl.ts
注:本文中的i18next.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论