Merge branch 'refactor-i18n_offset-table' of https://github.com/jpirnay/crosspoint-reader into mybuild

This commit is contained in:
jpirnay
2026-03-31 14:52:24 +02:00
+5 -5
View File
@@ -448,6 +448,7 @@ def generate_keys_header(
"#include <cstdint>", "#include <cstdint>",
"", "",
"// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.", "// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.",
"// clang-format off",
"", "",
"// Forward declarations for flat string data blobs and offset tables", "// Forward declarations for flat string data blobs and offset tables",
"namespace i18n_strings {", "namespace i18n_strings {",
@@ -529,9 +530,9 @@ def generate_keys_header(
key=lambda i: languages[i], key=lambda i: languages[i],
) )
sorted_indices = [english_idx] + rest sorted_indices = [english_idx] + rest
comment_names = ", ".join(language_names[i] for i in sorted_indices)
lines.append("// Sorted language indices by code (auto-generated by gen_i18n.py)") lines.append("// Sorted language indices by code (auto-generated by gen_i18n.py)")
lines.append(f"// Order: {comment_names}") for rank, idx in enumerate(sorted_indices):
lines.append(f"// {rank:>2}: {languages[idx]:<4} {language_names[idx]}")
lines.append( lines.append(
"constexpr uint8_t SORTED_LANGUAGE_INDICES[] = {" "constexpr uint8_t SORTED_LANGUAGE_INDICES[] = {"
f"{', '.join(str(i) for i in sorted_indices)}" f"{', '.join(str(i) for i in sorted_indices)}"
@@ -558,6 +559,7 @@ def generate_strings_header(
'#include "I18nKeys.h"', '#include "I18nKeys.h"',
"", "",
"// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.", "// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.",
"// clang-format off",
"", "",
"namespace i18n_strings {", "namespace i18n_strings {",
"", "",
@@ -586,6 +588,7 @@ def generate_strings_cpp(
"#include <cstddef>", "#include <cstddef>",
"", "",
"// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.", "// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.",
"// clang-format off",
"", "",
] ]
@@ -626,13 +629,10 @@ def generate_strings_cpp(
) )
# Flat string data blob — all strings concatenated with \0 separators. # Flat string data blob — all strings concatenated with \0 separators.
# clang-format off/on avoids reformatting of the adjacent string literals.
lines.append("// clang-format off")
lines.append(f"const char STRINGS_{code}_DATA[] =") lines.append(f"const char STRINGS_{code}_DATA[] =")
for text in lang_strings: for text in lang_strings:
_append_string_data_entry(lines, text) _append_string_data_entry(lines, text)
lines.append(";") lines.append(";")
lines.append("// clang-format on")
lines.append("") lines.append("")
# Offset table — one uint16_t per StrId # Offset table — one uint16_t per StrId