mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
[Font] Add an import option to pre-render all glyphs required for the translation.
This commit is contained in:
parent
dca5cb8e40
commit
35528b800c
12 changed files with 261 additions and 20 deletions
|
@ -267,6 +267,39 @@ StringName OptimizedTranslation::get_message(const StringName &p_src_text, const
|
|||
}
|
||||
}
|
||||
|
||||
Vector<String> OptimizedTranslation::get_translated_message_list() const {
|
||||
Vector<String> msgs;
|
||||
|
||||
const int *htr = hash_table.ptr();
|
||||
const uint32_t *htptr = (const uint32_t *)&htr[0];
|
||||
const int *btr = bucket_table.ptr();
|
||||
const uint32_t *btptr = (const uint32_t *)&btr[0];
|
||||
const uint8_t *sr = strings.ptr();
|
||||
const char *sptr = (const char *)&sr[0];
|
||||
|
||||
for (int i = 0; i < hash_table.size(); i++) {
|
||||
uint32_t p = htptr[i];
|
||||
if (p != 0xFFFFFFFF) {
|
||||
const Bucket &bucket = *(const Bucket *)&btptr[p];
|
||||
for (int j = 0; j < bucket.size; j++) {
|
||||
if (bucket.elem[j].comp_size == bucket.elem[j].uncomp_size) {
|
||||
String rstr;
|
||||
rstr.parse_utf8(&sptr[bucket.elem[j].str_offset], bucket.elem[j].uncomp_size);
|
||||
msgs.push_back(rstr);
|
||||
} else {
|
||||
CharString uncomp;
|
||||
uncomp.resize(bucket.elem[j].uncomp_size + 1);
|
||||
smaz_decompress(&sptr[bucket.elem[j].str_offset], bucket.elem[j].comp_size, uncomp.ptrw(), bucket.elem[j].uncomp_size);
|
||||
String rstr;
|
||||
rstr.parse_utf8(uncomp.get_data());
|
||||
msgs.push_back(rstr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return msgs;
|
||||
}
|
||||
|
||||
StringName OptimizedTranslation::get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context) const {
|
||||
// The use of plurals translation is not yet supported in OptimizedTranslation.
|
||||
return get_message(p_src_text, p_context);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue