A bit of reformatting
This commit is contained in:
+9
-6
@@ -166,7 +166,9 @@ def load_translations(
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
raise ValueError(
|
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)
|
# Order: English first, then by _order metadata (falls back to filename)
|
||||||
@@ -296,6 +298,7 @@ def report_unused_keys(
|
|||||||
# C++ string escaping
|
# C++ string escaping
|
||||||
# ---------------------------------------------------------------------------
|
# ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
def escape_cpp_string(s: str) -> List[str]:
|
def escape_cpp_string(s: str) -> List[str]:
|
||||||
r"""
|
r"""
|
||||||
Convert *s* into one or more C++ string literal segments.
|
Convert *s* into one or more C++ string literal segments.
|
||||||
@@ -445,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 {",
|
||||||
@@ -526,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)}"
|
||||||
@@ -555,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 {",
|
||||||
"",
|
"",
|
||||||
@@ -583,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",
|
||||||
"",
|
"",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -623,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
|
||||||
|
|||||||
Reference in New Issue
Block a user