本文整理汇总了TypeScript中sprintf-js.vsprintf函数的典型用法代码示例。如果您正苦于以下问题:TypeScript vsprintf函数的具体用法?TypeScript vsprintf怎么用?TypeScript vsprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vsprintf函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: localize
export function localize(key: string, ...args: string[]): string {
let localizedString;
try {
const identifier = utils.ad.resources.getStringId(encodeKey(key));
localizedString = identifier === 0 ? key : getResources().getString(identifier);
} catch (error) {
localizedString = key;
}
return vsprintf(localizedString, args);
}
示例2: getTranslation
private getTranslation(code:string, fallback: string, parameters: string[]):string{
var translation: any;
// If exist custom translate function - call
if(typeof this.config.onTranslate === 'function'){
translation = this.config.onTranslate(code, fallback);
}
// If not translated - get translation from passed translations
if(typeof translation != 'string'){
translation = this.translationsByCode[code];
}
// If not fount translations - use fallback
translation === undefined && (translation = fallback);
// If pass parameters - render with sprintf
parameters && (translation = vsprintf(translation, parameters));
return translation;
}
示例3: strFormat
static strFormat(str:string, params: Array<string>){
if(typeof params == "string"){
params = [params];
}
return vsprintf(str, params);
}
示例4: L
export function L(str: string, ...params): string {
var s = (language[window['selectedLanguage']] || {})[str];
if (s==null) s = str;
if (0 < params.length) s = vsprintf(s, params);
return s;
}
示例5: localize
export function localize(key: string, ...args: string[]): string {
const localizedString = getBundle().localizedStringForKeyValueTable(encodeKey(key), key, null);
return vsprintf(convertAtSignToStringSign(localizedString), args);
}