1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Improve editor property capitalization

* Captialize stop words when they are the last word.
* Add stop words logic in `extract.py`.
This commit is contained in:
Haoyu Qiu
2022-11-25 18:54:37 +08:00
parent 34df77285c
commit c0e9d928e6
2 changed files with 25 additions and 7 deletions

View File

@@ -64,8 +64,8 @@ String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const
Vector<String> parts = p_name.split("_", false);
for (int i = 0; i < parts.size(); i++) {
// Articles/conjunctions/prepositions which should only be capitalized if first word.
if (i != 0 && stop_words.find(parts[i]) != -1) {
// Articles/conjunctions/prepositions which should only be capitalized when not at beginning and end.
if (i > 0 && i + 1 < parts.size() && stop_words.find(parts[i]) != -1) {
continue;
}
HashMap<String, String>::ConstIterator remap = capitalize_string_remaps.find(parts[i]);
@@ -260,6 +260,8 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["yz"] = "YZ";
// Articles, conjunctions, prepositions.
// The following initialization is parsed in `editor/translations/extract.py` with a regex.
// The word definition format should be kept synced with the regex.
stop_words = LocalVector<String>({
"a",
"an",