[Import] Fix empty columns importing as invalid English translation.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
/**************************************************************************/
|
||||
/* optimized_translation.compat.inc */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
|
||||
#include "optimized_translation.h"
|
||||
|
||||
#include "core/object/class_db.h"
|
||||
|
||||
void OptimizedTranslation::_generate_bind_compat_119563(const Ref<Translation> &p_from) {
|
||||
generate(p_from);
|
||||
}
|
||||
|
||||
void OptimizedTranslation::_bind_compatibility_methods() {
|
||||
ClassDB::bind_compatibility_method(D_METHOD("generate", "from"), &OptimizedTranslation::_generate_bind_compat_119563);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -29,6 +29,7 @@
|
||||
/**************************************************************************/
|
||||
|
||||
#include "optimized_translation.h"
|
||||
#include "optimized_translation.compat.inc"
|
||||
|
||||
#include "core/object/class_db.h"
|
||||
#include "core/templates/pair.h"
|
||||
@@ -43,11 +44,11 @@ struct CompressedString {
|
||||
int offset = 0;
|
||||
};
|
||||
|
||||
void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
|
||||
bool OptimizedTranslation::generate(const Ref<Translation> &p_from) {
|
||||
// This method compresses a Translation instance.
|
||||
// Right now, it doesn't handle context or plurals.
|
||||
#ifdef TOOLS_ENABLED
|
||||
ERR_FAIL_COND(p_from.is_null());
|
||||
ERR_FAIL_COND_V(p_from.is_null(), false);
|
||||
|
||||
List<StringName> keys;
|
||||
{
|
||||
@@ -150,7 +151,7 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
|
||||
bucket_table_size += 2 + b.size() * 4;
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(bucket_table_size == 0);
|
||||
ERR_FAIL_COND_V(bucket_table_size == 0, false);
|
||||
|
||||
hash_table.resize(size);
|
||||
bucket_table.resize(bucket_table_size);
|
||||
@@ -189,9 +190,12 @@ void OptimizedTranslation::generate(const Ref<Translation> &p_from) {
|
||||
memcpy(&cw[compressed[i].offset], compressed[i].compressed.get_data(), compressed[i].compressed.size());
|
||||
}
|
||||
|
||||
ERR_FAIL_COND(btindex != bucket_table_size);
|
||||
ERR_FAIL_COND_V(btindex != bucket_table_size, false);
|
||||
set_locale(p_from->get_locale());
|
||||
|
||||
return true;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -91,11 +91,17 @@ protected:
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
static void _bind_methods();
|
||||
|
||||
#ifndef DISABLE_DEPRECATED
|
||||
void _generate_bind_compat_119563(const Ref<Translation> &p_from);
|
||||
|
||||
static void _bind_compatibility_methods();
|
||||
#endif
|
||||
|
||||
public:
|
||||
virtual StringName get_message(const StringName &p_src_text, const StringName &p_context = "") const override; //overridable for other implementations
|
||||
virtual StringName get_plural_message(const StringName &p_src_text, const StringName &p_plural_text, int p_n, const StringName &p_context = "") const override;
|
||||
virtual Vector<String> get_translated_message_list() const override;
|
||||
void generate(const Ref<Translation> &p_from);
|
||||
bool generate(const Ref<Translation> &p_from);
|
||||
|
||||
virtual void get_message_list(List<StringName> *r_messages) const override;
|
||||
virtual int get_message_count() const override;
|
||||
|
||||
Reference in New Issue
Block a user