A bit of reformatting

This commit is contained in:
jpirnay
2026-03-31 14:45:31 +02:00
parent 5da520eb9e
commit 59466b0625
+9 -6
View File
@@ -166,7 +166,9 @@ def load_translations(
)
]
raise ValueError(
"Duplicate _order values found:\n " + "\n ".join(duplicate_messages) + "\nEach _order value must be unique to ensure a deterministic language order."
"Duplicate _order values found:\n "
+ "\n ".join(duplicate_messages)
+ "\nEach _order value must be unique to ensure a deterministic language order."
)
# Order: English first, then by _order metadata (falls back to filename)
@@ -296,6 +298,7 @@ def report_unused_keys(
# C++ string escaping
# ---------------------------------------------------------------------------
def escape_cpp_string(s: str) -> List[str]:
r"""
Convert *s* into one or more C++ string literal segments.
@@ -445,6 +448,7 @@ def generate_keys_header(
"#include <cstdint>",
"",
"// 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",
"namespace i18n_strings {",
@@ -526,9 +530,9 @@ def generate_keys_header(
key=lambda i: languages[i],
)
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(f"// Order: {comment_names}")
for rank, idx in enumerate(sorted_indices):
lines.append(f"// {rank:>2}: {languages[idx]:<4} {language_names[idx]}")
lines.append(
"constexpr uint8_t SORTED_LANGUAGE_INDICES[] = {"
f"{', '.join(str(i) for i in sorted_indices)}"
@@ -555,6 +559,7 @@ def generate_strings_header(
'#include "I18nKeys.h"',
"",
"// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.",
"// clang-format off",
"",
"namespace i18n_strings {",
"",
@@ -583,6 +588,7 @@ def generate_strings_cpp(
"#include <cstddef>",
"",
"// THIS FILE IS AUTO-GENERATED BY gen_i18n.py. DO NOT EDIT.",
"// clang-format off",
"",
]
@@ -623,13 +629,10 @@ def generate_strings_cpp(
)
# 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[] =")
for text in lang_strings:
_append_string_data_entry(lines, text)
lines.append(";")
lines.append("// clang-format on")
lines.append("")
# Offset table — one uint16_t per StrId