Add option to add built-in strings in the POT generation
This commit is contained in:
@ -32,6 +32,7 @@
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/error/error_macros.h"
|
||||
#include "editor/editor_translation.h"
|
||||
#include "editor/editor_translation_parser.h"
|
||||
#include "plugins/packed_scene_translation_parser_plugin.h"
|
||||
|
||||
@ -65,6 +66,8 @@ void POTGenerator::generate_pot(const String &p_file) {
|
||||
// Clear all_translation_strings of the previous round.
|
||||
all_translation_strings.clear();
|
||||
|
||||
List<StringName> extractable_msgids = get_extractable_message_list();
|
||||
|
||||
// Collect all translatable strings according to files order in "POT Generation" setting.
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
Vector<String> msgids;
|
||||
@ -88,6 +91,12 @@ void POTGenerator::generate_pot(const String &p_file) {
|
||||
}
|
||||
}
|
||||
|
||||
if (GLOBAL_GET("internationalization/locale/translation_add_builtin_strings_to_pot")) {
|
||||
for (int i = 0; i < extractable_msgids.size(); i++) {
|
||||
_add_new_msgid(extractable_msgids[i], "", "", "");
|
||||
}
|
||||
}
|
||||
|
||||
_write_to_pot(p_file);
|
||||
}
|
||||
|
||||
@ -136,7 +145,9 @@ void POTGenerator::_write_to_pot(const String &p_file) {
|
||||
|
||||
// Write file locations.
|
||||
for (const String &E : locations) {
|
||||
file->store_line("#: " + E.trim_prefix("res://").replace("\n", "\\n"));
|
||||
if (!E.is_empty()) {
|
||||
file->store_line("#: " + E.trim_prefix("res://").replace("\n", "\\n"));
|
||||
}
|
||||
}
|
||||
|
||||
// Write context.
|
||||
|
||||
Reference in New Issue
Block a user