first Prototype
This commit is contained in:
parent
e11825c698
commit
35ce267482
481 changed files with 17315 additions and 1 deletions
|
|
@ -0,0 +1,9 @@
|
|||
# Auto Translate view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
@onready var _translators_ui = $Translators
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_translators_ui.set_data(data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cn4h4rfailmx
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://2e10hsy4f7ak"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/auto_translate/LocalizationAutoTranslateEditorView.gd" id="1"]
|
||||
[ext_resource type="PackedScene" uid="uid://d15n48edirewf" path="res://addons/localization_editor/scenes/auto_translate/translator/LocalizationAutoTranslate.tscn" id="2"]
|
||||
|
||||
[node name="LocalizationAutotranslateEditorView" type="VBoxContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1")
|
||||
|
||||
[node name="Translators" parent="." instance=ExtResource("2")]
|
||||
layout_mode = 2
|
||||
anchors_preset = 0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 1152.0
|
||||
offset_bottom = 648.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,482 @@
|
|||
# Autotranslate Yandex (https://translate.yandex.com/) for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var ctx = HMACContext.new()
|
||||
|
||||
const uuid_gen = preload("res://addons/localization_editor/uuid/uuid.gd")
|
||||
|
||||
const SETTINGS_SAVE_TRANSLATOR_SELECTION = "localization_editor/translations_translator_selection"
|
||||
const SETTINGS_SAVE_AUTH = "localization_editor/translations_save_auth"
|
||||
const SETTINGS_SAVE_AUTH_DEEPL_KEY = "localization_editor/translations_save_auth_deepl_key"
|
||||
const SETTINGS_SAVE_AUTH_MICROSOFT_URL = "localization_editor/translations_save_auth_microsoft_url"
|
||||
const SETTINGS_SAVE_AUTH_MICROSOFT_LOCATION = "localization_editor/translations_save_auth_deepl_location"
|
||||
const SETTINGS_SAVE_AUTH_MICROSOFT_KEY = "localization_editor/translations_save_auth_deepl_key"
|
||||
const SETTINGS_SAVE_AUTH_AMAZON_REGION = "localization_editor/translations_save_auth_amazon_region"
|
||||
const SETTINGS_SAVE_AUTH_AMAZON_ACCESS_KEY = "localization_editor/translations_save_auth_access_key"
|
||||
const SETTINGS_SAVE_AUTH_AMAZON_SECRET_KEY = "localization_editor/translations_save_auth_secret_key"
|
||||
|
||||
var _data: LocalizationData
|
||||
var _data_keys: Array = []
|
||||
var _queries_count: int = 0
|
||||
var _from_code: String
|
||||
var _to_code: String
|
||||
|
||||
@onready var _translator: OptionButton = $Panel/VBox/HBoxTranslator/Translator
|
||||
@onready var _link: LinkButton = $Panel/VBox/HBoxTranslator/LinkButton
|
||||
@onready var _save_auth: CheckBox = $Panel/VBox/HBoxTranslator/SaveAuth
|
||||
@onready var _from_language_ui = $Panel/VBox/HBox/FromLanguage
|
||||
@onready var _to_language_ui = $Panel/VBox/HBox/ToLanguage
|
||||
@onready var _translate_ui: Button = $Panel/VBox/HBox/Translate
|
||||
@onready var _progress_ui: ProgressBar = $Panel/VBox/Progress
|
||||
|
||||
# *** DEEPL ***
|
||||
@onready var _deepl_container: HBoxContainer = $Panel/VBox/HBoxDeepL
|
||||
@onready var _deepl_key: LineEdit = $Panel/VBox/HBoxDeepL/DeepLKey
|
||||
|
||||
# *** MICROSOFT AZURE ***
|
||||
@onready var _microsoft_container: HBoxContainer = $Panel/VBox/HBoxMicrosoft
|
||||
@onready var _microsoft_url: OptionButton = $Panel/VBox/HBoxMicrosoft/URL
|
||||
@onready var _microsoft_location: LineEdit = $Panel/VBox/HBoxMicrosoft/Location
|
||||
@onready var _microsoft_key: LineEdit = $Panel/VBox/HBoxMicrosoft/Key
|
||||
|
||||
# *** AMAZON AWS ***
|
||||
@onready var _amazon_container: VBoxContainer = $Panel/VBox/VBoxAWS
|
||||
@onready var _amazon_region: OptionButton = $Panel/VBox/VBoxAWS/HBoxRegion/Region
|
||||
@onready var _amazon_access_key: LineEdit = $Panel/VBox/VBoxAWS/HBoxAccessKey/AccessKey
|
||||
@onready var _amazon_secret_key: LineEdit = $Panel/VBox/VBoxAWS/HBoxSecretKey/SecretKey
|
||||
|
||||
const Locales = preload("res://addons/localization_editor/model/LocalizationLocalesList.gd")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
var has_save_auth = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH) == true
|
||||
_save_auth.set_pressed(has_save_auth)
|
||||
if has_save_auth:
|
||||
_translator.selected = ProjectSettings.get_setting(SETTINGS_SAVE_TRANSLATOR_SELECTION)
|
||||
_deepl_key.text = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_DEEPL_KEY)
|
||||
_microsoft_url.selected = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_MICROSOFT_URL)
|
||||
_microsoft_location.text = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_MICROSOFT_LOCATION)
|
||||
_microsoft_key.text = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_MICROSOFT_KEY)
|
||||
_amazon_region.selected = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_AMAZON_REGION)
|
||||
_amazon_access_key.text = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_AMAZON_ACCESS_KEY)
|
||||
_amazon_secret_key.text = ProjectSettings.get_setting(SETTINGS_SAVE_AUTH_AMAZON_SECRET_KEY)
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
if not _translator.is_connected("item_selected", _on_translator_selection_changed):
|
||||
_translator.item_selected.connect(_on_translator_selection_changed)
|
||||
if not _link.is_connected("pressed", _on_link_pressed):
|
||||
_link.pressed.connect(_on_link_pressed)
|
||||
if not _save_auth.toggled.is_connected(_on_save_auth_toggled):
|
||||
_save_auth.toggled.connect(_on_save_auth_toggled)
|
||||
if not _translate_ui.is_connected("pressed", _on_translate_pressed):
|
||||
assert(_translate_ui.connect("pressed", _on_translate_pressed) == OK)
|
||||
|
||||
if not _deepl_key.text_changed.is_connected(_deepl_key_text_changed):
|
||||
_deepl_key.text_changed.connect(_deepl_key_text_changed)
|
||||
|
||||
if not _amazon_region.item_selected.is_connected(_on_amazon_region_selection_changed):
|
||||
_amazon_region.item_selected.connect(_on_amazon_region_selection_changed)
|
||||
if not _amazon_access_key.text_changed.is_connected(_amazon_access_key_text_changed):
|
||||
_amazon_access_key.text_changed.connect(_amazon_access_key_text_changed)
|
||||
if not _amazon_secret_key.text_changed.is_connected(_amazon_secret_key_text_changed):
|
||||
_amazon_secret_key.text_changed.connect(_amazon_secret_key_text_changed)
|
||||
|
||||
if not _microsoft_url.is_connected("item_selected", _on_microsoft_url_selection_changed):
|
||||
_microsoft_url.item_selected.connect(_on_microsoft_url_selection_changed)
|
||||
if not _microsoft_location.text_changed.is_connected(_microsoft_location_text_changed):
|
||||
_microsoft_location.text_changed.connect(_microsoft_location_text_changed)
|
||||
if not _microsoft_key.text_changed.is_connected(_microsoft_key_text_changed):
|
||||
_microsoft_key.text_changed.connect(_microsoft_key_text_changed)
|
||||
|
||||
func _on_save_auth_toggled(button_pressed: bool) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _deepl_key_text_changed(_new_text: String) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _microsoft_location_text_changed(_new_text: String) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _amazon_access_key_text_changed(_new_text: String) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _amazon_secret_key_text_changed(_new_text: String) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _on_amazon_region_selection_changed(index: int):
|
||||
_update_auth_settings()
|
||||
|
||||
func _on_microsoft_url_selection_changed(index: int):
|
||||
_update_auth_settings()
|
||||
|
||||
func _microsoft_key_text_changed(_new_text: String) -> void:
|
||||
_update_auth_settings()
|
||||
|
||||
func _update_auth_settings() -> void:
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH, _save_auth.button_pressed)
|
||||
if _save_auth.button_pressed:
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_TRANSLATOR_SELECTION, _translator.selected)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_DEEPL_KEY, _deepl_key.text)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_URL, _microsoft_url.selected)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_LOCATION, _microsoft_location.text)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_KEY, _microsoft_key.text)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_REGION, _translator.selected)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_ACCESS_KEY, _amazon_access_key.text)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_SECRET_KEY, _amazon_secret_key.text)
|
||||
else:
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_TRANSLATOR_SELECTION, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_DEEPL_KEY, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_URL, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_LOCATION, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_MICROSOFT_KEY, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_REGION, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_ACCESS_KEY, null)
|
||||
ProjectSettings.set_setting(SETTINGS_SAVE_AUTH_AMAZON_SECRET_KEY, null)
|
||||
ProjectSettings.save()
|
||||
|
||||
func _update_view() -> void:
|
||||
_init_from_language_ui()
|
||||
_check_translate_ui_selected()
|
||||
|
||||
func _init_from_language_ui() -> void:
|
||||
_from_language_ui.clear()
|
||||
if not _from_language_ui.is_connected("selection_changed", _check_translate_ui):
|
||||
assert(_from_language_ui.connect("selection_changed", _check_translate_ui) == OK)
|
||||
for loc in _data.locales():
|
||||
var label = Locales.label_by_code(loc)
|
||||
if label != null and not label.is_empty():
|
||||
_from_language_ui.add_item(DropdownItem.new(loc, label))
|
||||
|
||||
func _init_to_language_ui(locales: Dictionary) -> void:
|
||||
_to_language_ui.clear()
|
||||
if not _to_language_ui.is_connected("selection_changed", _check_translate_ui):
|
||||
assert(_to_language_ui.connect("selection_changed", _check_translate_ui) == OK)
|
||||
for locale in locales:
|
||||
if Locales.has_code(locale):
|
||||
_to_language_ui.add_item(DropdownItem.new(locale, Locales.label_by_code(locale)))
|
||||
|
||||
func _check_translate_ui(_item: DropdownItem) -> void:
|
||||
_check_translate_ui_selected()
|
||||
|
||||
func _check_translate_ui_selected() -> void:
|
||||
if _translator.selected != -1:
|
||||
_on_translator_selected(_translator.selected)
|
||||
_check_translate_ui_disabled()
|
||||
|
||||
func _check_translate_ui_disabled() -> void:
|
||||
_translate_ui.set_disabled(_from_language_ui.get_selected_index() == -1 or _to_language_ui.get_selected_index() == -1)
|
||||
|
||||
func _on_translator_selection_changed(index: int) -> void:
|
||||
_to_language_ui.clear_selection()
|
||||
_on_translator_selected(index)
|
||||
_update_auth_settings()
|
||||
|
||||
func _on_translator_selected(index: int) -> void:
|
||||
_deepl_container.hide()
|
||||
_amazon_container.hide()
|
||||
_microsoft_container.hide()
|
||||
_check_translate_ui_disabled()
|
||||
match index:
|
||||
0:
|
||||
_link.text = "https://translate.google.com/"
|
||||
_init_to_language_ui(LocalizationAutoTranslateGoogle.LOCALES)
|
||||
1:
|
||||
_link.text = "https://yandex.com/dev/translate/"
|
||||
_init_to_language_ui(LocalizationAutoTranslateYandex.LOCALES)
|
||||
2:
|
||||
_link.text = "https://www.deepl.com/translator"
|
||||
_init_to_language_ui(LocalizationAutoTranslateDeepL.LOCALES)
|
||||
_deepl_container.show()
|
||||
3:
|
||||
_link.text = "https://aws.amazon.com/translate/"
|
||||
_init_to_language_ui(LocalizationAutoTranslateAmazon.LOCALES)
|
||||
_amazon_container.show()
|
||||
4:
|
||||
_link.text = "https://translator.microsoft.com/"
|
||||
_init_to_language_ui(LocalizationAutoTranslateMicrosoft.LOCALES)
|
||||
_microsoft_container.show()
|
||||
|
||||
func _on_link_pressed() -> void:
|
||||
OS.shell_open(_link.text)
|
||||
|
||||
func _on_translate_pressed() -> void:
|
||||
_from_code = _from_language_ui.get_selected_value()
|
||||
_from_code = _from_code.to_lower()
|
||||
_to_code = _to_language_ui.get_selected_value()
|
||||
_to_code = _to_code.to_lower()
|
||||
_translate()
|
||||
|
||||
func _translate() -> void:
|
||||
_data_keys = _data.keys().duplicate()
|
||||
var from_translation = _data.translation_by_locale(_data_keys[0], _from_code)
|
||||
var to_translation = _data.translation_by_locale(_data_keys[0], _to_code)
|
||||
_translate_ui.disabled = true
|
||||
_progress_ui.max_value = _data.keys().size()
|
||||
if not _data.locales().has(_to_code):
|
||||
_data.add_locale(_to_code, false)
|
||||
_create_requests()
|
||||
|
||||
func _create_requests() -> void:
|
||||
var space = IP.RESOLVER_MAX_QUERIES - _queries_count
|
||||
for index in range(space):
|
||||
if _data_keys.size() <= 0:
|
||||
return
|
||||
var from_translation = _data.translation_by_locale(_data_keys[0], _from_code)
|
||||
var to_translation = _data.translation_by_locale(_data_keys[0], _to_code)
|
||||
if from_translation != null and not from_translation.value.is_empty() and (to_translation.value == null or to_translation.value.is_empty()):
|
||||
match _translator.selected:
|
||||
0:
|
||||
_create_request_google(from_translation, to_translation)
|
||||
1:
|
||||
_create_request_yandex(from_translation, to_translation)
|
||||
2:
|
||||
_create_request_deepl(from_translation, to_translation)
|
||||
3:
|
||||
_create_request_amazon(from_translation, to_translation)
|
||||
4:
|
||||
_create_request_microsoft(from_translation, to_translation)
|
||||
else:
|
||||
_add_progress()
|
||||
_data_keys.remove_at(0)
|
||||
_queries_count += 1
|
||||
|
||||
# *** GOOGLE IMPLEMENTATION START ***
|
||||
func _create_request_google(from_translation, to_translation) -> void:
|
||||
var url = _create_url_google(from_translation, to_translation)
|
||||
var http_request = HTTPRequest.new()
|
||||
http_request.timeout = 5
|
||||
add_child(http_request)
|
||||
assert(http_request.request_completed.connect(_http_request_completed_google.bind(http_request, to_translation)) == OK)
|
||||
http_request.request(url, [], HTTPClient.Method.METHOD_GET)
|
||||
|
||||
func _create_url_google(from_translation, to_translation) -> String:
|
||||
var url = "https://translate.googleapis.com/translate_a/single?client=gtx"
|
||||
url += "&sl=" + from_translation.locale
|
||||
url += "&tl=" + to_translation.locale
|
||||
url += "&dt=t"
|
||||
url += "&q=" + from_translation.value.uri_encode()
|
||||
return url
|
||||
|
||||
func _http_request_completed_google(result, response_code, headers, body, http_request, to_translation):
|
||||
var json = JSON.new()
|
||||
var result_body := json.parse(body.get_string_from_utf8())
|
||||
if json.get_data() != null:
|
||||
var value = ""
|
||||
for index in range(json.get_data()[0].size()):
|
||||
if index == 0:
|
||||
value = json.get_data()[0][index][0]
|
||||
else:
|
||||
value += " " + json.get_data()[0][index][0]
|
||||
to_translation.value = value
|
||||
_add_progress()
|
||||
remove_child(http_request)
|
||||
_queries_count -= 1
|
||||
_create_requests()
|
||||
# *** GOOGLE IMPLEMENTATION END ***
|
||||
|
||||
# *** YANDEX IMPLEMENTATION START ***
|
||||
func _create_request_yandex(from_translation, to_translation) -> void:
|
||||
push_error("YANDEX IMPLEMENTATION NOT SUPPORTED YET")
|
||||
return
|
||||
# *** YANDEX IMPLEMENTATION END ***
|
||||
|
||||
# *** DEEPL IMPLEMENTATION START ***
|
||||
func _create_request_deepl(from_translation, to_translation) -> void:
|
||||
var key = _deepl_key.text
|
||||
var text = "text=" + from_translation.value.uri_encode() + "&target_lang=" + to_translation.locale
|
||||
var url = "https://api-free.deepl.com/v2/translate"
|
||||
var http_request = HTTPRequest.new()
|
||||
http_request.timeout = 5
|
||||
add_child(http_request)
|
||||
assert(http_request.request_completed.connect(_http_request_completed_deepl.bind(http_request, from_translation, to_translation)) == OK)
|
||||
var custom_headers = [
|
||||
"Host: api-free.deepl.com",
|
||||
"Authorization: DeepL-Auth-Key " + key,
|
||||
"User-Agent: YourApp/1.2.3",
|
||||
"Content-Length: " + str(text.length()),
|
||||
"Content-Type: application/x-www-form-urlencoded"
|
||||
]
|
||||
http_request.request(url, custom_headers, HTTPClient.Method.METHOD_POST, text)
|
||||
|
||||
func _http_request_completed_deepl(result, response_code, headers, body: PackedByteArray, http_request, from_translation, to_translation):
|
||||
var json = JSON.new()
|
||||
var result_body := json.parse(body.get_string_from_utf8())
|
||||
if json.get_data() != null:
|
||||
if not json.get_data().has("translations"):
|
||||
push_error("FROM: ", from_translation.value, " => ", body.get_string_from_utf8())
|
||||
to_translation.value = json.get_data().translations[0].text
|
||||
_add_progress()
|
||||
remove_child(http_request)
|
||||
_queries_count -= 1
|
||||
_create_requests()
|
||||
# *** DEEPL IMPLEMENTATION END ***
|
||||
|
||||
# *** AMAZON IMPLEMENTATION START ***
|
||||
func _create_request_amazon(from_translation, to_translation) -> void:
|
||||
var method = "POST"
|
||||
var service = "translate"
|
||||
var region = "us-east-2"
|
||||
match _amazon_region.selected:
|
||||
1:
|
||||
region = "us-east-1"
|
||||
2:
|
||||
region = "us-west-1"
|
||||
3:
|
||||
region = "us-west-2"
|
||||
4:
|
||||
region = "ap-east-1"
|
||||
5:
|
||||
region = "ap-south-1"
|
||||
6:
|
||||
region = "ap-northeast-2"
|
||||
7:
|
||||
region = "ap-southeast-1"
|
||||
8:
|
||||
region = "ap-southeast-2"
|
||||
9:
|
||||
region = "ap-northeast-1"
|
||||
10:
|
||||
region = "ca-central-1"
|
||||
11:
|
||||
region = "eu-central-1"
|
||||
12:
|
||||
region = "eu-west-1"
|
||||
13:
|
||||
region = "eu-west-2"
|
||||
14:
|
||||
region = "eu-west-3"
|
||||
15:
|
||||
region = "eu-north-1"
|
||||
16:
|
||||
region = "us-gov-west-1"
|
||||
var host = service + "." + region + ".amazonaws.com"
|
||||
var endpoint = "https://" + host + "/"
|
||||
var content_type = "application/x-amz-json-1.1"
|
||||
var amz_target = "AWSShineFrontendService_20170701.TranslateText"
|
||||
|
||||
var request_parameters = '{'
|
||||
request_parameters += '"Text": "' + from_translation.value + '",'
|
||||
request_parameters += '"SourceLanguageCode": "' + from_translation.locale + '",'
|
||||
request_parameters += '"TargetLanguageCode": "' + to_translation.locale + '"'
|
||||
request_parameters += '}'
|
||||
|
||||
# https://us-east-1.console.aws.amazon.com/iam/
|
||||
var access_key = _amazon_access_key.text
|
||||
var secret_key = _amazon_secret_key.text
|
||||
|
||||
var amz_date = Time.get_datetime_string_from_system(true).replace("-", "").replace(":", "") + "Z"
|
||||
var date_stamp = Time.get_date_string_from_system(true).replace("-", "")
|
||||
var canonical_uri = "/"
|
||||
var canonical_querystring = ""
|
||||
var canonical_headers = "content-type:" + content_type + "\n" + "host:" + host + "\n" + "x-amz-date:" + amz_date + "\n" + "x-amz-target:" + amz_target + "\n"
|
||||
var signed_headers = "content-type;host;x-amz-date;x-amz-target"
|
||||
|
||||
var payload_hash = request_parameters.sha256_text()
|
||||
var canonical_request = method + "\n" + canonical_uri + "\n" + canonical_querystring + "\n" + canonical_headers + "\n" + signed_headers + "\n" + payload_hash
|
||||
var algorithm = "AWS4-HMAC-SHA256"
|
||||
var credential_scope = date_stamp + "/" + region + "/" + service + "/" + "aws4_request"
|
||||
var string_to_sign = algorithm + "\n" + amz_date + "\n" + credential_scope + "\n" + canonical_request.sha256_text()
|
||||
|
||||
var signing_key = getSignatureKey(secret_key, date_stamp, region, service)
|
||||
var signature = signing_hex(signing_key, string_to_sign)
|
||||
var authorization_header = algorithm + " " + "Credential=" + access_key + "/" + credential_scope + ", " + "SignedHeaders=" + signed_headers + ", " + "Signature=" + signature
|
||||
|
||||
var http_request = HTTPRequest.new()
|
||||
http_request.timeout = 5
|
||||
add_child(http_request)
|
||||
assert(http_request.request_completed.connect(_http_request_completed_amazon.bind(http_request, from_translation, to_translation)) == OK)
|
||||
var headers = [
|
||||
"Content-type: application/x-amz-json-1.1",
|
||||
"X-Amz-Date: " + amz_date,
|
||||
"X-Amz-Target: " + amz_target,
|
||||
"Authorization: " + authorization_header
|
||||
]
|
||||
var error = http_request.request(endpoint, headers, HTTPClient.Method.METHOD_POST, request_parameters)
|
||||
|
||||
func getSignatureKey(key, dateStamp, regionName, serviceName):
|
||||
var kDate = signing(("AWS4" + key).to_utf8_buffer(), dateStamp)
|
||||
var kRegion = signing(kDate, regionName)
|
||||
var kService = signing(kRegion, serviceName)
|
||||
return signing(kService, "aws4_request")
|
||||
|
||||
func signing(key: PackedByteArray, msg: String):
|
||||
assert(ctx.start(HashingContext.HASH_SHA256, key) == OK)
|
||||
assert(ctx.update(msg.to_utf8_buffer()) == OK)
|
||||
var hmac = ctx.finish()
|
||||
return hmac
|
||||
|
||||
func signing_hex(key: PackedByteArray, msg: String) -> String:
|
||||
assert(ctx.start(HashingContext.HASH_SHA256, key) == OK)
|
||||
assert(ctx.update(msg.to_utf8_buffer()) == OK)
|
||||
var hmac = ctx.finish()
|
||||
return hmac.hex_encode()
|
||||
|
||||
func _http_request_completed_amazon(result, response_code, headers, body: PackedByteArray, http_request, from_translation, to_translation):
|
||||
var json = JSON.new()
|
||||
var result_body := json.parse(body.get_string_from_utf8())
|
||||
if json.get_data() != null:
|
||||
if not json.get_data().has("TranslatedText"):
|
||||
push_error("FROM: ", from_translation.value, " => ", body.get_string_from_utf8())
|
||||
to_translation.value = json.get_data().TranslatedText
|
||||
_add_progress()
|
||||
remove_child(http_request)
|
||||
_queries_count -= 1
|
||||
_create_requests()
|
||||
|
||||
# *** AMAZON IMPLEMENTATION END ***
|
||||
|
||||
# *** MICROSOFT IMPLEMENTATION START ***
|
||||
func _create_request_microsoft(from_translation, to_translation) -> void:
|
||||
var key = _microsoft_key.text
|
||||
var location = _microsoft_location.text
|
||||
var endpoint = "https://api.cognitive.microsofttranslator.com"
|
||||
match _microsoft_url.selected:
|
||||
1:
|
||||
endpoint = "https://api-apc.congnitive.microsofttranslator.com"
|
||||
2:
|
||||
endpoint = "https://api-eur.congnitive.microsofttranslator.com"
|
||||
3:
|
||||
endpoint = "https://api-nam.congnitive.microsofttranslator.com"
|
||||
var route = "/translate?api-version=3.0&from=en&to=ru"
|
||||
var http_request = HTTPRequest.new()
|
||||
http_request.timeout = 5
|
||||
add_child(http_request)
|
||||
assert(http_request.request_completed.connect(_http_request_completed_microsoft.bind(http_request, from_translation, to_translation)) == OK)
|
||||
var custom_headers = [
|
||||
"Ocp-Apim-Subscription-Key: " + key,
|
||||
"Ocp-Apim-Subscription-Region: " + location,
|
||||
"Content-type: application/json",
|
||||
"X-ClientTraceId: " + uuid_gen.v4()
|
||||
]
|
||||
var url = endpoint + route
|
||||
var body = JSON.stringify([{"Text": from_translation.value}])
|
||||
var error = http_request.request(url, custom_headers, HTTPClient.Method.METHOD_POST, body)
|
||||
|
||||
func _http_request_completed_microsoft(result, response_code, headers, body: PackedByteArray, http_request, from_translation, to_translation):
|
||||
var json = JSON.new()
|
||||
var result_body := json.parse(body.get_string_from_utf8())
|
||||
if json.get_data() != null:
|
||||
if not json.get_data()[0].has("translations"):
|
||||
push_error("FROM: ", from_translation.value, " => ", body.get_string_from_utf8())
|
||||
to_translation.value = json.get_data()[0].translations[0].text
|
||||
_add_progress()
|
||||
remove_child(http_request)
|
||||
_queries_count -= 1
|
||||
_create_requests()
|
||||
# *** MICROSOFT IMPLEMENTATION END ***
|
||||
|
||||
func _add_progress() -> void:
|
||||
_progress_ui.value = _progress_ui.value + 1
|
||||
_check_progress()
|
||||
|
||||
func _check_progress() -> void:
|
||||
if _progress_ui.value == _data.keys().size():
|
||||
_data.emit_signal_data_changed()
|
||||
_translate_ui.disabled = false
|
||||
_progress_ui.value = 0
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://drvspmt3mjcbe
|
||||
|
|
@ -0,0 +1,236 @@
|
|||
[gd_scene load_steps=8 format=3 uid="uid://bssdhtctthadv"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/auto_translate/translator/LocalizationAutoTranslate.gd" id="1_cuqef"]
|
||||
[ext_resource type="Texture2D" uid="uid://byv22srd37niw" path="res://addons/localization_editor/icons/Google.png" id="2_l1peq"]
|
||||
[ext_resource type="Texture2D" uid="uid://chlw8bdg84q1m" path="res://addons/localization_editor/icons/Yandex.png" id="3_ul6cn"]
|
||||
[ext_resource type="Texture2D" uid="uid://c24qna6n2q27l" path="res://addons/localization_editor/icons/DeepL.png" id="4_142cw"]
|
||||
[ext_resource type="Texture2D" uid="uid://cfu2uuf8hh0c" path="res://addons/localization_editor/icons/Amazon.png" id="5_0oig7"]
|
||||
[ext_resource type="Texture2D" uid="uid://dekewvpr4ic2c" path="res://addons/localization_editor/icons/Microsoft.png" id="6_tal6j"]
|
||||
[ext_resource type="PackedScene" path="res://addons/ui_extensions/dropdown/Dropdown.tscn" id="7_jsbqb"]
|
||||
|
||||
[node name="LocalizationAutotranslateGoogle" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource("1_cuqef")
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Panel"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="HBoxTranslator" type="HBoxContainer" parent="Panel/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/VBox/HBoxTranslator"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Translator"
|
||||
|
||||
[node name="Translator" type="OptionButton" parent="Panel/VBox/HBoxTranslator"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Select translation engine"
|
||||
item_count = 5
|
||||
selected = 0
|
||||
popup/item_0/text = ""
|
||||
popup/item_0/icon = ExtResource("2_l1peq")
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = ""
|
||||
popup/item_1/icon = ExtResource("3_ul6cn")
|
||||
popup/item_1/id = 1
|
||||
popup/item_1/disabled = true
|
||||
popup/item_2/text = ""
|
||||
popup/item_2/icon = ExtResource("4_142cw")
|
||||
popup/item_2/id = 2
|
||||
popup/item_3/text = ""
|
||||
popup/item_3/icon = ExtResource("5_0oig7")
|
||||
popup/item_3/id = 3
|
||||
popup/item_4/text = ""
|
||||
popup/item_4/icon = ExtResource("6_tal6j")
|
||||
popup/item_4/id = 4
|
||||
|
||||
[node name="LinkButton" type="LinkButton" parent="Panel/VBox/HBoxTranslator"]
|
||||
layout_mode = 2
|
||||
text = "https://translate.google.com/"
|
||||
|
||||
[node name="SaveAuth" type="CheckBox" parent="Panel/VBox/HBoxTranslator"]
|
||||
layout_mode = 2
|
||||
text = "Save Authentication Data"
|
||||
|
||||
[node name="HBoxMicrosoft" type="HBoxContainer" parent="Panel/VBox"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelURL" type="Label" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Base URL:
|
||||
"
|
||||
|
||||
[node name="URL" type="OptionButton" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
layout_mode = 2
|
||||
tooltip_text = "Select BAse-URL for translation service"
|
||||
item_count = 4
|
||||
selected = 0
|
||||
popup/item_0/text = "GLOBAL | api.cognitive.microsofttranslator.com"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "ASIA PACIFIC | api-apc.congnitive.microsofttranslator.com"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "EUROPE | api-eur.congnitive.microsofttranslator.com"
|
||||
popup/item_2/id = 2
|
||||
popup/item_3/text = "UNITED STATES | api-nam.congnitive.microsofttranslator.com"
|
||||
popup/item_3/id = 3
|
||||
|
||||
[node name="LabelLocation" type="Label" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Location:"
|
||||
|
||||
[node name="Location" type="LineEdit" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
custom_minimum_size = Vector2(160, 0)
|
||||
layout_mode = 2
|
||||
tooltip_text = "Location/Region for translation service"
|
||||
|
||||
[node name="LabelKey" type="Label" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
custom_minimum_size = Vector2(50, 0)
|
||||
layout_mode = 2
|
||||
text = "Key:"
|
||||
|
||||
[node name="Key" type="LineEdit" parent="Panel/VBox/HBoxMicrosoft"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Insert Ocp-Apim-Subscription-Key for authorisation"
|
||||
secret = true
|
||||
|
||||
[node name="VBoxAWS" type="VBoxContainer" parent="Panel/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBoxRegion" type="HBoxContainer" parent="Panel/VBox/VBoxAWS"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelRegion" type="Label" parent="Panel/VBox/VBoxAWS/HBoxRegion"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Region:"
|
||||
|
||||
[node name="Region" type="OptionButton" parent="Panel/VBox/VBoxAWS/HBoxRegion"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Select BAse-URL for translation service"
|
||||
item_count = 17
|
||||
popup/item_0/text = "US East (Ohio) | translate.us-east-2.amazonaws.com"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "US East (N. Virginia) | translate.us-east-1.amazonaws.com"
|
||||
popup/item_1/id = 1
|
||||
popup/item_2/text = "US West (N. California) | translate.us-west-1.amazonaws.com"
|
||||
popup/item_2/id = 2
|
||||
popup/item_3/text = "US West (Oregon) | translate.us-west-2.amazonaws.com"
|
||||
popup/item_3/id = 3
|
||||
popup/item_4/text = "Asia Pacific (Hong Kong) | translate.ap-east-1.amazonaws.com"
|
||||
popup/item_4/id = 4
|
||||
popup/item_5/text = "Asia Pacific (Mumbai) | translate.ap-south-1.amazonaws.com"
|
||||
popup/item_5/id = 5
|
||||
popup/item_6/text = "Asia Pacific (Seoul) | translate.ap-northeast-2.amazonaws.com"
|
||||
popup/item_6/id = 6
|
||||
popup/item_7/text = "Asia Pacific (Singapore) | translate.ap-southeast-1.amazonaws.com"
|
||||
popup/item_7/id = 7
|
||||
popup/item_8/text = "Asia Pacific (Sydney) | translate.ap-southeast-2.amazonaws.com"
|
||||
popup/item_8/id = 8
|
||||
popup/item_9/text = "Asia Pacific (Tokyo) | translate.ap-northeast-1.amazonaws.com"
|
||||
popup/item_9/id = 9
|
||||
popup/item_10/text = "Canada (Central) | translate.ca-central-1.amazonaws.com"
|
||||
popup/item_10/id = 10
|
||||
popup/item_11/text = "Europe (Frankfurt) | translate.eu-central-1.amazonaws.com"
|
||||
popup/item_11/id = 11
|
||||
popup/item_12/text = "Europe (Ireland) | translate.eu-west-1.amazonaws.com"
|
||||
popup/item_12/id = 12
|
||||
popup/item_13/text = "Europe (London) | translate.eu-west-2.amazonaws.com"
|
||||
popup/item_13/id = 13
|
||||
popup/item_14/text = "Europe (Paris) | translate.eu-west-3.amazonaws.com"
|
||||
popup/item_14/id = 14
|
||||
popup/item_15/text = "Europe (Stockholm) | translate.eu-north-1.amazonaws.com"
|
||||
popup/item_15/id = 15
|
||||
popup/item_16/text = "AWS GovCloud (US-West) | translate.us-gov-west-1.amazonaws.com"
|
||||
popup/item_16/id = 16
|
||||
|
||||
[node name="HBoxAccessKey" type="HBoxContainer" parent="Panel/VBox/VBoxAWS"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelAccessKey" type="Label" parent="Panel/VBox/VBoxAWS/HBoxAccessKey"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "AccessKey:"
|
||||
|
||||
[node name="AccessKey" type="LineEdit" parent="Panel/VBox/VBoxAWS/HBoxAccessKey"]
|
||||
custom_minimum_size = Vector2(160, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Location/Region for translation service"
|
||||
secret = true
|
||||
|
||||
[node name="HBoxSecretKey" type="HBoxContainer" parent="Panel/VBox/VBoxAWS"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="LabelSecretKey" type="Label" parent="Panel/VBox/VBoxAWS/HBoxSecretKey"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "SecretKey:"
|
||||
|
||||
[node name="SecretKey" type="LineEdit" parent="Panel/VBox/VBoxAWS/HBoxSecretKey"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Insert Ocp-Apim-Subscription-Key for authorisation"
|
||||
secret = true
|
||||
|
||||
[node name="HBoxDeepL" type="HBoxContainer" parent="Panel/VBox"]
|
||||
visible = false
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="Panel/VBox/HBoxDeepL"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "Key:"
|
||||
|
||||
[node name="DeepLKey" type="LineEdit" parent="Panel/VBox/HBoxDeepL"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
tooltip_text = "Insert DeepL-Auth-Key for authorisation"
|
||||
secret = true
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="Panel/VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="From" type="Label" parent="Panel/VBox/HBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "From:"
|
||||
|
||||
[node name="FromLanguage" parent="Panel/VBox/HBox" instance=ExtResource("7_jsbqb")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="To" type="Label" parent="Panel/VBox/HBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
text = "To:"
|
||||
|
||||
[node name="ToLanguage" parent="Panel/VBox/HBox" instance=ExtResource("7_jsbqb")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Translate" type="Button" parent="Panel/VBox/HBox"]
|
||||
layout_mode = 2
|
||||
disabled = true
|
||||
text = "Translate"
|
||||
|
||||
[node name="Progress" type="ProgressBar" parent="Panel/VBox"]
|
||||
layout_mode = 2
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
# List of locales supported by Amazon translator for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# @see https://aws.amazon.com/translate/
|
||||
class_name LocalizationAutoTranslateAmazon
|
||||
|
||||
const LOCALES = {
|
||||
"af": "Afrikaans",
|
||||
"sq": "Albanian",
|
||||
"am": "Amharic",
|
||||
"ar": "Arabic",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"bn": "Bengali",
|
||||
"bs": "Bosnian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"zh": "Chinese (Simplified)",
|
||||
"zh-TW": "Chinese (Traditional)",
|
||||
"hr": "Croatian",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"fa-AF": "Dari",
|
||||
"nl": "Dutch",
|
||||
"en": "English",
|
||||
"et": "Estonian",
|
||||
"fa": "Farsi (Persian)",
|
||||
"tl": "Filipino, Tagalog",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"fr-CA": "French (Canada)",
|
||||
"ka": "Georgian",
|
||||
"de": "German",
|
||||
"el": "Greek",
|
||||
"gu": "Gujarati",
|
||||
"ht": "Haitian Creole",
|
||||
"ha": "Hausa",
|
||||
"he": "Hebrew",
|
||||
"hi": "Hindi",
|
||||
"hu": "Hungarian",
|
||||
"is": "Icelandic",
|
||||
"id": "Indonesian",
|
||||
"ga": "Irish",
|
||||
"it": "Italian",
|
||||
"ja": "Japanese",
|
||||
"kn": "Kannada",
|
||||
"kk": "Kazakh",
|
||||
"ko": "Korean",
|
||||
"lv": "Latvian",
|
||||
"lt": "Lithuanian",
|
||||
"mk": "Macedonian",
|
||||
"ms": "Malay",
|
||||
"ml": "Malayalam",
|
||||
"mt": "Maltese",
|
||||
"mr": "Marathi",
|
||||
"mn": "Mongolian",
|
||||
"no": "Norwegian (Bokmål)",
|
||||
"ps": "Pashto",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese (Brazil)",
|
||||
"pt-PT": "Portuguese (Portugal)",
|
||||
"pa": "Punjabi",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sr": "Serbian",
|
||||
"si": "Sinhala",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"so": "Somali",
|
||||
"es": "Spanish",
|
||||
"es-MX": "Spanish (Mexico)",
|
||||
"sw": "Swahili",
|
||||
"sv": "Swedish",
|
||||
"ta": "Tamil",
|
||||
"te": "Telugu",
|
||||
"th": "Thai",
|
||||
"tr": "Turkish",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"uz": "Uzbek",
|
||||
"vi": "Vietnamese",
|
||||
"cy": "Welsh"
|
||||
}
|
||||
|
||||
static func label_by_code(code: String) -> String:
|
||||
if LOCALES.has(code.to_lower()):
|
||||
return code + " " + LOCALES[code.to_lower()]
|
||||
return ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dwj6srgm447ko
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
# List of locales supported by DeepL translator for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# @see https://www.deepl.com/docs-api/translate-text/translate-text/
|
||||
class_name LocalizationAutoTranslateDeepL
|
||||
|
||||
const LOCALES = {
|
||||
"BG": "Bulgarian",
|
||||
"CS": "Czech",
|
||||
"DA": "Danish",
|
||||
"DE": "German",
|
||||
"EL": "Greek",
|
||||
"EN-GB": "English (British)",
|
||||
"EN-US": "English (American)",
|
||||
"ES": "Spanish",
|
||||
"ET": "Estonian",
|
||||
"FI": "Finnish",
|
||||
"FR": "French",
|
||||
"HU": "Hungarian",
|
||||
"ID": "Indonesian",
|
||||
"IT": "Italian",
|
||||
"JA": "Japanese",
|
||||
"LT": "Lithuanian",
|
||||
"LV": "Latvian",
|
||||
"NL": "Dutch",
|
||||
"PL": "Polish",
|
||||
"PT-BR": "Portuguese (Brazilian)",
|
||||
"PT-PT": "Portuguese (all Portuguese varieties excluding Brazilian Portuguese)",
|
||||
"RO": "Romanian",
|
||||
"RU": "Russian",
|
||||
"SK": "Slovak",
|
||||
"SL": "Slovenian",
|
||||
"SV": "Swedish",
|
||||
"TR": "Turkish",
|
||||
"UK": "Ukrainian",
|
||||
"ZH": "Chinese (simplified)"
|
||||
}
|
||||
|
||||
static func label_by_code(code: String) -> String:
|
||||
if LOCALES.has(code.to_lower()):
|
||||
return code + " " + LOCALES[code.to_lower()]
|
||||
return ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://btouwcoi8yik5
|
||||
|
|
@ -0,0 +1,122 @@
|
|||
# List of locales supported by Google translator for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# @see https://cloud.google.com/translate/docs/languages
|
||||
class_name LocalizationAutoTranslateGoogle
|
||||
|
||||
const LOCALES = {
|
||||
"af": "Afrikaans",
|
||||
"sq": "Albanian",
|
||||
"am": "Amharic",
|
||||
"ar": "Arabic",
|
||||
"hy": "Armenian",
|
||||
"az": "Azerbaijani",
|
||||
"eu": "Basque",
|
||||
"be": "Belarusian",
|
||||
"bn": "Bengali",
|
||||
"bs": "Bosnian",
|
||||
"bg": "Bulgarian",
|
||||
"ca": "Catalan",
|
||||
"ceb": "Cebuano",
|
||||
"zh": "Chinese (Simplified)",
|
||||
"zh-TW": "Chinese (Traditional)",
|
||||
"co": "Corsican",
|
||||
"hr": "Croatian",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"nl": "Dutch",
|
||||
"en": "English",
|
||||
"eo": "Esperanto",
|
||||
"et": "Estonian",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"fy": "Frisian",
|
||||
"gl": "Galician",
|
||||
"ka": "Georgian",
|
||||
"de": "German",
|
||||
"el": "Greek",
|
||||
"gu": "Gujarati",
|
||||
"ht": "Haitian Creole",
|
||||
"ha": "Hausa",
|
||||
"haw": "Hawaiian",
|
||||
"he": "Hebrew",
|
||||
"iw": "Hebrew",
|
||||
"hi": "Hindi",
|
||||
"hmn": "Hmong",
|
||||
"hu": "Hungarian",
|
||||
"is": "Icelandic",
|
||||
"ig": "Igbo",
|
||||
"id": "Indonesian",
|
||||
"ga": "Irish",
|
||||
"it": "Italian",
|
||||
"ja": "Japanese",
|
||||
"jv": "Javanese",
|
||||
"kn": "Kannada",
|
||||
"kk": "Kazakh",
|
||||
"km": "Khmer",
|
||||
"rw": "Kinyarwanda",
|
||||
"ko": "Korean",
|
||||
"ku": "Kurdish",
|
||||
"ky": "Kyrgyz",
|
||||
"lo": "Lao",
|
||||
"la": "Latin",
|
||||
"lv": "Latvian",
|
||||
"lt": "Lithuanian",
|
||||
"lb": "Luxembourgish",
|
||||
"mk": "Macedonian",
|
||||
"mg": "Malagasy",
|
||||
"ms": "Malay",
|
||||
"ml": "Malayalam",
|
||||
"mt": "Maltese",
|
||||
"mi": "Maori",
|
||||
"mr": "Marathi",
|
||||
"mn": "Mongolian",
|
||||
"my": "Myanmar (Burmese)",
|
||||
"ne": "Nepali",
|
||||
"no": "Norwegian",
|
||||
"ny": "Nyanja (Chichewa)",
|
||||
"or": "Odia (Oriya)",
|
||||
"ps": "Pashto",
|
||||
"fa": "Persian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese (Portugal, Brazil)",
|
||||
"pa": "Punjabi",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sm": "Samoan",
|
||||
"gd": "Scots Gaelic",
|
||||
"sr": "Serbian",
|
||||
"st": "Sesotho",
|
||||
"sn": "Shona",
|
||||
"sd": "Sindhi",
|
||||
"si": "Sinhala (Sinhalese)",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"so": "Somali",
|
||||
"es": "Spanish",
|
||||
"su": "Sundanese",
|
||||
"sw": "Swahili",
|
||||
"sv": "Swedish",
|
||||
"tl": "Tagalog (Filipino)",
|
||||
"tg": "Tajik",
|
||||
"ta": "Tamil",
|
||||
"tt": "Tatar",
|
||||
"te": "Telugu",
|
||||
"th": "Thai",
|
||||
"tr": "Turkish",
|
||||
"tk": "Turkmen",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"ug": "Uyghur",
|
||||
"uz": "Uzbek",
|
||||
"vi": "Vietnamese",
|
||||
"cy": "Welsh",
|
||||
"xh": "Xhosa",
|
||||
"yi": "Yiddish",
|
||||
"yo": "Yoruba",
|
||||
"zu": "Zulu"
|
||||
}
|
||||
|
||||
static func label_by_code(code: String) -> String:
|
||||
if LOCALES.has(code.to_lower()):
|
||||
return code + " " + LOCALES[code.to_lower()]
|
||||
return ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cmruim7wjelew
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
# List of locales supported by Microsoft translator for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# @see https://translator.microsoft.com/
|
||||
class_name LocalizationAutoTranslateMicrosoft
|
||||
|
||||
const LOCALES = {
|
||||
"af": "Afrikaans",
|
||||
"sq": "Albanian",
|
||||
"am": "Amharic",
|
||||
"ar": "Arabic",
|
||||
"hy": "Armenian",
|
||||
"as": "Assamese",
|
||||
"az": "Azerbaijani (Latin)",
|
||||
"bn": "Bangla",
|
||||
"ba": "Bashkir",
|
||||
"eu": "Basque",
|
||||
"bs": "Bosnian (Latin)",
|
||||
"bg": "Bulgarian",
|
||||
"yue": "Cantonese (Traditional)",
|
||||
"ca": "Catalan",
|
||||
"lzh": "Chinese (Literary)",
|
||||
"zh-Hans": "Chinese Simplified",
|
||||
"zh-Hant": "Chinese Traditional",
|
||||
"hr": "Croatian",
|
||||
"cs": "Czech",
|
||||
"da": "Danish",
|
||||
"prs": "Dari",
|
||||
"dv": "Divehi",
|
||||
"nl": "Dutch",
|
||||
"en": "English",
|
||||
"et": "Estonian",
|
||||
"fo": "Faroese",
|
||||
"fj": "Fijian",
|
||||
"fil": "Filipino",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"fr-ca": "French (Canada)",
|
||||
"gl": "Galician",
|
||||
"ka": "Georgian",
|
||||
"de": "German",
|
||||
"el": "Greek",
|
||||
"gu": "Gujarati",
|
||||
"ht": "Haitian Creole",
|
||||
"he": "Hebrew",
|
||||
"hi": "Hindi",
|
||||
"mww": "Hmong Daw (Latin)",
|
||||
"hu": "Hungarian",
|
||||
"is": "Icelandic",
|
||||
"id": "Indonesian",
|
||||
"ikt": "Inuinnaqtun",
|
||||
"iu": "Inuktitut",
|
||||
"iu-Latn": "Inuktitut (Latin)",
|
||||
"ga": "Irish",
|
||||
"it": "Italian",
|
||||
"ja": "Japanese",
|
||||
"kn": "Kannada",
|
||||
"kk": "Kazakh",
|
||||
"km": "Khmer",
|
||||
"tlh-Latn": "Klingon",
|
||||
"tlh-Piqd": "Klingon (plqaD)",
|
||||
"ko": "Korean",
|
||||
"ku": "Kurdish (Central)",
|
||||
"kmr": "Kurdish (Northern)",
|
||||
"ky": "Kyrgyz (Cyrillic)",
|
||||
"lo": "Lao",
|
||||
"lv": "Latvian",
|
||||
"lt": "Lithuanian",
|
||||
"mk": "Macedonian",
|
||||
"mg": "Malagasy",
|
||||
"ms": "Malay (Latin)",
|
||||
"ml": "Malayalam",
|
||||
"mt": "Maltese",
|
||||
"mi": "Maori",
|
||||
"mr": "Marathi",
|
||||
"mn-Cyrl": "Mongolian (Cyrillic)",
|
||||
"mn-Mong": "Mongolian (Traditional)",
|
||||
"my": "Myanmar",
|
||||
"ne": "Nepali",
|
||||
"nb": "Norwegian",
|
||||
"or": "Odia",
|
||||
"ps": "Pashto",
|
||||
"fa": "Persian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese (Brazil)",
|
||||
"pt-pt": "Portuguese (Portugal)",
|
||||
"pa": "Punjabi",
|
||||
"otq": "Queretaro Otomi",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"sm": "Samoan (Latin)",
|
||||
"sr-Cyrl": "Serbian (Cyrillic)",
|
||||
"sr-Latn": "Serbian (Latin)",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"so": "Somali (Arabic)",
|
||||
"es": "Spanish",
|
||||
"sw": "Swahili (Latin)",
|
||||
"sv": "Swedish",
|
||||
"ty": "Tahitian",
|
||||
"ta": "Tamil",
|
||||
"tt": "Tatar (Latin)",
|
||||
"te": "Telugu",
|
||||
"th": "Thai",
|
||||
"bo": "Tibetan",
|
||||
"ti": "Tigrinya",
|
||||
"to": "Tongan",
|
||||
"tr": "Turkish",
|
||||
"tk": "Turkmen (Latin)",
|
||||
"uk": "Ukrainian",
|
||||
"hsb": "Upper Sorbian",
|
||||
"ur": "Urdu",
|
||||
"ug": "Uyghur (Arabic)",
|
||||
"uz": "Uzbek (Latin)",
|
||||
"vi": "Vietnamese",
|
||||
"cy": "Welsh",
|
||||
"yua": "Yucatec Maya",
|
||||
"zu": "Zulu"
|
||||
}
|
||||
|
||||
static func label_by_code(code: String) -> String:
|
||||
if LOCALES.has(code.to_lower()):
|
||||
return code + " " + LOCALES[code.to_lower()]
|
||||
return ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bnj6s02g52voy
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
# List of locales supported by Yandex translator for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# @see https://www.deepl.com/docs-api/translate-text/translate-text/
|
||||
class_name LocalizationAutoTranslateYandex
|
||||
|
||||
const LOCALES = {
|
||||
"az": "Azerbaijani",
|
||||
"sq": "Albanian",
|
||||
"am": "Amharic",
|
||||
"en": "English",
|
||||
"ar": "Arabic",
|
||||
"hy": "Armenian",
|
||||
"af": "Afrikaans",
|
||||
"eu": "Basque",
|
||||
"ba": "Bashkir",
|
||||
"be": "Belarusian",
|
||||
"bn": "Bengal",
|
||||
"my": "Burmese",
|
||||
"bg": "Bulgarian",
|
||||
"bs": "Bosnian",
|
||||
"cy": "Welsh",
|
||||
"hu": "Hungarian",
|
||||
"vi": "Vietnamese",
|
||||
"ht": "Haitian (Creole)",
|
||||
"gl": "Galician",
|
||||
"nl": "Dutch",
|
||||
"mrj": "Hill Mari",
|
||||
"el": "Greek",
|
||||
"ka": "Georgian",
|
||||
"gu": "Gujarati",
|
||||
"da": "Danish",
|
||||
"he": "Hebrew",
|
||||
"yi": "Yiddish",
|
||||
"id": "Indonesian",
|
||||
"ga": "Irish",
|
||||
"it": "Italian",
|
||||
"is": "Icelandic",
|
||||
"es": "Spanish",
|
||||
"kk": "Kazakh",
|
||||
"kn": "Kannada",
|
||||
"ca": "Catalan",
|
||||
"ky": "Kirghiz",
|
||||
"zh": "Chinese",
|
||||
"ko": "Korean",
|
||||
"xh": "Xhosa",
|
||||
"km": "Khmer",
|
||||
"lo": "Laotian",
|
||||
"la": "Latin",
|
||||
"lv": "Latvian",
|
||||
"lt": "Lithuanian",
|
||||
"lb": "Luxembourg",
|
||||
"mg": "Malagasy",
|
||||
"ms": "Malay",
|
||||
"ml": "Malayalam",
|
||||
"mt": "Maltese",
|
||||
"mk": "Macedonian",
|
||||
"mi": "Maori",
|
||||
"mr": "Marathi",
|
||||
"mhr": "Mari",
|
||||
"mn": "Mongolian",
|
||||
"de": "German",
|
||||
"ne": "Nepalese",
|
||||
"no": "Norwegian",
|
||||
"pa": "Punjabi",
|
||||
"pap": "Papiamento",
|
||||
"fa": "Persian",
|
||||
"pl": "Polish",
|
||||
"pt": "Portuguese",
|
||||
"ro": "Romanian",
|
||||
"ru": "Russian",
|
||||
"ceb": "Cebuano",
|
||||
"sr": "Serbian",
|
||||
"si": "Sinhalese",
|
||||
"sk": "Slovak",
|
||||
"sl": "Slovenian",
|
||||
"sw": "Swahili",
|
||||
"su": "Sundanese",
|
||||
"tg": "Tajik",
|
||||
"th": "Thai",
|
||||
"tl": "Tagalog",
|
||||
"ta": "Tamil",
|
||||
"tt": "Tartar",
|
||||
"te": "Telugu",
|
||||
"tr": "Turkish",
|
||||
"udm": "Udmurt",
|
||||
"uz": "Uzbek",
|
||||
"uk": "Ukrainian",
|
||||
"ur": "Urdu",
|
||||
"fi": "Finnish",
|
||||
"fr": "French",
|
||||
"hi": "Hindi",
|
||||
"hr": "Croatian",
|
||||
"cs": "Czech",
|
||||
"sv": "Swedish",
|
||||
"gd": "Scottish",
|
||||
"et": "Estonian",
|
||||
"eo": "Esperanto",
|
||||
"jv": "Javanese",
|
||||
"ja": "Japanese"
|
||||
}
|
||||
|
||||
static func label_by_code(code: String) -> String:
|
||||
if LOCALES.has(code.to_lower()):
|
||||
return code + " " + LOCALES[code.to_lower()]
|
||||
return ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bh3c1fjwk1euw
|
||||
|
|
@ -0,0 +1,92 @@
|
|||
# Locale UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _locale
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _selection_ui = $HBox/Selection as CheckBox
|
||||
@onready var _locale_ui = $HBox/Locale as Label
|
||||
@onready var _eye_ui = $HBox/Eye as TextureButton
|
||||
|
||||
const IconOpen = preload("res://addons/localization_editor/icons/Open.svg")
|
||||
const IconClose = preload("res://addons/localization_editor/icons/Close.svg")
|
||||
|
||||
func locale():
|
||||
return _locale
|
||||
|
||||
func set_data(locale, data: LocalizationData) -> void:
|
||||
_locale = locale
|
||||
_data = data
|
||||
_draw_view()
|
||||
_init_connections()
|
||||
|
||||
func _draw_view() -> void:
|
||||
_selection_ui.text = _locale
|
||||
_locale_ui.text = LocalizationLocalesList.label_by_code(_locale)
|
||||
_selection_ui_state()
|
||||
_eye_ui_state()
|
||||
|
||||
func _selection_ui_state() -> void:
|
||||
_selection_ui.set_pressed(_data.find_locale(_locale) != null)
|
||||
|
||||
func _eye_ui_state() -> void:
|
||||
_eye_ui.set_pressed(not _data.is_locale_visible(_locale))
|
||||
_update_view_eye(_selection_ui.is_pressed())
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _selection_ui.is_connected("toggled", _on_selection_changed):
|
||||
assert(_selection_ui.toggled.connect(_on_selection_changed) == OK)
|
||||
if not _eye_ui.is_connected("toggled", _on_eye_changed):
|
||||
assert(_eye_ui.toggled.connect(_on_eye_changed) == OK)
|
||||
|
||||
func _on_selection_changed(value) -> void:
|
||||
if value == true:
|
||||
_data.add_locale(_locale)
|
||||
_update_view_eye(value)
|
||||
else:
|
||||
_show_confirm_dialog()
|
||||
|
||||
func _show_confirm_dialog() -> void:
|
||||
var root = get_tree().get_root()
|
||||
var confirm_dialog = ConfirmationDialog.new()
|
||||
confirm_dialog.title = "Confirm"
|
||||
confirm_dialog.dialog_text = "Are you sure to delete locale with all translations and remaps?"
|
||||
confirm_dialog.confirmed.connect(_on_confirm_dialog_ok.bind(root, confirm_dialog))
|
||||
confirm_dialog.cancelled.connect(_on_confirm_dialog_cancelled.bind(root, confirm_dialog))
|
||||
root.add_child(confirm_dialog)
|
||||
confirm_dialog.popup_centered()
|
||||
|
||||
func _on_confirm_dialog_ok(root, confirm_dialog) -> void:
|
||||
_data.del_locale(_locale)
|
||||
_update_view_eye(false)
|
||||
_confirm_dialog_remove(root, confirm_dialog)
|
||||
|
||||
func _on_confirm_dialog_cancelled(root, confirm_dialog) -> void:
|
||||
_selection_ui.set_pressed(true)
|
||||
_confirm_dialog_remove(root, confirm_dialog)
|
||||
|
||||
func _confirm_dialog_remove(root, confirm_dialog) -> void:
|
||||
root.remove_child(confirm_dialog)
|
||||
confirm_dialog.queue_free()
|
||||
|
||||
func _update_view_eye(value: bool) -> void:
|
||||
if value:
|
||||
_eye_ui.show()
|
||||
_update_visible_icon_from_data()
|
||||
else:
|
||||
_eye_ui.hide()
|
||||
|
||||
func _update_visible_icon_from_data() -> void:
|
||||
_update_visible_icon(_data.is_locale_visible(_locale))
|
||||
|
||||
func _on_eye_changed(value) -> void:
|
||||
if value:
|
||||
_data.setting_locales_visibility_put(_locale)
|
||||
else:
|
||||
_data.setting_locales_visibility_del(_locale)
|
||||
_update_visible_icon(!value)
|
||||
|
||||
func _update_visible_icon(value: bool) -> void:
|
||||
_eye_ui.texture_normal = IconOpen if value else IconClose
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://crfl2nduqv6fy
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://c8jdbet30gbuk"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocale.gd" id="2"]
|
||||
|
||||
[node name="Locale" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_top = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
script = ExtResource( "2" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_top = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Selection" type="CheckBox" parent="HBox"]
|
||||
offset_right = 80.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(80, 0)
|
||||
hint_tooltip = "Select language for translation"
|
||||
size_flags_vertical = 0
|
||||
text = "en"
|
||||
|
||||
[node name="Locale" type="Label" parent="HBox"]
|
||||
offset_left = 84.0
|
||||
offset_right = 994.0
|
||||
offset_bottom = 26.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
text = "English"
|
||||
|
||||
[node name="Eye" type="TextureButton" parent="HBox"]
|
||||
offset_left = 998.0
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 20.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
size_flags_vertical = 0
|
||||
toggle_mode = true
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
# Locales UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _locales_ui = $Panel/Scroll/VBox as VBoxContainer
|
||||
|
||||
const LocalizationLocale = preload("res://addons/localization_editor/scenes/locales/LocalizationLocale.tscn")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_view()
|
||||
_draw_view()
|
||||
|
||||
func _clear_view() -> void:
|
||||
for child in _locales_ui.get_children():
|
||||
_locales_ui.remove_child(child)
|
||||
child.queue_free()
|
||||
|
||||
func _draw_view() -> void:
|
||||
for locale in LocalizationLocalesList.LOCALES:
|
||||
if _is_locale_to_show(locale):
|
||||
var locale_ui = LocalizationLocale.instantiate()
|
||||
_locales_ui.add_child(locale_ui)
|
||||
locale_ui.set_data(locale, _data)
|
||||
|
||||
func _is_locale_to_show(locale) -> bool:
|
||||
if not _is_locale_to_show_by_selection(locale):
|
||||
return false
|
||||
return _is_locale_to_show_by_filter(locale)
|
||||
|
||||
func _is_locale_to_show_by_selection(locale) -> bool:
|
||||
return !_data.locales_selected() or _data.find_locale(locale) != null
|
||||
|
||||
func _is_locale_to_show_by_filter(locale) -> bool:
|
||||
var filter = _data.locales_filter()
|
||||
return filter == "" or filter in locale or filter in LocalizationLocalesList.label_by_code(locale)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b6clr41xvv4yr
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://6ma47o0u2v2l"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocales.gd" id="1"]
|
||||
|
||||
[node name="LocalizationLocales" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Panel" type="Panel" parent="."]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="Panel/Scroll"]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
# Locales view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
@onready var _filter_ui = $Filter
|
||||
@onready var _locales_ui = $Locales
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_filter_ui.set_data(data)
|
||||
_locales_ui.set_data(data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://df2ql0j1qx2ag
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://bikmkc3ntiugr"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/locales/LocalizationLocalesEditorView.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://addons/localization_editor/scenes/locales/LocalizationLocalesFilter.tscn" id="2"]
|
||||
[ext_resource type="PackedScene" uid="uid://6ma47o0u2v2l" path="res://addons/localization_editor/scenes/locales/LocalizationLocales.tscn" id="3"]
|
||||
|
||||
[node name="LocalizationLocalesEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Filter" parent="." instance=ExtResource( "2" )]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 33.0
|
||||
|
||||
[node name="Locales" parent="." instance=ExtResource( "3" )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_top = 37.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
# Locales filter for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _filter_ui = $HBox/Filter as LineEdit
|
||||
@onready var _selected_ui = $HBox/Selected as CheckBox
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _filter_ui.is_connected("text_changed", _on_filter_changed):
|
||||
assert(_filter_ui.text_changed.connect(_on_filter_changed) == OK)
|
||||
if not _selected_ui.is_connected("toggled", _on_selected_changed):
|
||||
assert(_selected_ui.toggled.connect(_on_selected_changed) == OK)
|
||||
|
||||
func _on_filter_changed(text: String) -> void:
|
||||
_data.set_locales_filter(text)
|
||||
|
||||
func _on_selected_changed(value) -> void:
|
||||
_data.set_locales_selected(value)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d2wo8kjq5u2t
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/locales/LocalizationLocalesFilter.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationLocalesFilter" type="MarginContainer"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
|
||||
[node name="Filter" type="LineEdit" parent="HBox"]
|
||||
margin_right = 937.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Enter text to filter locales"
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Filter"
|
||||
|
||||
[node name="Selected" type="CheckBox" parent="HBox"]
|
||||
margin_left = 941.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 38.0
|
||||
hint_tooltip = "Check to view only selected locales"
|
||||
text = "Selected"
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
# Placeholder UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _locale
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _placeholder_ui = $HBox/Placeholder
|
||||
|
||||
const Locales = preload("res://addons/localization_editor/model/LocalizationLocalesList.gd")
|
||||
|
||||
func set_data(key, locale, data: LocalizationData) -> void:
|
||||
_key = key
|
||||
_locale = locale
|
||||
_data = data
|
||||
_draw_view()
|
||||
|
||||
func _ready() -> void:
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _placeholder_ui.is_connected("text_changed", _on_text_changed):
|
||||
assert(_placeholder_ui.text_changed.connect(_on_text_changed) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_placeholder_ui.text = _data.data_placeholders[_key][_locale]
|
||||
|
||||
func _on_text_changed(new_text) -> void:
|
||||
_data.data_placeholders[_key][_locale] = new_text
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cnxexngce4bck
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholder.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationPlaceholder" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2( 0, 27 )
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
margin_left = 3.0
|
||||
margin_right = 1021.0
|
||||
margin_bottom = 24.0
|
||||
rect_min_size = Vector2( 0, 24 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="Placeholder" type="LineEdit" parent="HBox"]
|
||||
margin_right = 1018.0
|
||||
margin_bottom = 24.0
|
||||
rect_min_size = Vector2( 0, 24 )
|
||||
size_flags_horizontal = 3
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
# Placeholders UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _placeholders_ui = $Scroll/Placeholders
|
||||
|
||||
const LocalizationTranslationsList = preload("res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersList.tscn")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_ui_placeholders()
|
||||
_add_ui_placeholders()
|
||||
_view_ui_placeholders()
|
||||
_update_ui_placeholders()
|
||||
|
||||
func _clear_ui_placeholders() -> void:
|
||||
var placeholders_ui = _placeholders_ui.get_children()
|
||||
for placeholder_ui in placeholders_ui:
|
||||
if placeholder_ui.has_method("get_locale"):
|
||||
var locale = placeholder_ui.get_locale()
|
||||
if _data.find_locale(locale) == null:
|
||||
placeholders_ui.erase(placeholder_ui)
|
||||
placeholder_ui.queue_free()
|
||||
|
||||
func _add_ui_placeholders() -> void:
|
||||
var locales = _data.locales()
|
||||
for locale in locales:
|
||||
if not _ui_placeholder_exists(locale):
|
||||
_add_ui_placeholder(locale)
|
||||
|
||||
func _ui_placeholder_exists(locale) -> bool:
|
||||
for placeholder_ui in _placeholders_ui.get_children():
|
||||
if placeholder_ui.has_method("get_locale"):
|
||||
if placeholder_ui.get_locale() == locale:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _add_ui_placeholder(locale: String) -> void:
|
||||
var ui_placeholder = LocalizationTranslationsList.instantiate()
|
||||
_placeholders_ui.add_child(ui_placeholder)
|
||||
ui_placeholder.set_data(locale, _data)
|
||||
|
||||
func _view_ui_placeholders() -> void:
|
||||
for placeholder_ui in _placeholders_ui.get_children():
|
||||
if placeholder_ui.has_method("get_locale"):
|
||||
var locale = placeholder_ui.get_locale()
|
||||
var serarator_ui = _separator_after_placeholder_ui(placeholder_ui)
|
||||
if _data.is_locale_visible(locale):
|
||||
placeholder_ui.show()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.show()
|
||||
else:
|
||||
placeholder_ui.hide()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.hide()
|
||||
|
||||
func _separator_after_placeholder_ui(placeholder_ui: Node) -> Node:
|
||||
var index = placeholder_ui.get_index()
|
||||
var count = _placeholders_ui.get_child_count()
|
||||
if index + 1 < count:
|
||||
return _placeholders_ui.get_child(index + 1)
|
||||
return null
|
||||
|
||||
func _update_ui_placeholders() -> void:
|
||||
for placeholder_ui in _placeholders_ui.get_children():
|
||||
if placeholder_ui.has_method("update_view"):
|
||||
placeholder_ui.update_view()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b50tncrjb6x5j
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholders.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationPlaceholders" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Placeholders" type="HBoxContainer" parent="Scroll"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# Placeholders view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
var _split_viewport_size = 0
|
||||
var _scroll_position = 0
|
||||
|
||||
@onready var _split_ui = $Split
|
||||
@onready var _keys_ui = $Split/Keys
|
||||
@onready var _placeholders_ui = $Split/Placeholders
|
||||
@onready var _placeholders_list_ui = $Split/Placeholders/Scroll/Placeholders
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_keys_ui.set_data(data)
|
||||
_placeholders_ui.set_data(data)
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _split_ui.is_connected("dragged", _on_split_dragged):
|
||||
assert(_split_ui.dragged.connect(_on_split_dragged) == OK)
|
||||
|
||||
func _process(delta):
|
||||
if _split_viewport_size != size.x:
|
||||
_split_viewport_size = size.x
|
||||
_init_split_offset()
|
||||
_update_scrolls()
|
||||
|
||||
func _init_split_offset() -> void:
|
||||
var offset = 350
|
||||
if _data:
|
||||
offset = _data.setting_placeholders_split_offset()
|
||||
_split_ui.set_split_offset(-size.x / 2 + offset)
|
||||
|
||||
func _on_split_dragged(offset: int) -> void:
|
||||
if _data != null:
|
||||
var value = -(-size.x / 2 - offset)
|
||||
_data.setting_placeholders_split_offset_put(value)
|
||||
|
||||
# Workaround for https://github.com/godotengine/godot/issues/22936
|
||||
func _update_scrolls() -> void:
|
||||
var sc = _new_scrolls_position()
|
||||
if _scroll_position != sc:
|
||||
_scroll_position = sc
|
||||
_keys_ui.set_v_scroll(_scroll_position)
|
||||
for child in _placeholders_list_ui.get_children():
|
||||
if child.has_method("set_v_scroll"):
|
||||
child.set_v_scroll(_scroll_position)
|
||||
|
||||
func _new_scrolls_position() -> int:
|
||||
if _keys_ui == null:
|
||||
return 0
|
||||
var v_1 = [_keys_ui.get_v_scroll()]
|
||||
var v_2 = []
|
||||
for child in _placeholders_list_ui.get_children():
|
||||
if child.has_method("get_v_scroll"):
|
||||
var v_child = child.get_v_scroll()
|
||||
if v_1[0] == v_child:
|
||||
v_1.append(v_child)
|
||||
else:
|
||||
v_2.append(v_child)
|
||||
if v_2.size() == 0:
|
||||
return v_1[0]
|
||||
if v_1.size() == 1:
|
||||
return v_1[0]
|
||||
return v_2[0]
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://diwy25h5ek0ur
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersEditorView.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersKeys.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholders.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="LocalizationPlaceholdersEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Split" type="HSplitContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
split_offset = -162
|
||||
|
||||
[node name="Keys" parent="Split" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 344.0
|
||||
margin_bottom = 600.0
|
||||
rect_clip_content = true
|
||||
|
||||
[node name="Placeholders" parent="Split" instance=ExtResource( 3 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 356.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Placeholders head UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _type: String
|
||||
var _data: LocalizationData
|
||||
|
||||
var _filter = ""
|
||||
|
||||
@onready var _title_ui = $TitleMargin/HBox/Title
|
||||
@onready var _filter_ui = $FilterMargin/HBox/Filter
|
||||
|
||||
func set_data(type: String, data: LocalizationData):
|
||||
_type = type
|
||||
_data = data
|
||||
_filter = _data.data_filter_placeholders_by_type(_type)
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _filter_ui.is_connected("text_changed", _filter_changed_action):
|
||||
assert(_filter_ui.text_changed.connect(_filter_changed_action) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_filter_ui.text = _filter
|
||||
|
||||
func _filter_changed_action(filter) -> void:
|
||||
_filter = filter
|
||||
_data.data_filter_placeholders_put(_type, _filter)
|
||||
|
||||
func set_title(text: String) -> void:
|
||||
_title_ui.text = text
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c7clt1325spkx
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersHead.gd" type="Script" id=1]
|
||||
|
||||
[node name="LocalizationHead" type="VBoxContainer"]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TitleMargin" type="MarginContainer" parent="."]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 26.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="TitleMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 26.0
|
||||
|
||||
[node name="Title" type="Label" parent="TitleMargin/HBox"]
|
||||
margin_top = 4.0
|
||||
margin_right = 338.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
||||
text = "KEYS"
|
||||
align = 1
|
||||
|
||||
[node name="FilterMargin" type="MarginContainer" parent="."]
|
||||
margin_top = 30.0
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="FilterMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="Filter" type="LineEdit" parent="FilterMargin/HBox"]
|
||||
margin_right = 338.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Filter"
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Translations key UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _del_ui = $HBoxContainer/Del as Button
|
||||
@onready var _key_ui = $HBoxContainer/Key as LineEdit
|
||||
|
||||
func _ready() -> void:
|
||||
_del_ui.connect("pressed", _on_del_pressed)
|
||||
|
||||
func _on_del_pressed() -> void:
|
||||
_data.del_placeholder(_key)
|
||||
|
||||
func key():
|
||||
return _key
|
||||
|
||||
func set_data(key, data: LocalizationData):
|
||||
_key = key
|
||||
_data = data
|
||||
_draw_view()
|
||||
|
||||
func _draw_view() -> void:
|
||||
_key_ui.text = _key
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d6vayujgyix1
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://c0m0p02wuleun"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersKey.gd" id="1"]
|
||||
[ext_resource type="Texture2D" uid="uid://caiapkr8oaqe6" path="res://addons/localization_editor/icons/Del.svg" id="2_gnca8"]
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 597.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Del" type="Button" parent="HBoxContainer"]
|
||||
offset_right = 28.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
icon = ExtResource( "2_gnca8" )
|
||||
|
||||
[node name="Key" type="LineEdit" parent="HBoxContainer"]
|
||||
offset_left = 32.0
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 597.0
|
||||
size_flags_horizontal = 3
|
||||
editable = false
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Placeholders keys UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _keys_ui = $VBox/Scroll/Keys
|
||||
|
||||
const LocalizationKey = preload("res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersKey.tscn")
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_head_ui.set_data("placeholderkeys", _data)
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_view()
|
||||
_draw_view()
|
||||
|
||||
func _clear_view() -> void:
|
||||
for key_ui in _keys_ui.get_children():
|
||||
_keys_ui.remove_child(key_ui)
|
||||
key_ui.queue_free()
|
||||
|
||||
func _draw_view() -> void:
|
||||
for key in _data.placeholders_filtered().keys():
|
||||
_draw_key(key)
|
||||
|
||||
func _draw_key(key) -> void:
|
||||
var key_ui = LocalizationKey.instantiate()
|
||||
_keys_ui.add_child(key_ui)
|
||||
key_ui.set_data(key, _data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dogexarhaq31l
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersKeys.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersHead.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="LocalizationPlaceholdersKeys" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource( 2 )]
|
||||
margin_right = 1024.0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
margin_top = 61.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Keys" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
margin_right = 1024.0
|
||||
size_flags_horizontal = 3
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
# Placeholders list UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
var _locale: String
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _separator_ui = $Separator
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _placeholders_ui = $VBox/Scroll/PlaceholdersList
|
||||
|
||||
const Locales = preload("res://addons/localization_editor/model/LocalizationLocalesList.gd")
|
||||
const LocalizationPlaceholder = preload("res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholder.tscn")
|
||||
|
||||
func set_data(locale: String, data: LocalizationData) -> void:
|
||||
_locale = locale
|
||||
_data = data
|
||||
_head_ui.set_data(_locale, _data)
|
||||
update_view()
|
||||
|
||||
func get_locale() -> String:
|
||||
return _locale
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
if _scroll_ui == null:
|
||||
return 0
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func update_view() -> void:
|
||||
if get_index() == 0:
|
||||
_separator_ui.hide()
|
||||
_head_ui.set_title(Locales.label_by_code(_locale))
|
||||
_add_placeholders()
|
||||
|
||||
func _add_placeholders() -> void:
|
||||
_clear_placeholders()
|
||||
var placeholders_filtered = _data.placeholders_filtered()
|
||||
for key in placeholders_filtered.keys():
|
||||
var placeholder = placeholders_filtered[key]
|
||||
if placeholder.has(_locale):
|
||||
_add_placeholder(key)
|
||||
|
||||
func _clear_placeholders() -> void:
|
||||
for placeholder_ui in _placeholders_ui.get_children():
|
||||
_placeholders_ui.remove_child(placeholder_ui)
|
||||
placeholder_ui.queue_free()
|
||||
|
||||
func _add_placeholder(key) -> void:
|
||||
var placeholder_ui = LocalizationPlaceholder.instantiate()
|
||||
_placeholders_ui.add_child(placeholder_ui)
|
||||
placeholder_ui.set_data(key, _locale, _data)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bwbmioxxhe7w1
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersHead.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/placeholders/LocalizationPlaceholdersList.gd" type="Script" id=2]
|
||||
|
||||
[node name="LocalizationPlaceholdersList" type="HBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( -585.391, 206.877 )
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Separator" type="VSeparator" parent="."]
|
||||
margin_right = 4.0
|
||||
margin_bottom = 600.0
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
margin_left = 8.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource( 1 )]
|
||||
margin_right = 1016.0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
margin_top = 61.0
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PlaceholdersList" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
margin_right = 1016.0
|
||||
margin_bottom = 539.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
# LocalizationEditor Pseudolocalization: MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://2lspoobji4u0
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bt0r11jd8rtq6"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/pseudolocalization/LocalizationPseudolocalizationEditorView.gd" id="1_lb46l"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3jy757hoeaso" path="res://addons/localization_editor/scenes/pseudolocalization/control/LocalizationPseudolocalizationControl.tscn" id="2_s2t82"]
|
||||
|
||||
[node name="PseudolocalizationEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1_lb46l" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="LocalizationPseudolocalizationControl" parent="." instance=ExtResource( "2_s2t82" )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 354.0
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
# LocalizationEditor PseudolocalizationControl: MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
const _pseudolocalization_control: String = "internationalization/pseudolocalization/use_pseudolocalization_control"
|
||||
|
||||
@onready var _pseudolocalization_ui: CheckBox = $HBox/Panel/PseudolocalizationControl
|
||||
|
||||
func _ready():
|
||||
if ProjectSettings.has_setting(_pseudolocalization_control):
|
||||
_pseudolocalization_ui.button_pressed = ProjectSettings.get_setting(_pseudolocalization_control)
|
||||
_pseudolocalization_ui.toggled.connect(_on_pseudolocalization_toggled)
|
||||
|
||||
func _on_pseudolocalization_toggled(button_pressed: bool) -> void:
|
||||
ProjectSettings.set_setting(_pseudolocalization_control, button_pressed)
|
||||
ProjectSettings.save()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://buetkc0boro05
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://b3jy757hoeaso"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/pseudolocalization/control/LocalizationPseudolocalizationControl.gd" id="1_an27a"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvfcmuubc6npi" path="res://addons/localization_editor/scenes/pseudolocalization/control/LocalizationPseudolocalizationUI.tscn" id="2_jxw8w"]
|
||||
|
||||
[node name="LocalizationPseudolocalizationControl" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( "1_an27a" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBox"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Use Pseudolocalization Control in UI"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBox"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="PseudolocalizationControl" type="CheckBox" parent="HBox/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
button_pressed = true
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="."]
|
||||
offset_top = 35.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 39.0
|
||||
|
||||
[node name="PseudolocalizationEditorView" parent="." instance=ExtResource( "2_jxw8w" )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_top = 43.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
# LocalizationEditor PseudolocalizationUI: MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
const _pseudolocalization: String = "internationalization/pseudolocalization/use_pseudolocalization"
|
||||
const _accents: String = "internationalization/pseudolocalization/replace_with_accents"
|
||||
const _double_vowels: String = "internationalization/pseudolocalization/double_vowels"
|
||||
const _fake_bidi: String = "internationalization/pseudolocalization/fake_bidi"
|
||||
const _override: String = "internationalization/pseudolocalization/override"
|
||||
const _expansion_ratio: String = "internationalization/pseudolocalization/expansion_ratio"
|
||||
const _prefix: String = "internationalization/pseudolocalization/prefix"
|
||||
const _suffix: String = "internationalization/pseudolocalization/suffix"
|
||||
const _skip_placeholders: String = "internationalization/pseudolocalization/skip_placeholders"
|
||||
|
||||
@onready var _pseudolocalization_ui: CheckBox = $HBoxPseudolocalization/Panel/Pseudolocalization
|
||||
@onready var _accents_ui: CheckBox = $HBoxAccents/Panel/Accents
|
||||
@onready var _double_vowels_ui: CheckBox = $HBoxDoubleVowels/Panel/DoubleVowels
|
||||
@onready var _fake_bidi_ui: CheckBox = $HBoxFakeBidi/Panel/FakeBidi
|
||||
@onready var _override_ui: CheckBox = $HBoxOverride/Panel/Override
|
||||
@onready var _expansion_ratio_ui: LineEdit = $HBoxExpansionRatio/ExpansionRatio
|
||||
@onready var _prefix_ui: LineEdit = $HBoxPrefix/ExpansionPrefix
|
||||
@onready var _suffix_ui: LineEdit = $HBoxSuffix/ExpansionSuffix
|
||||
@onready var _skip_placeholders_ui: CheckBox = $HBoxSkipPlaceholders/Panel/SkipPlaceholders
|
||||
|
||||
func _ready() -> void:
|
||||
_init_vars()
|
||||
_init_connections()
|
||||
|
||||
func _init_vars() -> void:
|
||||
_pseudolocalization_ui.button_pressed = TranslationServer.is_pseudolocalization_enabled()
|
||||
_accents_ui.button_pressed = ProjectSettings.get(_accents)
|
||||
_double_vowels_ui.button_pressed = ProjectSettings.get(_double_vowels)
|
||||
_fake_bidi_ui.button_pressed = ProjectSettings.get(_fake_bidi)
|
||||
_override_ui.button_pressed = ProjectSettings.get(_override)
|
||||
_expansion_ratio_ui.text = str(ProjectSettings.get(_expansion_ratio))
|
||||
_prefix_ui.text = ProjectSettings.get(_prefix)
|
||||
_suffix_ui.text = ProjectSettings.get(_suffix)
|
||||
_skip_placeholders_ui.button_pressed = ProjectSettings.get(_skip_placeholders)
|
||||
|
||||
func _init_connections() -> void:
|
||||
_pseudolocalization_ui.toggled.connect(_on_pseudolocalization_toggled)
|
||||
_accents_ui.toggled.connect(_on_accents_toggled)
|
||||
_double_vowels_ui.toggled.connect(_on_double_vowels_toggled)
|
||||
_fake_bidi_ui.toggled.connect(_on_fake_bidi_toggled)
|
||||
_override_ui.toggled.connect(_on_override_toggled)
|
||||
_expansion_ratio_ui.text_changed.connect(_on_expansion_ratio_text_changed)
|
||||
_prefix_ui.text_changed.connect(_on_prefix_text_changed)
|
||||
_suffix_ui.text_changed.connect(_on_suffix_text_changed)
|
||||
_skip_placeholders_ui.toggled.connect(_on_skip_placeholders_toggled)
|
||||
|
||||
func _on_pseudolocalization_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_pseudolocalization, button_pressed)
|
||||
TranslationServer.set_pseudolocalization_enabled(button_pressed)
|
||||
|
||||
func _on_accents_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_accents, button_pressed)
|
||||
|
||||
func _on_double_vowels_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_double_vowels, button_pressed)
|
||||
|
||||
func _on_fake_bidi_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_fake_bidi, button_pressed)
|
||||
|
||||
func _on_override_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_override, button_pressed)
|
||||
|
||||
func _on_expansion_ratio_text_changed() -> void:
|
||||
float()
|
||||
var ratio = (_expansion_ratio_ui.text).to_float()
|
||||
if ratio > 1:
|
||||
ratio = 1
|
||||
_expansion_ratio_ui.text = str(ratio)
|
||||
if ratio < 0:
|
||||
ratio = 0
|
||||
_expansion_ratio_ui.text = str(ratio)
|
||||
_change_project_setting(_expansion_ratio, ratio)
|
||||
|
||||
func _on_prefix_text_changed() -> void:
|
||||
_change_project_setting(_prefix, _prefix_ui.text)
|
||||
|
||||
func _on_suffix_text_changed() -> void:
|
||||
_change_project_setting(_suffix, _suffix_ui.text)
|
||||
|
||||
func _on_skip_placeholders_toggled(button_pressed: bool) -> void:
|
||||
_change_project_setting(_skip_placeholders, button_pressed)
|
||||
|
||||
func _change_project_setting(property: String, value: Variant, reload: bool = true, save: bool = true) -> void:
|
||||
ProjectSettings.set(property, value)
|
||||
if reload:
|
||||
TranslationServer.reload_pseudolocalization()
|
||||
if save and Engine.is_editor_hint():
|
||||
ProjectSettings.save()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cn1qqdf7vel45
|
||||
|
|
@ -0,0 +1,259 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dvfcmuubc6npi"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/pseudolocalization/control/LocalizationPseudolocalizationUI.gd" id="1_uf0s3"]
|
||||
|
||||
[node name="PseudolocalizationEditorView" type="VBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1_uf0s3" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxPseudolocalization" type="HBoxContainer" parent="."]
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxPseudolocalization"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Use Pseudolocalization"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxPseudolocalization"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Pseudolocalization" type="CheckBox" parent="HBoxPseudolocalization/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
text = "On"
|
||||
|
||||
[node name="HBoxAccents" type="HBoxContainer" parent="."]
|
||||
offset_top = 35.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 66.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxAccents"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Replace With Accents
|
||||
"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxAccents"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Accents" type="CheckBox" parent="HBoxAccents/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
button_pressed = true
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxDoubleVowels" type="HBoxContainer" parent="."]
|
||||
offset_top = 70.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 101.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxDoubleVowels"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Double Vowels"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxDoubleVowels"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="DoubleVowels" type="CheckBox" parent="HBoxDoubleVowels/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxFakeBidi" type="HBoxContainer" parent="."]
|
||||
offset_top = 105.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 136.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxFakeBidi"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Fake Bidi"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxFakeBidi"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="FakeBidi" type="CheckBox" parent="HBoxFakeBidi/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxOverride" type="HBoxContainer" parent="."]
|
||||
offset_top = 140.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 171.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxOverride"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Override"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxOverride"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Override" type="CheckBox" parent="HBoxOverride/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxExpansionRatio" type="HBoxContainer" parent="."]
|
||||
offset_top = 175.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 206.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxExpansionRatio"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Expansion Ratio"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ExpansionRatio" type="LineEdit" parent="HBoxExpansionRatio"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
text = "0"
|
||||
|
||||
[node name="HBoxPrefix" type="HBoxContainer" parent="."]
|
||||
offset_top = 210.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 241.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxPrefix"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Prefix"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ExpansionPrefix" type="LineEdit" parent="HBoxPrefix"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
text = "["
|
||||
|
||||
[node name="HBoxSuffix" type="HBoxContainer" parent="."]
|
||||
offset_top = 245.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 276.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxSuffix"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Suffix"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="ExpansionSuffix" type="LineEdit" parent="HBoxSuffix"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
text = "]"
|
||||
|
||||
[node name="HBoxSkipPlaceholders" type="HBoxContainer" parent="."]
|
||||
offset_top = 280.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 311.0
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxSkipPlaceholders"]
|
||||
offset_right = 510.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Skip Placeholders"
|
||||
vertical_alignment = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="HBoxSkipPlaceholders"]
|
||||
offset_left = 514.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 31.0
|
||||
rect_min_size = Vector2(0, 31)
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="SkipPlaceholders" type="CheckBox" parent="HBoxSkipPlaceholders/Panel"]
|
||||
offset_right = 44.0
|
||||
offset_bottom = 31.0
|
||||
auto_translate = false
|
||||
text = "On"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
extends CanvasLayer
|
||||
|
||||
const LocalizationPseudolocalizationWindow = preload("res://addons/localization_editor/scenes/pseudolocalization/ui/LocalizationPseudolocalizationWindow.tscn")
|
||||
|
||||
@onready var _view_ui: Button = $VBox/HBox/View
|
||||
|
||||
var _root
|
||||
var _window = null
|
||||
|
||||
func _ready():
|
||||
_root = get_tree().get_root()
|
||||
_view_ui.pressed.connect(_on_view_ui_pressed)
|
||||
|
||||
func _on_view_ui_pressed() -> void:
|
||||
if _window == null:
|
||||
_create_dialogue()
|
||||
else:
|
||||
_window.move_to_foreground()
|
||||
|
||||
func _create_dialogue() -> void:
|
||||
var pseudolocalization_window: Window = LocalizationPseudolocalizationWindow.instantiate()
|
||||
_root.add_child(pseudolocalization_window)
|
||||
_window = pseudolocalization_window
|
||||
pseudolocalization_window.title = "Pseudolocalization"
|
||||
pseudolocalization_window.connect("close_requested", _on_window_hide)
|
||||
pseudolocalization_window.popup_centered(Vector2i(500, 315))
|
||||
|
||||
func _on_window_hide() -> void:
|
||||
_root.remove_child(_window)
|
||||
_window.queue_free()
|
||||
_window = null
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bpk6015voisn6
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bikihsdqsi1sm"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/pseudolocalization/ui/LocalizationPseudolocalizationForUI.gd" id="1_knfsp"]
|
||||
|
||||
[node name="Control" type="CanvasLayer"]
|
||||
script = ExtResource( "1_knfsp" )
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_left = 1.0
|
||||
anchor_right = 1.0
|
||||
offset_left = -212.0
|
||||
offset_bottom = 31.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="VBox"]
|
||||
offset_right = 212.0
|
||||
offset_bottom = 31.0
|
||||
alignment = 2
|
||||
|
||||
[node name="View" type="Button" parent="VBox/HBox"]
|
||||
offset_right = 212.0
|
||||
offset_bottom = 31.0
|
||||
text = "Pseudolocalization Control"
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://sl1jt1bmc4aj"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://dvfcmuubc6npi" path="res://addons/localization_editor/scenes/pseudolocalization/control/LocalizationPseudolocalizationUI.tscn" id="1_0aul8"]
|
||||
|
||||
[node name="Window" type="Window"]
|
||||
disable_3d = true
|
||||
title = "Pseudolocalization"
|
||||
size = Vector2i(500, 850)
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="PseudolocalizationEditorView" parent="ScrollContainer" instance=ExtResource( "1_0aul8" )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
|
|
@ -0,0 +1,95 @@
|
|||
# Remap UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _remap
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _remap_ui = $HBox/Remap
|
||||
@onready var _audio_ui = $HBox/Audio
|
||||
@onready var _video_ui = $HBox/Video
|
||||
@onready var _image_ui = $HBox/Image
|
||||
|
||||
const LocalizationRemapDialogVideo = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemapDialogVideo.tscn")
|
||||
const LocalizationRemapDialogImage = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemapDialogImage.tscn")
|
||||
|
||||
func set_data(key, remap, data: LocalizationData) -> void:
|
||||
_key = key
|
||||
_remap = remap
|
||||
_data = data
|
||||
_remap_ui.set_data(key, remap, data)
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_remapkey_value_changed", _draw_view):
|
||||
assert(_data.data_remapkey_value_changed.connect(_draw_view) == OK)
|
||||
if not _audio_ui.is_connected("pressed", _on_audio_pressed):
|
||||
assert(_audio_ui.connect("pressed", _on_audio_pressed) == OK)
|
||||
if not _video_ui.is_connected("pressed", _on_video_pressed):
|
||||
assert(_video_ui.connect("pressed", _on_video_pressed) == OK)
|
||||
if not _image_ui.is_connected("pressed", _on_image_pressed):
|
||||
assert(_image_ui.connect("pressed", _on_image_pressed) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_check_buttons()
|
||||
|
||||
func _check_buttons() -> void:
|
||||
_hide_buttons()
|
||||
var type = _data.remap_type(_remap)
|
||||
match type:
|
||||
"audio":
|
||||
_audio_ui.show()
|
||||
"image":
|
||||
_image_ui.show()
|
||||
"video":
|
||||
_video_ui.show()
|
||||
|
||||
func _hide_buttons() -> void:
|
||||
_audio_ui.hide()
|
||||
_video_ui.hide()
|
||||
_image_ui.hide()
|
||||
|
||||
func _on_audio_pressed() -> void:
|
||||
var audio_player
|
||||
if get_tree().get_root().has_node("AudioPlayer"):
|
||||
audio_player = get_tree().get_root().get_node("AudioPlayer") as AudioStreamPlayer
|
||||
else:
|
||||
audio_player = AudioStreamPlayer.new()
|
||||
get_tree().get_root().add_child(audio_player)
|
||||
var audio = load(_remap.value)
|
||||
audio.set_loop(false)
|
||||
audio_player.stream = audio
|
||||
audio_player.play()
|
||||
|
||||
func _on_video_pressed() -> void:
|
||||
var video_dialog: Window = LocalizationRemapDialogVideo.instantiate()
|
||||
var root = get_tree().get_root()
|
||||
root.add_child(video_dialog)
|
||||
video_dialog.title = _data.filename(_remap.value)
|
||||
var video_player = video_dialog.get_node("VideoPlayer") as VideoStreamPlayer
|
||||
video_player.expand = true
|
||||
var video: VideoStream = load(_remap.value)
|
||||
video_player.stream = video
|
||||
video_dialog.close_requested.connect(_video_dialog_close.bind(video_dialog))
|
||||
video_dialog.popup_centered(Vector2i(500, 300))
|
||||
video_player.play()
|
||||
|
||||
func _video_dialog_close(video_dialog: Window) -> void:
|
||||
video_dialog.hide()
|
||||
|
||||
func _on_image_pressed() -> void:
|
||||
var image_dialog: Window = LocalizationRemapDialogImage.instantiate()
|
||||
var root = get_tree().get_root()
|
||||
root.add_child(image_dialog)
|
||||
image_dialog.title = _data.filename(_remap.value)
|
||||
var texture = image_dialog.get_node("Texture") as TextureRect
|
||||
var image = load(_remap.value)
|
||||
texture.texture = image
|
||||
image_dialog.close_requested.connect(_image_dialog_close.bind(image_dialog))
|
||||
image_dialog.popup_centered(Vector2i(500, 300))
|
||||
|
||||
func _image_dialog_close(image_dialog: Window) -> void:
|
||||
image_dialog.hide()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cpx7wk0diu1h3
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://dqtiybaaxohvp"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/remaps/LocalizationRemap.gd" id="4"]
|
||||
[ext_resource type="PackedScene" uid="uid://cconuf5kyyt8x" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapPath.tscn" id="5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bkeugb6vucegl" path="res://addons/localization_editor/icons/Audio.svg" id="5_84ecs"]
|
||||
[ext_resource type="Texture2D" uid="uid://oxmydroedm6f" path="res://addons/localization_editor/icons/Video.svg" id="6_uxbjg"]
|
||||
[ext_resource type="Texture2D" uid="uid://dl6cg75c815d8" path="res://addons/localization_editor/icons/Image.svg" id="7_is72i"]
|
||||
|
||||
[node name="Remap" type="MarginContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
size_flags_horizontal = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource("4")
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="Remap" parent="HBox" instance=ExtResource("5")]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Audio" type="Button" parent="HBox"]
|
||||
layout_mode = 2
|
||||
icon = ExtResource("5_84ecs")
|
||||
|
||||
[node name="Video" type="Button" parent="HBox"]
|
||||
layout_mode = 2
|
||||
icon = ExtResource("6_uxbjg")
|
||||
|
||||
[node name="Image" type="Button" parent="HBox"]
|
||||
layout_mode = 2
|
||||
icon = ExtResource("7_is72i")
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[gd_scene format=3 uid="uid://bh0d4n3rlnltu"]
|
||||
|
||||
[node name="LocalizationRemapDialogFile" type="FileDialog"]
|
||||
size = Vector2i(800, 600)
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
[gd_scene format=3 uid="uid://cig7xmo5hp6hv"]
|
||||
|
||||
[node name="LocalizationRemapVideoDialog" type="Window"]
|
||||
visible = false
|
||||
|
||||
[node name="Texture" type="TextureRect" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
stretch_mode = 6
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
[gd_scene format=3 uid="uid://b3vp2dngpmd0f"]
|
||||
|
||||
[node name="LocalizationRemapVideoDialog" type="Window"]
|
||||
|
||||
[node name="VideoPlayer" type="VideoStreamPlayer" parent="."]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
|
|
@ -0,0 +1,136 @@
|
|||
# Remap UI LineEdit for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
# Drag and drop not work just now, see Workaround -> LocalizationRemapPut
|
||||
# https://github.com/godotengine/godot/issues/30480
|
||||
@tool
|
||||
extends LineEdit
|
||||
|
||||
var _key
|
||||
var _remap
|
||||
var _data: LocalizationData
|
||||
|
||||
var _remap_ui_style_empty: StyleBoxFlat
|
||||
var _remap_ui_style_resource: StyleBoxFlat
|
||||
var _remap_ui_style_resource_diff: StyleBoxFlat
|
||||
var _remap_ui_style_resource_double: StyleBoxFlat
|
||||
|
||||
const LocalizationRemapDialogFile = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemapDialogFile.tscn")
|
||||
|
||||
func set_data(key, remap, data: LocalizationData) -> void:
|
||||
_key = key
|
||||
_remap = remap
|
||||
_data = data
|
||||
_init_styles()
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_styles() -> void:
|
||||
var style_box = get_theme_stylebox("normal", "LineEdit")
|
||||
_remap_ui_style_empty = style_box.duplicate()
|
||||
_remap_ui_style_empty.set_bg_color(Color("#661c1c"))
|
||||
_remap_ui_style_resource = style_box.duplicate()
|
||||
_remap_ui_style_resource.set_bg_color(Color("#192e59"))
|
||||
_remap_ui_style_resource_diff = style_box.duplicate()
|
||||
_remap_ui_style_resource_diff.set_bg_color(Color("#514200"))
|
||||
_remap_ui_style_resource_double = style_box.duplicate()
|
||||
_remap_ui_style_resource_double.set_bg_color(Color("#174044"))
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_remapkey_value_changed", _draw_view):
|
||||
assert(_data.data_remapkey_value_changed.connect(_draw_view) == OK)
|
||||
if not is_connected("focus_entered", _on_focus_entered):
|
||||
assert(focus_entered.connect(_on_focus_entered) == OK)
|
||||
if not is_connected("focus_exited", _on_focus_exited):
|
||||
assert(focus_exited.connect(_on_focus_exited) == OK)
|
||||
if not is_connected("text_changed", _remap_value_changed):
|
||||
assert(text_changed.connect(_remap_value_changed) == OK)
|
||||
if not is_connected("gui_input", _on_gui_input):
|
||||
assert(gui_input.connect(_on_gui_input) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
if has_focus():
|
||||
text = _remap.value
|
||||
else:
|
||||
text = _data.filename(_remap.value)
|
||||
_check_remap_ui()
|
||||
|
||||
func _input(event) -> void:
|
||||
if (event is InputEventMouseButton) and event.pressed:
|
||||
if not get_global_rect().has_point(event.position):
|
||||
release_focus()
|
||||
|
||||
func _on_focus_entered() -> void:
|
||||
text = _remap.value
|
||||
|
||||
func _on_focus_exited() -> void:
|
||||
text = _data.filename(_remap.value)
|
||||
|
||||
func _remap_value_changed(remap_value) -> void:
|
||||
_data.remapkey_value_change(_remap, remap_value)
|
||||
|
||||
func _on_gui_input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if event.button_index == MOUSE_BUTTON_MIDDLE:
|
||||
if event.pressed:
|
||||
grab_focus()
|
||||
var file_dialog = LocalizationRemapDialogFile.instantiate()
|
||||
if _resource_exists():
|
||||
file_dialog.current_dir = _data.file_path(_remap.value)
|
||||
file_dialog.current_file = _data.filename(_remap.value)
|
||||
for extension in _data.supported_file_extensions():
|
||||
file_dialog.add_filter("*." + extension)
|
||||
var root = get_tree().get_root()
|
||||
root.add_child(file_dialog)
|
||||
file_dialog.connect("file_selected", _remap_value_changed)
|
||||
file_dialog.popup_centered()
|
||||
|
||||
func _can_drop_data(position, data) -> bool:
|
||||
var remap_value = data["files"][0]
|
||||
var remap_extension = _data.file_extension(remap_value)
|
||||
for extension in _data.supported_file_extensions():
|
||||
if remap_extension == extension:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _drop_data(position, data) -> void:
|
||||
var remap_value = data["files"][0]
|
||||
_remap_value_changed(remap_value)
|
||||
|
||||
func _check_remap_ui() -> void:
|
||||
if text.length() <= 0:
|
||||
set("custom_styles/normal", _remap_ui_style_empty)
|
||||
tooltip_text = "Please set remap resource"
|
||||
elif not _resource_exists():
|
||||
set("custom_styles/normal", _remap_ui_style_resource)
|
||||
tooltip_text = "Your resource path: \"" + _remap.value + "\" does not exists"
|
||||
elif _resource_different_type():
|
||||
set("custom_styles/normal", _remap_ui_style_resource_diff)
|
||||
tooltip_text = "Your remaps have different types"
|
||||
elif _resource_double():
|
||||
set("custom_styles/normal", _remap_ui_style_resource_double)
|
||||
tooltip_text = "Your have double resources in your remaps"
|
||||
else:
|
||||
set("custom_styles/normal", null)
|
||||
tooltip_text = ""
|
||||
|
||||
func _resource_exists() -> bool:
|
||||
if _data.remap_type(_remap) == "undefined":
|
||||
return false
|
||||
return FileAccess.file_exists(_remap.value)
|
||||
|
||||
func _resource_different_type() -> bool:
|
||||
var type = _data.remap_type(_remap)
|
||||
for remap in _key.remaps:
|
||||
if remap.value.length() > 0 and type != _data.remap_type(remap):
|
||||
return true
|
||||
return false
|
||||
|
||||
func _resource_double() -> bool:
|
||||
var first
|
||||
for remap in _key.remaps:
|
||||
if first == null:
|
||||
first = remap
|
||||
continue
|
||||
if remap.value.length() > 0 and first.value == remap.value:
|
||||
return true
|
||||
return false
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://caetu5nx0gjo4
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cconuf5kyyt8x"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapPath.gd" id="1"]
|
||||
|
||||
[node name="LocalizationRemapPath" type="LineEdit"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource("1")
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
# Remaps UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _remaps_ui = $Scroll/Remaps
|
||||
|
||||
const LocalizationRemapsList = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemapsList.tscn")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_ui_remaps()
|
||||
_add_ui_remaps()
|
||||
_view_ui_remaps()
|
||||
_update_ui_remaps()
|
||||
|
||||
func _clear_ui_remaps() -> void:
|
||||
var remaps_ui = _remaps_ui.get_children()
|
||||
for remap_ui in remaps_ui:
|
||||
if remap_ui.has_method("get_locale"):
|
||||
var locale = remap_ui.get_locale()
|
||||
if _data.find_locale(locale) == null:
|
||||
remaps_ui.erase(remap_ui)
|
||||
remap_ui.queue_free()
|
||||
|
||||
func _add_ui_remaps() -> void:
|
||||
var locales = _data.locales()
|
||||
for locale in locales:
|
||||
if not _ui_remap_exists(locale):
|
||||
_add_ui_remap(locale)
|
||||
|
||||
func _ui_remap_exists(locale) -> bool:
|
||||
for remap_ui in _remaps_ui.get_children():
|
||||
if remap_ui.has_method("get_locale"):
|
||||
if remap_ui.get_locale() == locale:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _add_ui_remap(locale: String) -> void:
|
||||
var ui_remap = LocalizationRemapsList.instantiate()
|
||||
_remaps_ui.add_child(ui_remap)
|
||||
ui_remap.set_data(locale, _data)
|
||||
|
||||
func _view_ui_remaps() -> void:
|
||||
for remap_ui in _remaps_ui.get_children():
|
||||
if remap_ui.has_method("get_locale"):
|
||||
var locale = remap_ui.get_locale()
|
||||
var serarator_ui = _separator_after_remap_ui(remap_ui)
|
||||
if _data.is_locale_visible(locale):
|
||||
remap_ui.show()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.show()
|
||||
else:
|
||||
remap_ui.hide()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.hide()
|
||||
|
||||
func _separator_after_remap_ui(remap_ui: Node) -> Node:
|
||||
var index = remap_ui.get_index()
|
||||
var count = _remaps_ui.get_child_count()
|
||||
if index + 1 < count:
|
||||
return _remaps_ui.get_child(index + 1)
|
||||
return null
|
||||
|
||||
func _update_ui_remaps() -> void:
|
||||
for remap_ui in _remaps_ui.get_children():
|
||||
if remap_ui.has_method("update_view"):
|
||||
remap_ui.update_view()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bygtup048vkg4
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemaps.gd" type="Script" id=2]
|
||||
|
||||
[node name="LocalizationRemaps" type="Panel"]
|
||||
margin_left = 518.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Remaps" type="HBoxContainer" parent="Scroll"]
|
||||
margin_right = 506.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
# Remaps view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
var _split_viewport_size = 0
|
||||
|
||||
@onready var _split_ui = $Split
|
||||
@onready var _keys_ui = $Split/Keys
|
||||
@onready var _remaps_ui = $Split/Remaps
|
||||
|
||||
const LocalizationRemaps = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemaps.tscn")
|
||||
|
||||
func set_data(data: LocalizationData):
|
||||
_data = data
|
||||
_keys_ui.set_data(data)
|
||||
_remaps_ui.set_data(data)
|
||||
|
||||
func _process(delta):
|
||||
if _split_viewport_size != size.x:
|
||||
_split_viewport_size = size.x
|
||||
_init_split_offset()
|
||||
|
||||
func _init_split_offset() -> void:
|
||||
var offset = 70
|
||||
_split_ui.set_split_offset(-size.x / 2 + offset)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bn300pfj06p2u
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsEditorView.gd" type="Script" id=1]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsKeys.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemaps.tscn" type="PackedScene" id=3]
|
||||
|
||||
[node name="Remaps" type="HBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Split" type="HSplitContainer" parent="."]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
split_offset = -442
|
||||
dragger_visibility = 1
|
||||
|
||||
[node name="Keys" parent="Split" instance=ExtResource( 2 )]
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 600.0
|
||||
|
||||
[node name="Remaps" parent="Split" instance=ExtResource( 3 )]
|
||||
margin_left = 76.0
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
# Head UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _type: String
|
||||
var _filter: String = ""
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _title_ui = $TitleMargin/HBox/Title
|
||||
@onready var _filter_ui = $FilterMargin/HBox/Filter
|
||||
|
||||
func set_data(type: String, data: LocalizationData):
|
||||
_type = type
|
||||
_data = data
|
||||
_filter = _data.data_filter_remaps_by_type(_type)
|
||||
_init_connections()
|
||||
_draw_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _filter_ui.is_connected("text_changed", _filter_changed_action):
|
||||
assert(_filter_ui.text_changed.connect(_filter_changed_action) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_filter_ui.text = _filter
|
||||
|
||||
func _filter_changed_action(filter) -> void:
|
||||
_filter = filter
|
||||
_data.data_filter_remaps_put(_type, _filter)
|
||||
|
||||
func set_title(text: String) -> void:
|
||||
_title_ui.text = text
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://djked7geg1wks
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsHead.gd" type="Script" id=1]
|
||||
|
||||
[node name="RemapsHead" type="VBoxContainer"]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
size_flags_horizontal = 3
|
||||
script = ExtResource( 1 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="TitleMargin" type="MarginContainer" parent="."]
|
||||
margin_right = 344.0
|
||||
margin_bottom = 26.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="TitleMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 26.0
|
||||
|
||||
[node name="Title" type="Label" parent="TitleMargin/HBox"]
|
||||
margin_top = 4.0
|
||||
margin_right = 338.0
|
||||
margin_bottom = 18.0
|
||||
size_flags_horizontal = 3
|
||||
text = "REMAP"
|
||||
align = 1
|
||||
|
||||
[node name="FilterMargin" type="MarginContainer" parent="."]
|
||||
margin_top = 30.0
|
||||
margin_right = 344.0
|
||||
margin_bottom = 57.0
|
||||
rect_min_size = Vector2( 0, 26 )
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
custom_constants/margin_right = 3
|
||||
custom_constants/margin_top = 3
|
||||
custom_constants/margin_left = 3
|
||||
custom_constants/margin_bottom = 0
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="FilterMargin"]
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = 341.0
|
||||
margin_bottom = 27.0
|
||||
|
||||
[node name="Filter" type="LineEdit" parent="FilterMargin/HBox"]
|
||||
margin_right = 338.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
placeholder_text = "Filter"
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
# Remaps key UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _add_ui = $HBoxContainer/Add
|
||||
@onready var _del_ui = $HBoxContainer/Del
|
||||
|
||||
func set_data(key, data: LocalizationData):
|
||||
_key = key
|
||||
_data = data
|
||||
_draw_view()
|
||||
|
||||
func _ready() -> void:
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _add_ui.is_connected("pressed", _on_add_pressed):
|
||||
assert(_add_ui.connect("pressed", _on_add_pressed) == OK)
|
||||
if not _del_ui.is_connected("pressed", _on_del_pressed):
|
||||
assert(_del_ui.connect("pressed", _on_del_pressed) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_del_ui.disabled = _data.remaps().size() == 1
|
||||
|
||||
func _on_add_pressed() -> void:
|
||||
_data._add_remapkey_new_after_uuid_remap(_key.uuid)
|
||||
|
||||
func _on_del_pressed() -> void:
|
||||
_data.del_remapkey(_key.uuid)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://b5te2xo0ppciy
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://1qs1y7jo8jb5"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cbf54t7aak7dy" path="res://addons/localization_editor/icons/Add.svg" id="2_kn4tc"]
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsKey.gd" id="3"]
|
||||
[ext_resource type="Texture2D" uid="uid://caiapkr8oaqe6" path="res://addons/localization_editor/icons/Del.svg" id="3_rqcqd"]
|
||||
|
||||
[node name="MarginContainer" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource( "3" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 29.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 0
|
||||
|
||||
[node name="Add" type="Button" parent="HBoxContainer"]
|
||||
offset_right = 28.0
|
||||
offset_bottom = 29.0
|
||||
hint_tooltip = "Add remap"
|
||||
icon = ExtResource( "2_kn4tc" )
|
||||
|
||||
[node name="Del" type="Button" parent="HBoxContainer"]
|
||||
offset_left = 32.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 29.0
|
||||
hint_tooltip = "Del remap"
|
||||
icon = ExtResource( "3_rqcqd" )
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Remaps keys UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _keys_ui = $VBox/Scroll/Keys
|
||||
|
||||
const LocalizationRemapsKey = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemapsKey.tscn")
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_head_ui.set_data(_data)
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_view()
|
||||
_draw_view()
|
||||
|
||||
func _clear_view() -> void:
|
||||
for key_ui in _keys_ui.get_children():
|
||||
_keys_ui.remove_child(key_ui)
|
||||
key_ui.queue_free()
|
||||
|
||||
func _draw_view() -> void:
|
||||
for key in _data.remapkeys_filtered():
|
||||
_draw_key(key)
|
||||
|
||||
func _draw_key(key) -> void:
|
||||
var key_ui = LocalizationRemapsKey.instantiate()
|
||||
_keys_ui.add_child(key_ui)
|
||||
key_ui.set_data(key, _data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://dgcbl3ua7u5sp
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsKeysHead.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsKeys.gd" type="Script" id=3]
|
||||
|
||||
[node name="LocalizationRemapsKeys" type="Panel"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( 3 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource( 2 )]
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
margin_top = 61.0
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Keys" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
margin_right = 1024.0
|
||||
margin_bottom = 539.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
# Remaps head keys UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _type: String = "remapkeys"
|
||||
var _filter: String = ""
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _music_ui = $VBox/HBoxTop/Music
|
||||
@onready var _image_ui = $VBox/HBoxTop/Image
|
||||
@onready var _video_ui = $VBox/HBoxBottom/Video
|
||||
@onready var _reset_ui = $VBox/HBoxBottom/Reset
|
||||
|
||||
func set_data(data: LocalizationData):
|
||||
_data = data
|
||||
_filter = _data.data_filter_remaps_by_type(_type)
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _music_ui.is_connected("button_up", _filter_changed_action):
|
||||
assert(_music_ui.button_up.connect(_filter_changed_action) == OK)
|
||||
if not _image_ui.is_connected("button_up", _filter_changed_action):
|
||||
assert(_image_ui.button_up.connect(_filter_changed_action) == OK)
|
||||
if not _video_ui.is_connected("button_up", _filter_changed_action):
|
||||
assert(_video_ui.button_up.connect(_filter_changed_action) == OK)
|
||||
if not _reset_ui.is_connected("button_up", _filter_reset_action):
|
||||
assert(_reset_ui.button_up.connect(_filter_reset_action) == OK)
|
||||
|
||||
func _filter_changed_action() -> void:
|
||||
var new_filter = ""
|
||||
if _music_ui.is_pressed():
|
||||
new_filter = new_filter + "audio"
|
||||
if _image_ui.is_pressed():
|
||||
new_filter = new_filter + ",image"
|
||||
if _video_ui.is_pressed():
|
||||
new_filter = new_filter + ",video"
|
||||
_filter = new_filter
|
||||
_data.data_filter_remaps_put(_type, _filter)
|
||||
|
||||
func _filter_reset_action() -> void:
|
||||
_music_ui.set_pressed(false)
|
||||
_image_ui.set_pressed(false)
|
||||
_video_ui.set_pressed(false)
|
||||
_filter = ""
|
||||
_data.data_filter_remaps_put(_type, _filter)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cxu4x8lxt0nvs
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://b7dpjrokji2pg"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://dgp35gsev3h0u" path="res://addons/localization_editor/icons/Audio.svg" id="2_6uq4h"]
|
||||
[ext_resource type="Texture2D" uid="uid://0737j0gpu23r" path="res://addons/localization_editor/icons/Image.svg" id="3_aivuy"]
|
||||
[ext_resource type="Texture2D" uid="uid://djtpd7stomej7" path="res://addons/localization_editor/icons/Video.svg" id="4_mrycj"]
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsKeysHead.gd" id="5"]
|
||||
[ext_resource type="Texture2D" uid="uid://dyxcie626p7lk" path="res://addons/localization_editor/icons/Cancel.svg" id="5_ydycg"]
|
||||
|
||||
[node name="Head" type="MarginContainer"]
|
||||
rect_min_size = Vector2(0, 57)
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_top = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 0
|
||||
script = ExtResource( "5" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_top = 3.0
|
||||
offset_right = 63.0
|
||||
offset_bottom = 65.0
|
||||
|
||||
[node name="HBoxTop" type="HBoxContainer" parent="VBox"]
|
||||
offset_right = 60.0
|
||||
offset_bottom = 29.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
|
||||
[node name="Music" type="Button" parent="VBox/HBoxTop"]
|
||||
offset_right = 28.0
|
||||
offset_bottom = 29.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Audio filter"
|
||||
toggle_mode = true
|
||||
icon = ExtResource( "2_6uq4h" )
|
||||
|
||||
[node name="Image" type="Button" parent="VBox/HBoxTop"]
|
||||
offset_left = 32.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 29.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Texture filter"
|
||||
toggle_mode = true
|
||||
icon = ExtResource( "3_aivuy" )
|
||||
|
||||
[node name="HBoxBottom" type="HBoxContainer" parent="VBox"]
|
||||
offset_top = 33.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 62.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
|
||||
[node name="Video" type="Button" parent="VBox/HBoxBottom"]
|
||||
offset_right = 28.0
|
||||
offset_bottom = 29.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Video filter"
|
||||
toggle_mode = true
|
||||
icon = ExtResource( "4_mrycj" )
|
||||
|
||||
[node name="Reset" type="Button" parent="VBox/HBoxBottom"]
|
||||
offset_left = 32.0
|
||||
offset_right = 60.0
|
||||
offset_bottom = 29.0
|
||||
rect_min_size = Vector2(20, 20)
|
||||
hint_tooltip = "Reset filters"
|
||||
icon = ExtResource( "5_ydycg" )
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
# RemapsList UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends HBoxContainer
|
||||
|
||||
var _locale: String
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _separator_ui = $Separator
|
||||
@onready var _head_ui = $VBox/Head
|
||||
@onready var _scroll_ui = $VBox/Scroll
|
||||
@onready var _remaps_ui = $VBox/Scroll/RemapsList
|
||||
|
||||
const LocalizationRemap = preload("res://addons/localization_editor/scenes/remaps/LocalizationRemap.tscn")
|
||||
|
||||
func set_data(locale: String, data: LocalizationData) -> void:
|
||||
_locale = locale
|
||||
_data = data
|
||||
_head_ui.set_data(_locale, _data)
|
||||
update_view()
|
||||
|
||||
func get_locale() -> String:
|
||||
return _locale
|
||||
|
||||
func get_v_scroll() -> int:
|
||||
if _scroll_ui == null:
|
||||
return 0
|
||||
return _scroll_ui.get_v_scroll()
|
||||
|
||||
func set_v_scroll(value: int) -> void:
|
||||
_scroll_ui.set_v_scroll(value)
|
||||
|
||||
func update_view() -> void:
|
||||
if get_index() == 0:
|
||||
_separator_ui.hide()
|
||||
_head_ui.set_title(LocalizationLocalesList.label_by_code(_locale))
|
||||
_add_remaps()
|
||||
|
||||
func _add_remaps() -> void:
|
||||
_clear_remaps()
|
||||
for key in _data.remapkeys_filtered():
|
||||
for remap in key.remaps:
|
||||
if remap.locale == _locale:
|
||||
_add_remap(key, remap)
|
||||
|
||||
func _clear_remaps() -> void:
|
||||
for remap_ui in _remaps_ui.get_children():
|
||||
_remaps_ui.remove_child(remap_ui)
|
||||
remap_ui.queue_free()
|
||||
|
||||
func _add_remap(key, remap) -> void:
|
||||
var remap_ui = LocalizationRemap.instantiate()
|
||||
_remaps_ui.add_child(remap_ui)
|
||||
remap_ui.set_data(key, remap, _data)
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://d3xv5mt01uv0l
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://bqdplxampikmo"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsList.gd" id="1"]
|
||||
[ext_resource type="PackedScene" path="res://addons/localization_editor/scenes/remaps/LocalizationRemapsHead.tscn" id="2"]
|
||||
|
||||
[node name="RemapsVBox" type="HBoxContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Separator" type="VSeparator" parent="."]
|
||||
offset_right = 4.0
|
||||
offset_bottom = 600.0
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
offset_left = 8.0
|
||||
offset_right = 1024.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Head" parent="VBox" instance=ExtResource( "2" )]
|
||||
offset_right = 1016.0
|
||||
offset_bottom = 69.0
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="VBox"]
|
||||
offset_top = 73.0
|
||||
offset_right = 1016.0
|
||||
offset_bottom = 600.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="RemapsList" type="VBoxContainer" parent="VBox/Scroll"]
|
||||
offset_right = 1016.0
|
||||
offset_bottom = 527.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
# Translation UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends MarginContainer
|
||||
|
||||
var _key
|
||||
var _locale
|
||||
var _translation
|
||||
var _data: LocalizationData
|
||||
|
||||
var _translation_ui_style_empty: StyleBoxFlat
|
||||
|
||||
@onready var _translation_ui = $HBox/Translation
|
||||
|
||||
func set_data(key, translation, locale, data: LocalizationData) -> void:
|
||||
_key = key
|
||||
_translation = translation
|
||||
_locale = locale
|
||||
_data = data
|
||||
_draw_view()
|
||||
|
||||
func _ready() -> void:
|
||||
_init_styles()
|
||||
_init_connections()
|
||||
|
||||
func _init_styles() -> void:
|
||||
var style_box = _translation_ui.get_theme_stylebox("normal", "LineEdit")
|
||||
_translation_ui_style_empty = style_box.duplicate()
|
||||
_translation_ui_style_empty.set_bg_color(Color("#661c1c"))
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _translation_ui.is_connected("text_changed", _on_text_changed):
|
||||
assert(_translation_ui.text_changed.connect(_on_text_changed) == OK)
|
||||
|
||||
func _draw_view() -> void:
|
||||
_translation_ui.text = _translation.value
|
||||
_check_translation_ui()
|
||||
|
||||
func _on_text_changed(new_text) -> void:
|
||||
_translation.value = new_text
|
||||
_check_translation_ui()
|
||||
|
||||
func _check_translation_ui() -> void:
|
||||
if _translation_ui.text.length() <= 0:
|
||||
_translation_ui.add_theme_stylebox_override("normal", _translation_ui_style_empty)
|
||||
_translation_ui.tooltip_text = "Please enter value for your translation"
|
||||
else:
|
||||
_translation_ui.remove_theme_stylebox_override("normal")
|
||||
_translation_ui.tooltip_text = ""
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://cfsaie5x0otef
|
||||
|
|
@ -0,0 +1,30 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://bnkc2ox5vcdkq"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslation.gd" id="1"]
|
||||
|
||||
[node name="LocalizationTranslation" type="MarginContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_min_size = Vector2(0, 33)
|
||||
theme_override_constants/margin_right = 3
|
||||
theme_override_constants/margin_left = 3
|
||||
theme_override_constants/margin_bottom = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="."]
|
||||
offset_left = 3.0
|
||||
offset_right = 1021.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Translation" type="LineEdit" parent="HBox"]
|
||||
offset_right = 1018.0
|
||||
offset_bottom = 597.0
|
||||
rect_min_size = Vector2(0, 24)
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
# Translations UI for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends Panel
|
||||
|
||||
var _data: LocalizationData
|
||||
|
||||
@onready var _translations_ui = $Scroll/Translations
|
||||
|
||||
const LocalizationTranslationsList = preload("res://addons/localization_editor/scenes/translations/LocalizationTranslationsList.tscn")
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_init_connections()
|
||||
_update_view()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _data.is_connected("data_changed", _update_view):
|
||||
assert(_data.data_changed.connect(_update_view) == OK)
|
||||
|
||||
func _update_view() -> void:
|
||||
_clear_ui_translations()
|
||||
_add_ui_translations()
|
||||
_view_ui_translations()
|
||||
_update_ui_translations()
|
||||
|
||||
func _clear_ui_translations() -> void:
|
||||
var translations_ui = _translations_ui.get_children()
|
||||
for translation_ui in translations_ui:
|
||||
if translation_ui.has_method("get_locale"):
|
||||
var locale = translation_ui.get_locale()
|
||||
if _data.find_locale(locale) == null:
|
||||
translations_ui.erase(translation_ui)
|
||||
translation_ui.queue_free()
|
||||
|
||||
func _add_ui_translations() -> void:
|
||||
var locales = _data.locales()
|
||||
for locale in locales:
|
||||
if not _ui_translation_exists(locale):
|
||||
_add_ui_translation(locale)
|
||||
|
||||
func _ui_translation_exists(locale) -> bool:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("get_locale"):
|
||||
if translation_ui.get_locale() == locale:
|
||||
return true
|
||||
return false
|
||||
|
||||
func _add_ui_translation(locale: String) -> void:
|
||||
var ui_translation = LocalizationTranslationsList.instantiate()
|
||||
_translations_ui.add_child(ui_translation)
|
||||
ui_translation.set_data(locale, _data)
|
||||
|
||||
func _view_ui_translations() -> void:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("get_locale"):
|
||||
var locale = translation_ui.get_locale()
|
||||
var serarator_ui = _separator_after_translation_ui(translation_ui)
|
||||
if _data.is_locale_visible(locale):
|
||||
translation_ui.show()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.show()
|
||||
else:
|
||||
translation_ui.hide()
|
||||
if serarator_ui != null:
|
||||
serarator_ui.hide()
|
||||
|
||||
func _separator_after_translation_ui(translation_ui: Node) -> Node:
|
||||
var index = translation_ui.get_index()
|
||||
var count = _translations_ui.get_child_count()
|
||||
if index + 1 < count:
|
||||
return _translations_ui.get_child(index + 1)
|
||||
return null
|
||||
|
||||
func _update_ui_translations() -> void:
|
||||
for translation_ui in _translations_ui.get_children():
|
||||
if translation_ui.has_method("update_view"):
|
||||
translation_ui.update_view()
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://c4l5sfsibw527
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://dfykqid37nnvl"]
|
||||
|
||||
[ext_resource type="Script" path="res://addons/localization_editor/scenes/translations/LocalizationTranslations.gd" id="1"]
|
||||
|
||||
[node name="LocalizationTranslations" type="Panel"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
script = ExtResource( "1" )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Scroll" type="ScrollContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Translations" type="HBoxContainer" parent="Scroll"]
|
||||
offset_right = 12.0
|
||||
offset_bottom = 12.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
|
@ -0,0 +1,68 @@
|
|||
# Translations view for LocalizationEditor : MIT License
|
||||
# @author Vladimir Petrenko
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
|
||||
var _data: LocalizationData
|
||||
var _split_viewport_size = 0
|
||||
var _scroll_position = 0
|
||||
|
||||
@onready var _split_ui = $Split
|
||||
@onready var _keys_ui = $Split/Keys
|
||||
@onready var _translations_ui = $Split/Translations
|
||||
@onready var _translations_list_ui = $Split/Translations/Scroll/Translations
|
||||
|
||||
func set_data(data: LocalizationData) -> void:
|
||||
_data = data
|
||||
_keys_ui.set_data(data)
|
||||
_translations_ui.set_data(data)
|
||||
_init_connections()
|
||||
|
||||
func _init_connections() -> void:
|
||||
if not _split_ui.is_connected("dragged", _on_split_dragged):
|
||||
assert(_split_ui.dragged.connect(_on_split_dragged) == OK)
|
||||
|
||||
func _process(delta):
|
||||
if _split_viewport_size != size.x:
|
||||
_split_viewport_size = size.x
|
||||
_init_split_offset()
|
||||
_update_scrolls()
|
||||
|
||||
func _init_split_offset() -> void:
|
||||
var offset = 350
|
||||
if _data:
|
||||
offset = _data.setting_translations_split_offset()
|
||||
_split_ui.set_split_offset(-size.x / 2 + offset)
|
||||
|
||||
func _on_split_dragged(offset: int) -> void:
|
||||
if _data != null:
|
||||
var value = -(-size.x / 2 - offset)
|
||||
_data.setting_translations_split_offset_put(value)
|
||||
|
||||
# Workaround for https://github.com/godotengine/godot/issues/22936
|
||||
func _update_scrolls() -> void:
|
||||
var sc = _new_scrolls_position()
|
||||
if _scroll_position != sc:
|
||||
_scroll_position = sc
|
||||
_keys_ui.set_v_scroll(_scroll_position)
|
||||
for child in _translations_list_ui.get_children():
|
||||
if child.has_method("set_v_scroll"):
|
||||
child.set_v_scroll(_scroll_position)
|
||||
|
||||
func _new_scrolls_position() -> int:
|
||||
if _keys_ui == null:
|
||||
return 0
|
||||
var v_1 = [_keys_ui.get_v_scroll()]
|
||||
var v_2 = []
|
||||
for child in _translations_list_ui.get_children():
|
||||
if child.has_method("get_v_scroll"):
|
||||
var v_child = child.get_v_scroll()
|
||||
if v_1[0] == v_child:
|
||||
v_1.append(v_child)
|
||||
else:
|
||||
v_2.append(v_child)
|
||||
if v_2.size() == 0:
|
||||
return v_1[0]
|
||||
if v_1.size() == 1:
|
||||
return v_1[0]
|
||||
return v_2[0]
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://80r1f854w4ml
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue