MCPcopy Create free account
hub / github.com/GDRETools/gdsdecomp / convert

Method convert

compat/optimized_translation_extractor.cpp:639–667  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

637}
638
639Ref<Resource> TranslationConverterCompat::convert(const Ref<MissingResource> &res, ResourceInfo::LoadType p_type, int ver_major, Error *r_error) {
640 Ref<Translation> ote;
641 if (res->get_original_class() == "PHashTranslation" || res->get_original_class() == "OptimizedTranslation") {
642 ote = memnew(OptimizedTranslation);
643 ote->set("hash_table", res->get("hash_table"));
644 ote->set("bucket_table", res->get("bucket_table"));
645 ote->set("strings", res->get("strings"));
646 } else {
647 ote = memnew(Translation);
648 }
649 Variant v = res->get("messages");
650 Dictionary d;
651 if (v.get_type() == Variant::Type::PACKED_STRING_ARRAY) {
652 // convert to a Dictionary
653 PackedStringArray psa = v;
654 for (int i = 0; i < psa.size(); i += 2) {
655 d[psa[i]] = psa[i + 1];
656 }
657 } else if (v.get_type() == Variant::Type::DICTIONARY) {
658 d = v;
659 }
660 ote->set("messages", d);
661 Variant locale = res->get("locale");
662 if (locale != Variant()) {
663 ote->set("locale", locale);
664 }
665 ote->merge_meta_from(res.ptr());
666 return ote;
667}
668
669bool TranslationConverterCompat::handles_type(const String &p_type, int ver_major) const {
670 return (p_type == "Translation" || p_type == "PHashTranslation" || p_type == "OptimizedTranslation") && ver_major <= 3;

Callers

nothing calls this directly

Calls 5

get_original_classMethod · 0.80
setMethod · 0.80
getMethod · 0.45
get_typeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected