Unverified Commit 700ec479 authored by Robin Mueller's avatar Robin Mueller
Browse files

use formatted string

parent 656757e7
......@@ -35,16 +35,17 @@ def write_translation_file(filename, list_of_entries, date_string_full: str):
outputfile = open(filename, "w")
print('ObjectParser: Writing translation file ' + filename)
definitions = ""
function = "const char* translateObject(object_id_t object){\n\tswitch((object&0xFFFFFFFF)){\n"
function = "const char* translateObject(object_id_t object) {\n\tswitch( (object & 0xFFFFFFFF) ) {\n"
for entry in list_of_entries:
# first part of translate file
definitions += "const char *" + entry[1][0] + "_STRING = \"" + entry[1][0] + "\";\n"
definitions += f"const char *{entry[1][0]}_STRING = \"{entry[1][0]}\";\n"
# second part of translate file. entry[i] contains 32 bit hexadecimal numbers
function += "\t\tcase " + str(entry[0]) + ":\n\t\t\treturn " + entry[1][0] + "_STRING;\n"
function += '\t\tdefault:\n\t\t\treturn "UNKNOWN_OBJECT";\n'
outputfile.write("/** \n * @brief\tAuto-generated object translation file. Contains "
+ str(len(list_of_entries)) + " translations. \n"
" * Generated on: " + date_string_full + "\n **/ \n")
function += f"\tcase {entry[0]}:\n\t\treturn {entry[1][0]}_STRING;\n"
function += '\tdefault:\n\t\treturn "UNKNOWN_OBJECT";\n'
outputfile.write(f"/** \n * @brief\tAuto-generated object translation file.\n"
f" * @details\n"
f" * Contains {len(list_of_entries)} translations. \n"
f" * Generated on: {date_string_full}\n */ \n")
outputfile.write("#include \"translateObjects.h\"\n\n")
outputfile.write(definitions + "\n" + function + "\t}\n\treturn 0;\n}\n")
outputfile.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment