You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Gettext PO and MO files use an empty untranslated string without context
39
+
// to store metadata.
40
+
if (p_msgctxt.is_empty() && p_msgid.is_empty()) {
41
+
WARN_PRINT("Both context and the untranslated string are empty. This may cause issues with the translation system and external tools.");
42
+
}
43
+
44
+
// The EOT character (0x04) is used as a separator between context and
45
+
// untranslated string in the MO file format. This convention is also used
46
+
// by `get_message_list()`.
47
+
//
48
+
// It's unusual to have this character in the context or untranslated
49
+
// string. But it doesn't do any harm as long as you are aware of this when
50
+
// using the relevant APIs and tools.
51
+
if (p_msgctxt.contains_char(0x04)) {
52
+
WARN_PRINT(vformat("Found EOT character (0x04) within context '%s'. This may cause issues with the translation system and external tools.", p_msgctxt));
53
+
}
54
+
if (p_msgid.contains_char(0x04)) {
55
+
WARN_PRINT(vformat("Found EOT character (0x04) within untranslated string '%s'. This may cause issues with the translation system and external tools.", p_msgid));
56
+
}
57
+
}
58
+
37
59
Dictionary Translation::_get_messages() const {
38
60
Dictionary d;
39
-
for (const KeyValue<StringName, StringName> &E : translation_map) {
40
-
d[E.key] = E.value;
61
+
for (const KeyValue<MessageKey, Vector<StringName>> &E : translation_map) {
WARN_PRINT("Translation class doesn't handle plural messages. Calling add_plural_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles plurals, such as TranslationPO class");
90
150
ERR_FAIL_COND_MSG(p_plural_xlated_texts.is_empty(), "Parameter vector p_plural_xlated_texts passed in is empty.");
WARN_PRINT("Translation class doesn't handle context. Using context in get_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles context, such as TranslationPO class");
102
-
}
103
-
104
-
HashMap<StringName, StringName>::ConstIterator E = translation_map.find(p_src_text);
@@ -115,21 +180,30 @@ StringName Translation::get_plural_message(const StringName &p_src_text, const S
115
180
return ret;
116
181
}
117
182
118
-
WARN_PRINT("Translation class doesn't handle plural messages. Calling get_plural_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles plurals, such as TranslationPO class");
119
-
returnget_message(p_src_text);
120
-
}
183
+
ERR_FAIL_COND_V_MSG(p_n < 0, StringName(), "N passed into translation to get a plural message should not be negative. For negative numbers, use singular translation please. Search \"gettext PO Plural Forms\" online for details on translating negative numbers.");
WARN_PRINT("Translation class doesn't handle context. Using context in erase_message() on a Translation instance is probably a mistake. \nUse a derived Translation class that handles context, such as TranslationPO class");
0 commit comments