Cleanup editor translation related methods

- Unify logic for loading editor/property/doc/extractable translations.
- Replace legacy `TranslationServer` methods with translation domains for internal translations.
- Only pre-create editor/property/doc translation domains in editor builds.
- Prevent adding `null` translation.
- Fixes potential loading of duplicated editor translations.
- Add internal `has_translation_for_locale()` instead of calling `get_loaded_translations().has()`.
This commit is contained in:
Haoyu Qiu 2025-06-26 15:16:30 +08:00
parent 8b4b93a82e
commit 3f03260a21
12 changed files with 77 additions and 163 deletions

View file

@ -124,7 +124,7 @@ inline constexpr const unsigned char _{category}_translation_{name}_compressed[]
file.write(f"""\
#include "{target_h}"
const {category.capitalize()}TranslationList _{category}_translations[] = {{
const EditorTranslationList _{category}_translations[] = {{
""")
for x in xl_names:
@ -137,12 +137,18 @@ const {category.capitalize()}TranslationList _{category}_translations[] = {{
with methods.generated_wrapper(target_h) as file:
file.write(f"""\
struct {category.capitalize()}TranslationList {{
#ifndef EDITOR_TRANSLATION_LIST
#define EDITOR_TRANSLATION_LIST
struct EditorTranslationList {{
const char* lang;
int comp_size;
int uncomp_size;
const unsigned char* data;
}};
extern const {category.capitalize()}TranslationList _{category}_translations[];
#endif // EDITOR_TRANSLATION_LIST
extern const EditorTranslationList _{category}_translations[];
""")