mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Add ConstIterator to Dictionary.
This commit is contained in:
@@ -67,10 +67,8 @@ Vector<String> Translation::get_translated_message_list() const {
|
||||
}
|
||||
|
||||
void Translation::_set_messages(const Dictionary &p_messages) {
|
||||
List<Variant> keys;
|
||||
p_messages.get_key_list(&keys);
|
||||
for (const Variant &E : keys) {
|
||||
translation_map[E] = p_messages[E];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_messages) {
|
||||
translation_map[kv.key] = kv.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,20 +86,16 @@ Dictionary TranslationPO::_get_messages() const {
|
||||
void TranslationPO::_set_messages(const Dictionary &p_messages) {
|
||||
// Construct translation_map from a Dictionary.
|
||||
|
||||
List<Variant> context_l;
|
||||
p_messages.get_key_list(&context_l);
|
||||
for (const Variant &ctx : context_l) {
|
||||
const Dictionary &id_str_map = p_messages[ctx];
|
||||
for (const KeyValue<Variant, Variant> &kv : p_messages) {
|
||||
const Dictionary &id_str_map = kv.value;
|
||||
|
||||
HashMap<StringName, Vector<StringName>> temp_map;
|
||||
List<Variant> id_l;
|
||||
id_str_map.get_key_list(&id_l);
|
||||
for (List<Variant>::Element *E2 = id_l.front(); E2; E2 = E2->next()) {
|
||||
StringName id = E2->get();
|
||||
temp_map[id] = id_str_map[id];
|
||||
for (const KeyValue<Variant, Variant> &kv_id : id_str_map) {
|
||||
StringName id = kv_id.key;
|
||||
temp_map[id] = kv_id.value;
|
||||
}
|
||||
|
||||
translation_map[ctx] = temp_map;
|
||||
translation_map[kv.key] = temp_map;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4029,11 +4029,9 @@ String String::format(const Variant &values, const String &placeholder) const {
|
||||
}
|
||||
} else if (values.get_type() == Variant::DICTIONARY) {
|
||||
Dictionary d = values;
|
||||
List<Variant> keys;
|
||||
d.get_key_list(&keys);
|
||||
|
||||
for (const Variant &key : keys) {
|
||||
new_string = new_string.replace(placeholder.replace("_", key), d[key]);
|
||||
for (const KeyValue<Variant, Variant> &kv : d) {
|
||||
new_string = new_string.replace(placeholder.replace("_", kv.key), kv.value);
|
||||
}
|
||||
} else if (values.get_type() == Variant::OBJECT) {
|
||||
Object *obj = values.get_validated_object();
|
||||
|
||||
Reference in New Issue
Block a user