feat: updated engine version to 4.4-rc1
This commit is contained in:
parent
ee00efde1f
commit
21ba8e33af
5459 changed files with 1128836 additions and 198305 deletions
|
|
@ -31,14 +31,14 @@
|
|||
#include "localization_editor.h"
|
||||
|
||||
#include "core/config/project_settings.h"
|
||||
#include "core/string/translation.h"
|
||||
#include "core/string/translation_server.h"
|
||||
#include "editor/editor_translation_parser.h"
|
||||
#include "editor/editor_undo_redo_manager.h"
|
||||
#include "editor/filesystem_dock.h"
|
||||
#include "editor/gui/editor_file_dialog.h"
|
||||
#include "editor/pot_generator.h"
|
||||
#include "editor/themes/editor_scale.h"
|
||||
#include "scene/gui/control.h"
|
||||
#include "scene/gui/tab_container.h"
|
||||
|
||||
void LocalizationEditor::_notification(int p_what) {
|
||||
switch (p_what) {
|
||||
|
|
@ -49,6 +49,7 @@ void LocalizationEditor::_notification(int p_what) {
|
|||
|
||||
List<String> tfn;
|
||||
ResourceLoader::get_recognized_extensions_for_type("Translation", &tfn);
|
||||
tfn.erase("csv"); // CSV is recognized by the resource importer to generate translation files, but it's not a translation file itself.
|
||||
for (const String &E : tfn) {
|
||||
translation_file_open->add_filter("*." + E);
|
||||
}
|
||||
|
|
@ -74,15 +75,20 @@ void LocalizationEditor::add_translation(const String &p_translation) {
|
|||
|
||||
void LocalizationEditor::_translation_add(const PackedStringArray &p_paths) {
|
||||
PackedStringArray translations = GLOBAL_GET("internationalization/locale/translations");
|
||||
for (int i = 0; i < p_paths.size(); i++) {
|
||||
if (!translations.has(p_paths[i])) {
|
||||
int count = 0;
|
||||
for (const String &path : p_paths) {
|
||||
if (!translations.has(path)) {
|
||||
// Don't add duplicate translation paths.
|
||||
translations.push_back(p_paths[i]);
|
||||
translations.push_back(path);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(vformat(TTR("Add %d Translations"), p_paths.size()));
|
||||
undo_redo->create_action(vformat(TTRN("Add %d Translation", "Add %d Translations", count), count));
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translations", translations);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "internationalization/locale/translations", GLOBAL_GET("internationalization/locale/translations"));
|
||||
undo_redo->add_do_method(this, "update_translations");
|
||||
|
|
@ -136,15 +142,20 @@ void LocalizationEditor::_translation_res_add(const PackedStringArray &p_paths)
|
|||
prev = remaps;
|
||||
}
|
||||
|
||||
for (int i = 0; i < p_paths.size(); i++) {
|
||||
if (!remaps.has(p_paths[i])) {
|
||||
int count = 0;
|
||||
for (const String &path : p_paths) {
|
||||
if (!remaps.has(path)) {
|
||||
// Don't overwrite with an empty remap array if an array already exists for the given path.
|
||||
remaps[p_paths[i]] = PackedStringArray();
|
||||
remaps[path] = PackedStringArray();
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(vformat(TTR("Translation Resource Remap: Add %d Path(s)"), p_paths.size()));
|
||||
undo_redo->create_action(vformat(TTRN("Translation Resource Remap: Add %d Path", "Translation Resource Remap: Add %d Paths", count), count));
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translation_remaps", remaps);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "internationalization/locale/translation_remaps", prev);
|
||||
undo_redo->add_do_method(this, "update_translations");
|
||||
|
|
@ -176,7 +187,7 @@ void LocalizationEditor::_translation_res_option_add(const PackedStringArray &p_
|
|||
remaps[key] = r;
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(vformat(TTR("Translation Resource Remap: Add %d Remap(s)"), p_paths.size()));
|
||||
undo_redo->create_action(vformat(TTRN("Translation Resource Remap: Add %d Remap", "Translation Resource Remap: Add %d Remaps", p_paths.size()), p_paths.size()));
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translation_remaps", remaps);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "internationalization/locale/translation_remaps", GLOBAL_GET("internationalization/locale/translation_remaps"));
|
||||
undo_redo->add_do_method(this, "update_translations");
|
||||
|
|
@ -326,14 +337,19 @@ void LocalizationEditor::_translation_res_option_delete(Object *p_item, int p_co
|
|||
|
||||
void LocalizationEditor::_pot_add(const PackedStringArray &p_paths) {
|
||||
PackedStringArray pot_translations = GLOBAL_GET("internationalization/locale/translations_pot_files");
|
||||
for (int i = 0; i < p_paths.size(); i++) {
|
||||
if (!pot_translations.has(p_paths[i])) {
|
||||
pot_translations.push_back(p_paths[i]);
|
||||
int count = 0;
|
||||
for (const String &path : p_paths) {
|
||||
if (!pot_translations.has(path)) {
|
||||
pot_translations.push_back(path);
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
if (count == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();
|
||||
undo_redo->create_action(vformat(TTR("Add %d file(s) for POT generation"), p_paths.size()));
|
||||
undo_redo->create_action(vformat(TTRN("Add %d file for POT generation", "Add %d files for POT generation", count), count));
|
||||
undo_redo->add_do_property(ProjectSettings::get_singleton(), "internationalization/locale/translations_pot_files", pot_translations);
|
||||
undo_redo->add_undo_property(ProjectSettings::get_singleton(), "internationalization/locale/translations_pot_files", GLOBAL_GET("internationalization/locale/translations_pot_files"));
|
||||
undo_redo->add_do_method(this, "update_translations");
|
||||
|
|
@ -426,7 +442,7 @@ void LocalizationEditor::_filesystem_files_moved(const String &p_old_file, const
|
|||
bool remapped_files_updated = false;
|
||||
|
||||
for (int j = 0; j < remapped_files.size(); j++) {
|
||||
int splitter_pos = remapped_files[j].rfind(":");
|
||||
int splitter_pos = remapped_files[j].rfind_char(':');
|
||||
String res_path = remapped_files[j].substr(0, splitter_pos);
|
||||
|
||||
if (res_path == p_old_file) {
|
||||
|
|
@ -467,7 +483,7 @@ void LocalizationEditor::_filesystem_file_removed(const String &p_file) {
|
|||
for (int i = 0; i < remap_keys.size() && !remaps_changed; i++) {
|
||||
PackedStringArray remapped_files = remaps[remap_keys[i]];
|
||||
for (int j = 0; j < remapped_files.size() && !remaps_changed; j++) {
|
||||
int splitter_pos = remapped_files[j].rfind(":");
|
||||
int splitter_pos = remapped_files[j].rfind_char(':');
|
||||
String res_path = remapped_files[j].substr(0, splitter_pos);
|
||||
remaps_changed = p_file == res_path;
|
||||
if (remaps_changed) {
|
||||
|
|
@ -552,7 +568,7 @@ void LocalizationEditor::update_translations() {
|
|||
PackedStringArray selected = remaps[keys[i]];
|
||||
for (int j = 0; j < selected.size(); j++) {
|
||||
const String &s2 = selected[j];
|
||||
int qp = s2.rfind(":");
|
||||
int qp = s2.rfind_char(':');
|
||||
String path = s2.substr(0, qp);
|
||||
String locale = s2.substr(qp + 1, s2.length());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue