def applyTranslations(self, allTranslations, locale, moduleName, content, escaping): for match in re.finditer(r"\[\[([a-zA-Z0-9_]+)\]\]", content): key = match.group(1) if not key in allTranslations: raise BuildError("Undefined text key %s in module %s" % (key, moduleName)) translations = allTranslations[key] if not locale in translations: raise BuildError("Translation not provided for text key %s and locale %s" % (key, locale)) value = translations[locale] if escaping == "html": value = buildutil.htmlEscape(value) elif escaping == "javascript": value = json.dumps(value) if len(value) > 1: value = value[1:-1] # strip of the quotes on both sides else: raise BuildError("Unrecognized escaping type %s" % escaping) content = content.replace("[[%s]]" % key, value) return content
def applyTranslations(self, allTranslations, locale, moduleName, content, escaping): for match in re.finditer(r"\[\[([a-zA-Z0-9_]+)\]\]", content): key = match.group(1) if not key in allTranslations: raise BuildError("Undefined text key %s in module %s" % (key, moduleName)) translations = allTranslations[key] if not locale in translations: raise BuildError( "Translation not provided for text key %s and locale %s" % (key, locale)) value = translations[locale] if escaping == "html": value = buildutil.htmlEscape(value) elif escaping == "javascript": value = json.dumps(value) if len(value) > 1: value = value[1:-1] # strip of the quotes on both sides else: raise BuildError("Unrecognized escaping type %s" % escaping) content = content.replace("[[%s]]" % key, value) return content
config = parseOptions() try: shermanPath = os.path.dirname(os.path.abspath(__file__)) os.mkdir(config.targetDirectory) copyTemplate(shermanPath + "/templates/Makefile", config.targetDirectory + "/Makefile", { "shermanPath": shermanPath }) copyTemplate(shermanPath + "/templates/project-manifest.json", config.targetDirectory + "/project-manifest.json", { "title": config.projectName }) os.mkdir(config.targetDirectory + "/boot") copyTemplate(shermanPath + "/templates/boot.tpl.html", config.targetDirectory + "/boot/boot.tpl.html", { "title": buildutil.htmlEscape(config.projectName) }) shutil.copy(shermanPath + "/templates/favicon.ico", config.targetDirectory + "/boot/favicon.ico") os.mkdir(config.targetDirectory + "/modules") shutil.copytree(shermanPath + "/templates/core/css", config.targetDirectory + "/modules/core/css") shutil.copytree(shermanPath + "/templates/core/i18n", config.targetDirectory + "/modules/core/i18n") shutil.copytree(shermanPath + "/templates/core/js", config.targetDirectory + "/modules/core/js") shutil.copytree(shermanPath + "/templates/core/tmpl", config.targetDirectory + "/modules/core/tmpl") copyTemplate(shermanPath + "/templates/core/manifest.json", config.targetDirectory + "/modules/core/manifest.json", { "namespace": config.namespace }) shutil.copytree(shermanPath + "/templates/boot/js", config.targetDirectory + "/modules/boot/js") copyTemplate(shermanPath + "/templates/boot/manifest.json", config.targetDirectory + "/modules/boot/manifest.json", { "namespace": config.namespace