Skip to content

Commit

Permalink
add pseudolocalization to editor
Browse files Browse the repository at this point in the history
  • Loading branch information
angad-k committed Jul 19, 2021
1 parent abc3839 commit 0ae14e2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
23 changes: 23 additions & 0 deletions core/string/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1271,9 +1271,23 @@ StringName TranslationServer::tool_translate(const StringName &p_message, const
if (tool_translation.is_valid()) {
StringName r = tool_translation->get_message(p_message, p_context);
if (r) {
#ifdef TOOLS_ENABLED
if (EditorSettings::get_singleton()) {
if (EditorSettings::get_singleton()->get("interface/editor/enable_debugging_pseudolocalization")) {
return tool_pseudolocalize(r);
}
}
#endif // TOOLS_ENABLED
return r;
}
}
#ifdef TOOLS_ENABLED
if (EditorSettings::get_singleton()) {
if (EditorSettings::get_singleton()->get("interface/editor/enable_debugging_pseudolocalization")) {
return tool_pseudolocalize(p_message);
}
}
#endif // TOOLS_ENABLED
return p_message;
}

Expand Down Expand Up @@ -1458,6 +1472,15 @@ StringName TranslationServer::pseudolocalize(const StringName &p_message) const
StringName res = add_padding(message, length);
return res;
}

StringName TranslationServer::tool_pseudolocalize(const StringName &p_message) const {
String message = p_message;
message = double_vowels(message);
message = replace_with_accented_string(message);
StringName res = "[!!! " + message + " !!!]";
return res;
}

String TranslationServer::get_override_string(String &message) const {
String res = "";
for (int i = 0; i < message.size(); i++) {
Expand Down
1 change: 1 addition & 0 deletions core/string/translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class TranslationServer : public Object {
StringName translate_plural(const StringName &p_message, const StringName &p_message_plural, int p_n, const StringName &p_context = "") const;

StringName pseudolocalize(const StringName &p_message) const;
StringName tool_pseudolocalize(const StringName &p_message) const;
String get_override_string(String &message) const;
String double_vowels(String &message) const;
String replace_with_accented_string(String &message) const;
Expand Down
5 changes: 5 additions & 0 deletions editor/editor_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
_initial_set("interface/editor/display_scale", 0);
// Display what the Auto display scale setting effectively corresponds to.
float scale = get_auto_display_scale();

_initial_set("interface/editor/enable_debugging_pseudolocalization", false);
set_restart_if_changed("interface/editor/enable_debugging_pseudolocalization", true);
// Use pseudolocalization in editor.

hints["interface/editor/display_scale"] = PropertyInfo(Variant::INT, "interface/editor/display_scale", PROPERTY_HINT_ENUM, vformat("Auto (%d%%),75%%,100%%,125%%,150%%,175%%,200%%,Custom", Math::round(scale * 100)), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
_initial_set("interface/editor/custom_display_scale", 1.0f);
hints["interface/editor/custom_display_scale"] = PropertyInfo(Variant::FLOAT, "interface/editor/custom_display_scale", PROPERTY_HINT_RANGE, "0.5,3,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED);
Expand Down

0 comments on commit 0ae14e2

Please sign in to comment.