POT Generator: Add support for TRANSLATORS: and NO_TRANSLATE comments

This commit is contained in:
Danil Alexeev
2024-10-11 17:35:28 +03:00
parent 92e51fca72
commit cab80cb97d
9 changed files with 170 additions and 23 deletions

View File

@@ -31,7 +31,6 @@
#include "editor_translation_parser.h"
#include "core/error/error_macros.h"
#include "core/io/file_access.h"
#include "core/object/script_language.h"
#include "core/templates/hash_set.h"
@@ -65,6 +64,21 @@ Error EditorTranslationParserPlugin::parse_file(const String &p_path, Vector<Str
}
}
void EditorTranslationParserPlugin::get_comments(Vector<String> *r_ids_comment, Vector<String> *r_ids_ctx_plural_comment) {
TypedArray<String> ids_comment;
TypedArray<String> ids_ctx_plural_comment;
if (GDVIRTUAL_CALL(_get_comments, ids_comment, ids_ctx_plural_comment)) {
for (int i = 0; i < ids_comment.size(); i++) {
r_ids_comment->append(ids_comment[i]);
}
for (int i = 0; i < ids_ctx_plural_comment.size(); i++) {
r_ids_ctx_plural_comment->append(ids_ctx_plural_comment[i]);
}
}
}
void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_extensions) const {
Vector<String> extensions;
if (GDVIRTUAL_CALL(_get_recognized_extensions, extensions)) {
@@ -78,6 +92,7 @@ void EditorTranslationParserPlugin::get_recognized_extensions(List<String> *r_ex
void EditorTranslationParserPlugin::_bind_methods() {
GDVIRTUAL_BIND(_parse_file, "path", "msgids", "msgids_context_plural");
GDVIRTUAL_BIND(_get_comments, "msgids_comment", "msgids_context_plural_comment");
GDVIRTUAL_BIND(_get_recognized_extensions);
}