in scripts/generateTemplates.js [231:281]
function processGalleryFile(galleryPath, rootDirectory, fileName, galleryData) {
try {
// Assign file names
if (galleryData && galleryData.categories) {
galleryData.categories.forEach(category => {
category.templates.forEach(template => {
const templateId = template.id;
const templatePath = rootDirectory.endsWith("\\") ? rootDirectory.concat("\\", templateId) : rootDirectory.concat(templateId);
assignFileName(templatePath, rootDirectory, template);
});
});
}
var path = getPackageOutputPath(galleryPath, rootDirectory);
if (galleryPath.endsWith("cohorts")) {
path = path.replace("gallery\\", "Cohorts\\");
} else {
path = path.replace("gallery\\", "Workbooks\\");
}
const p = path.substr(0, path.lastIndexOf('\\'));
const subDir = path.split("\\").pop();
const workbookType = subDir.substr(0, subDir.lastIndexOf('.'));
path = p.concat("\\", GalleryFilePrefix, workbookType, "-", fileName);
// Location of translated RESJSON outputted by the localization build
const translatedRESJSONPath = getClonedLocFilePath(galleryPath, rootDirectory, WorkbookFileType.Gallery, fileName);
// Generate localized templates
languages.forEach(lang => {
// Location of translated resjson
const localizedFilePath = translatedRESJSONPath.replace(LangOutputSpecifier, lang);
// Location of package for translated gallery file
const translatedResultPath = path.replace(LangOutputSpecifier, LanguagesMap[lang]);
if (lang === DefaultLang) {
writeTranslatedFile(galleryData, translatedResultPath);
} else {
if (fs.existsSync(localizedFilePath)) {
// Do workbook string replacement here
const jsonData = fs.readFileSync(localizedFilePath, Encoding);
parseTemplateResult(jsonData, galleryData, translatedResultPath);
} else {
// No loc file found, just push the workbook file as is in English
logMessage("Did not find localized file in: " + localizedFilePath);
writeTranslatedFile(galleryData, translatedResultPath);
}
}
});
} catch (e) {
logError("Failed to process gallery file: " + galleryPath + "Error: " + e, true);
}
}