Merge pull request #59771 from timothyqiu/i18n-theme-props

Extract theme property names for localization
This commit is contained in:
Rémi Verschelde 2022-04-01 08:44:11 +02:00 committed by GitHub
commit f3fe2631da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 2 deletions

View file

@ -117,17 +117,23 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["bvh"] = "BVH";
capitalize_string_remaps["ca"] = "CA";
capitalize_string_remaps["cd"] = "CD";
capitalize_string_remaps["commentfocus"] = "Comment Focus";
capitalize_string_remaps["cpu"] = "CPU";
capitalize_string_remaps["csg"] = "CSG";
capitalize_string_remaps["db"] = "dB";
capitalize_string_remaps["defaultfocus"] = "Default Focus";
capitalize_string_remaps["defaultframe"] = "Default Frame";
capitalize_string_remaps["dof"] = "DoF";
capitalize_string_remaps["dpi"] = "DPI";
capitalize_string_remaps["dtls"] = "DTLS";
capitalize_string_remaps["eol"] = "EOL";
capitalize_string_remaps["erp"] = "ERP";
capitalize_string_remaps["etc"] = "ETC";
capitalize_string_remaps["etc2"] = "ETC2";
capitalize_string_remaps["fbx"] = "FBX";
capitalize_string_remaps["fbx2gltf"] = "FBX2glTF";
capitalize_string_remaps["fft"] = "FFT";
capitalize_string_remaps["fg"] = "FG";
capitalize_string_remaps["fov"] = "FOV";
capitalize_string_remaps["fps"] = "FPS";
capitalize_string_remaps["fs"] = "FS";
@ -145,6 +151,8 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["hdr"] = "HDR";
capitalize_string_remaps["hidpi"] = "hiDPI";
capitalize_string_remaps["hipass"] = "High-pass";
capitalize_string_remaps["hl"] = "HL";
capitalize_string_remaps["hseparation"] = "H Separation";
capitalize_string_remaps["hsv"] = "HSV";
capitalize_string_remaps["html"] = "HTML";
capitalize_string_remaps["http"] = "HTTP";
@ -177,6 +185,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["msaa"] = "MSAA";
capitalize_string_remaps["nfc"] = "NFC";
capitalize_string_remaps["normalmap"] = "Normal Map";
capitalize_string_remaps["ofs"] = "Offset";
capitalize_string_remaps["ok"] = "OK";
capitalize_string_remaps["opengl"] = "OpenGL";
capitalize_string_remaps["opentype"] = "OpenType";
@ -195,6 +204,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["sdfgi"] = "SDFGI";
capitalize_string_remaps["sdk"] = "SDK";
capitalize_string_remaps["sec"] = "(sec)"; // Unit.
capitalize_string_remaps["selectedframe"] = "Selected Frame";
capitalize_string_remaps["sms"] = "SMS";
capitalize_string_remaps["srgb"] = "sRGB";
capitalize_string_remaps["ssao"] = "SSAO";
@ -203,6 +213,7 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["ssl"] = "SSL";
capitalize_string_remaps["stderr"] = "stderr";
capitalize_string_remaps["stdout"] = "stdout";
capitalize_string_remaps["sv"] = "SV";
capitalize_string_remaps["svg"] = "SVG";
capitalize_string_remaps["tcp"] = "TCP";
capitalize_string_remaps["ui"] = "UI";
@ -216,9 +227,11 @@ EditorPropertyNameProcessor::EditorPropertyNameProcessor() {
capitalize_string_remaps["uv1"] = "UV1";
capitalize_string_remaps["uv2"] = "UV2";
capitalize_string_remaps["uwp"] = "UWP";
capitalize_string_remaps["vadjust"] = "V Adjust";
capitalize_string_remaps["vector2"] = "Vector2";
capitalize_string_remaps["vpn"] = "VPN";
capitalize_string_remaps["vram"] = "VRAM";
capitalize_string_remaps["vseparation"] = "V Separation";
capitalize_string_remaps["vsync"] = "V-Sync";
capitalize_string_remaps["wap"] = "WAP";
capitalize_string_remaps["webp"] = "WebP";

View file

@ -3,6 +3,7 @@
import enum
import fnmatch
import os
import os.path
import re
import shutil
import subprocess
@ -128,6 +129,9 @@ message_patterns = {
re.compile(r'ADD_GROUP\("(?P<message>[^"]+?)", "(?P<prefix>[^"]*?)"\)'): ExtractType.GROUP,
re.compile(r'#define WRTC_\w+ "(?P<message>[^"]+?)"'): ExtractType.PROPERTY_PATH,
}
theme_property_patterns = {
re.compile(r'set_(constant|font|font_size|stylebox|color|icon)\("(?P<message>[^"]+)", '): ExtractType.PROPERTY_PATH,
}
# See String::camelcase_to_underscore().
@ -200,6 +204,10 @@ def process_file(f, fname):
translator_comment = ""
current_group = ""
patterns = message_patterns
if os.path.basename(fname) == "default_theme.cpp":
patterns = {**message_patterns, **theme_property_patterns}
while l:
# Detect translator comments.
@ -217,7 +225,7 @@ def process_file(f, fname):
translator_comment = translator_comment[:-1] # Remove extra \n at the end.
if not reading_translator_comment:
for pattern, extract_type in message_patterns.items():
for pattern, extract_type in patterns.items():
for m in pattern.finditer(l):
location = os.path.relpath(fname).replace("\\", "/")
if line_nb:

View file

@ -367,7 +367,7 @@ bool Control::_get(const StringName &p_name, Variant &r_ret) const {
void Control::_get_property_list(List<PropertyInfo> *p_list) const {
Ref<Theme> theme = Theme::get_default();
p_list->push_back(PropertyInfo(Variant::NIL, "Theme Overrides", PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));
p_list->push_back(PropertyInfo(Variant::NIL, TTRC("Theme Overrides"), PROPERTY_HINT_NONE, "theme_override_", PROPERTY_USAGE_GROUP));
{
List<StringName> names;