Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function updateTemplateEngine(uri: vscode.Uri) {
let engine: TemplateEngine = new TemplateEngine();
try {
engine = engine.addFile(uri.fsPath);
}
catch(e)
{
// ignore it
//vscode.window.showWarningMessage(e.message);
}
DataStorage.templateEngineMap.set(uri.fsPath, new TemplateEngineEntity(uri, engine));
}
private initTemplateEngine(turnContext: TurnContext): TemplateEngine {
const locale = turnContext.activity.locale? turnContext.activity.locale.toLocaleLowerCase() : '';
if (this.multiLangEngines.size > 0) {
const fallbackLocale = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(this.multiLangEngines.keys()));
this.engine = this.multiLangEngines.get(fallbackLocale);
} else {
this.engine = this.engine? this.engine : new TemplateEngine();
}
return this.engine;
}
}
public constructor(lgText?: string | TemplateEngine, id?: string, resourceMapping?: Map) {
if (typeof lgText === 'string' && id !== undefined && resourceMapping !== undefined) {
this.id = id !== undefined? id : this.DEFAULTLABEL;
const {prefix: _, language: locale} = MultiLanguageResourceLoader.parseLGFileName(id);
const fallbackLocale: string = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(resourceMapping.keys()));
for (const mappingKey of resourceMapping.keys()) {
if (fallbackLocale === '' || fallbackLocale === mappingKey) {
const engine = new TemplateEngine().addText(lgText !== undefined? lgText : '', id, LanguageGeneratorManager.resourceExplorerResolver(mappingKey, resourceMapping));
this.multiLangEngines.set(mappingKey, engine);
}
}
} else if (lgText instanceof TemplateEngine) {
this.engine = lgText;
} else {
this.engine = new TemplateEngine();
}
}
public constructor(lgText?: string | TemplateEngine, id?: string, resourceMapping?: Map) {
if (typeof lgText === 'string' && id !== undefined && resourceMapping !== undefined) {
this.id = id !== undefined? id : this.DEFAULTLABEL;
const {prefix: _, language: locale} = MultiLanguageResourceLoader.parseLGFileName(id);
const fallbackLocale: string = MultiLanguageResourceLoader.fallbackLocale(locale.toLocaleLowerCase(), Array.from(resourceMapping.keys()));
for (const mappingKey of resourceMapping.keys()) {
if (fallbackLocale === '' || fallbackLocale === mappingKey) {
const engine = new TemplateEngine().addText(lgText !== undefined? lgText : '', id, LanguageGeneratorManager.resourceExplorerResolver(mappingKey, resourceMapping));
this.multiLangEngines.set(mappingKey, engine);
}
}
} else if (lgText instanceof TemplateEngine) {
this.engine = lgText;
} else {
this.engine = new TemplateEngine();
}
}