def gen_c_code_simple(strings_dict, keys, dir_name): langs = get_lang_objects(sorted(trans_langs.g_langs, cmp=lang_sort_func)) assert "en" == langs[0].code langs = build_trans_for_langs(langs, strings_dict, keys) lines = [] for lang in langs: lines.append(' /* Translations for language %s */' % lang.code) lines += [' L"%s",' % t.replace('"', '\\"') if t else ' NULL,' for t in lang.translations] lines.append("") lines.pop() translations = "\n".join(lines) langs_grp = ['"%s"' % lang.code for lang in langs] + ["NULL"] langs_list = ",\n ".join([", ".join(grp) for grp in util2.group(langs_grp, 10)]) lang_id_to_index = "\n ".join(["case %s: return %d;" % (lang.ms_lang_id, langs.index(lang) * len(keys)) for lang in langs if lang.ms_lang_id != "(LANGID)-1"] + ["default: return -1;"]) rtl_lang_cmp = " || ".join(["%d == index" % (langs.index(lang) * len(keys)) for lang in langs if lang.isRtl]) or "false" translations_count = len(keys) file_content = codecs.BOM_UTF8 + TRANSLATIONS_TXT_SIMPLE % locals() file_name = os.path.join( SRC_DIR, dir_name, file_name_from_dir_name(dir_name)) file(file_name, "wb").write(file_content) print_incomplete_langs(dir_name)
def flattenDependencyList(dependencies): flatlist = [] for file in dependencies.keys(): if dependencies[file]: opath = getObjectPath(file) filename = os.path.splitext(os.path.split(file)[1])[0] # TODO: normalizing paths already in prependPath makes getObjectPath fail under cygwin deplist = sorted(dependencies[file], key=lambda s: str.lower(s.replace("/", "\\"))) for depgroup in util2.group(deplist, DEPENDENCIES_PER_LINE): flatlist.append("%s\\%s.obj: $B\\%s" % (opath, filename, " $B\\".join(depgroup))) return flatlist
def gen_c_code_simple(strings_dict, keys, dir_name): langs = get_lang_objects(sorted(trans_langs.g_langs, cmp=lang_sort_func)) assert "en" == langs[0].code langs = build_trans_for_langs(langs, strings_dict, keys) lines = [] for lang in langs: lines.append(' /* Translations for language %s */' % lang.code) lines += [' L"%s",' % t.replace('"', '\\"') if t else ' NULL,' for t in lang.translations] lines.append("") lines.pop() translations = "\n".join(lines) langs_grp = ['"%s"' % lang.code for lang in langs] + ["NULL"] langs_list = ",\n ".join([", ".join(grp) for grp in util2.group(langs_grp, 10)]) lang_id_to_index = "\n ".join(["case %s: return %d;" % (lang.ms_lang_id, langs.index(lang) * len(keys)) for lang in langs if lang.ms_lang_id != "(LANGID)-1"] + ["default: return -1;"]) rtl_lang_cmp = " || ".join(["%d == index" % (langs.index(lang) * len(keys)) for lang in langs if lang.isRtl]) or "false" translations_count = len(keys) file_content = codecs.BOM_UTF8 + TRANSLATIONS_TXT_SIMPLE % locals() file_name = os.path.join(SRC_DIR, dir_name, file_name_from_dir_name(dir_name)) file(file_name, "wb").write(file_content) print_incomplete_langs(dir_name)
def createFastSelector(fullList, nameList, funcName, type): cases = ["case %s:" % value for (name, value) in fullList if name in nameList] return unTab(Template_Selector % (funcName, type, "\n ".join([" ".join(part) for part in util2.group(cases, 4)])))
def createTypeEnum(list, type, default): list = sorted(list, key=lambda a: a[0]) parts = util2.group([item[1] for item in list] + [default], 5) return unTab(Template_Enumeration % (type, ",\n ".join([", ".join(part) for part in parts])))
def createFastSelector(fullList, nameList, funcName, type): cases = [ "case %s:" % value for (name, value) in fullList if name in nameList ] return unTab(Template_Selector % (funcName, type, "\n ".join( [" ".join(part) for part in util2.group(cases, 4)])))