mirror of
https://github.com/Relintai/gdfxr.git
synced 2025-04-20 01:43:13 +02:00
Fix localization failure
This commit is contained in:
parent
eab1983c15
commit
accb9c1ffe
@ -45,22 +45,22 @@ func _ready():
|
|||||||
return # Running in the edited scene instead of from Plugin
|
return # Running in the edited scene instead of from Plugin
|
||||||
|
|
||||||
var popup := extra_button.get_popup()
|
var popup := extra_button.get_popup()
|
||||||
popup.add_item(translator.tr("Save As..."), ExtraOption.SAVE_AS)
|
popup.add_item(translator.t("Save As..."), ExtraOption.SAVE_AS)
|
||||||
popup.add_separator()
|
popup.add_separator()
|
||||||
popup.add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), translator.tr("Copy"), ExtraOption.COPY)
|
popup.add_icon_item(get_theme_icon("ActionCopy", "EditorIcons"), translator.t("Copy"), ExtraOption.COPY)
|
||||||
popup.add_icon_item(get_theme_icon("ActionPaste", "EditorIcons"), translator.tr("Paste"), ExtraOption.PASTE)
|
popup.add_icon_item(get_theme_icon("ActionPaste", "EditorIcons"), translator.t("Paste"), ExtraOption.PASTE)
|
||||||
popup.add_item(translator.tr("Paste from jsfxr"), ExtraOption.PASTE_JSFXR)
|
popup.add_item(translator.t("Paste from jsfxr"), ExtraOption.PASTE_JSFXR)
|
||||||
popup.add_separator(translator.tr("Recently Generated"))
|
popup.add_separator(translator.t("Recently Generated"))
|
||||||
popup.id_pressed.connect(_on_Extra_id_pressed)
|
popup.id_pressed.connect(_on_Extra_id_pressed)
|
||||||
|
|
||||||
_category_names = {
|
_category_names = {
|
||||||
SFXRConfig.Category.PICKUP_COIN: translator.tr("Pickup/Coin"),
|
SFXRConfig.Category.PICKUP_COIN: translator.t("Pickup/Coin"),
|
||||||
SFXRConfig.Category.LASER_SHOOT: translator.tr("Laser/Shoot"),
|
SFXRConfig.Category.LASER_SHOOT: translator.t("Laser/Shoot"),
|
||||||
SFXRConfig.Category.EXPLOSION: translator.tr("Explosion"),
|
SFXRConfig.Category.EXPLOSION: translator.t("Explosion"),
|
||||||
SFXRConfig.Category.POWERUP: translator.tr("Powerup"),
|
SFXRConfig.Category.POWERUP: translator.t("Powerup"),
|
||||||
SFXRConfig.Category.HIT_HURT: translator.tr("Hit/Hurt"),
|
SFXRConfig.Category.HIT_HURT: translator.t("Hit/Hurt"),
|
||||||
SFXRConfig.Category.JUMP: translator.tr("Jump"),
|
SFXRConfig.Category.JUMP: translator.t("Jump"),
|
||||||
SFXRConfig.Category.BLIP_SELECT: translator.tr("Blip/Select"),
|
SFXRConfig.Category.BLIP_SELECT: translator.t("Blip/Select"),
|
||||||
}
|
}
|
||||||
|
|
||||||
var params := find_child("Params") as Container
|
var params := find_child("Params") as Container
|
||||||
@ -97,7 +97,7 @@ func edit(object: Variant) -> void:
|
|||||||
var path := object.resource_path as String
|
var path := object.resource_path as String
|
||||||
if _modified:
|
if _modified:
|
||||||
_popup_confirm(
|
_popup_confirm(
|
||||||
translator.tr("There are unsaved changes.\nOpen '%s' anyway?") % path,
|
translator.t("There are unsaved changes.\nOpen '%s' anyway?") % path,
|
||||||
_set_editing_file.bind(path)
|
_set_editing_file.bind(path)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -129,7 +129,7 @@ func _popup_confirm(content: String, callback: Callable) -> void:
|
|||||||
var dialog := ConfirmationDialog.new()
|
var dialog := ConfirmationDialog.new()
|
||||||
add_child(dialog)
|
add_child(dialog)
|
||||||
dialog.dialog_text = content
|
dialog.dialog_text = content
|
||||||
dialog.title = translator.tr("SFXR Editor")
|
dialog.title = translator.t("SFXR Editor")
|
||||||
dialog.confirmed.connect(callback)
|
dialog.confirmed.connect(callback)
|
||||||
dialog.popup_centered()
|
dialog.popup_centered()
|
||||||
dialog.visibility_changed.connect(dialog.queue_free)
|
dialog.visibility_changed.connect(dialog.queue_free)
|
||||||
@ -139,7 +139,7 @@ func _popup_message(content: String) -> void:
|
|||||||
var dialog := AcceptDialog.new()
|
var dialog := AcceptDialog.new()
|
||||||
add_child(dialog)
|
add_child(dialog)
|
||||||
dialog.dialog_text = content
|
dialog.dialog_text = content
|
||||||
dialog.title = translator.tr("SFXR Editor")
|
dialog.title = translator.t("SFXR Editor")
|
||||||
dialog.popup_centered()
|
dialog.popup_centered()
|
||||||
dialog.visibility_changed.connect(dialog.queue_free)
|
dialog.visibility_changed.connect(dialog.queue_free)
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ func _popup_file_dialog(mode: int, callback: Callable, default_filename := Defau
|
|||||||
if _path:
|
if _path:
|
||||||
dialog.current_path = _generate_serial_path(_path)
|
dialog.current_path = _generate_serial_path(_path)
|
||||||
|
|
||||||
dialog.add_filter("*.sfxr; %s" % translator.tr("SFXR Audio"))
|
dialog.add_filter("*.sfxr; %s" % translator.t("SFXR Audio"))
|
||||||
dialog.file_selected.connect(callback)
|
dialog.file_selected.connect(callback)
|
||||||
dialog.popup_centered_ratio()
|
dialog.popup_centered_ratio()
|
||||||
dialog.visibility_changed.connect(dialog.queue_free)
|
dialog.visibility_changed.connect(dialog.queue_free)
|
||||||
@ -184,7 +184,7 @@ func _set_editing_file(path: String) -> int: # Error
|
|||||||
else:
|
else:
|
||||||
var err := _config.load(path)
|
var err := _config.load(path)
|
||||||
if err != OK:
|
if err != OK:
|
||||||
_popup_message(translator.tr("'%s' is not a valid SFXR file.") % path)
|
_popup_message(translator.t("'%s' is not a valid SFXR file.") % path)
|
||||||
return err
|
return err
|
||||||
audio_player.stream = load(path)
|
audio_player.stream = load(path)
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ func _set_modified(value: bool) -> void:
|
|||||||
_modified = value
|
_modified = value
|
||||||
|
|
||||||
var has_file := not _path.is_empty()
|
var has_file := not _path.is_empty()
|
||||||
var base = _path if has_file else translator.tr("Unsaved sound")
|
var base = _path if has_file else translator.t("Unsaved sound")
|
||||||
if _modified:
|
if _modified:
|
||||||
base += "(*)"
|
base += "(*)"
|
||||||
filename_label.text = base
|
filename_label.text = base
|
||||||
@ -281,7 +281,7 @@ func _on_Play_pressed(force_regenerate := false):
|
|||||||
func _on_Randomize_pressed(category: int):
|
func _on_Randomize_pressed(category: int):
|
||||||
if category == -1:
|
if category == -1:
|
||||||
_config.randomize()
|
_config.randomize()
|
||||||
_push_recent(translator.tr("Randomize"))
|
_push_recent(translator.t("Randomize"))
|
||||||
else:
|
else:
|
||||||
_config.randomize_in_category(category)
|
_config.randomize_in_category(category)
|
||||||
_push_recent(_category_names.get(category, "Unknown"))
|
_push_recent(_category_names.get(category, "Unknown"))
|
||||||
@ -294,7 +294,7 @@ func _on_Randomize_pressed(category: int):
|
|||||||
func _on_Mutate_pressed():
|
func _on_Mutate_pressed():
|
||||||
_config.mutate()
|
_config.mutate()
|
||||||
|
|
||||||
_push_recent(translator.tr("Mutate"))
|
_push_recent(translator.t("Mutate"))
|
||||||
_set_modified(true)
|
_set_modified(true)
|
||||||
_sync_ui()
|
_sync_ui()
|
||||||
_on_Play_pressed(true)
|
_on_Play_pressed(true)
|
||||||
@ -307,7 +307,7 @@ func _on_Restore_pressed():
|
|||||||
func _on_New_pressed():
|
func _on_New_pressed():
|
||||||
if _modified:
|
if _modified:
|
||||||
_popup_confirm(
|
_popup_confirm(
|
||||||
translator.tr("There are unsaved changes.\nCreate a new one anyway?"),
|
translator.t("There are unsaved changes.\nCreate a new one anyway?"),
|
||||||
_on_New_confirmed
|
_on_New_confirmed
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -337,7 +337,7 @@ func _on_SaveAsDialog_confirmed(path: String):
|
|||||||
func _on_Load_pressed():
|
func _on_Load_pressed():
|
||||||
if _modified:
|
if _modified:
|
||||||
_popup_confirm(
|
_popup_confirm(
|
||||||
translator.tr("There are unsaved changes.\nLoad anyway?"),
|
translator.t("There are unsaved changes.\nLoad anyway?"),
|
||||||
_popup_file_dialog.bind(EditorFileDialog.FILE_MODE_OPEN_FILE, "_set_editing_file")
|
_popup_file_dialog.bind(EditorFileDialog.FILE_MODE_OPEN_FILE, "_set_editing_file")
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
@ -357,7 +357,7 @@ func _on_Extra_about_to_show():
|
|||||||
popup.remove_item(count - 1 - i)
|
popup.remove_item(count - 1 - i)
|
||||||
|
|
||||||
if _config_recents.is_empty():
|
if _config_recents.is_empty():
|
||||||
popup.add_item(translator.tr("None"), ExtraOption.RECENT)
|
popup.add_item(translator.t("None"), ExtraOption.RECENT)
|
||||||
popup.set_item_disabled(popup.get_item_index(ExtraOption.RECENT), true)
|
popup.set_item_disabled(popup.get_item_index(ExtraOption.RECENT), true)
|
||||||
else:
|
else:
|
||||||
for i in _config_recents.size():
|
for i in _config_recents.size():
|
||||||
@ -382,7 +382,7 @@ func _on_Extra_id_pressed(id: int) -> void:
|
|||||||
if pasted.load_from_base58(DisplayServer.clipboard_get()) == OK:
|
if pasted.load_from_base58(DisplayServer.clipboard_get()) == OK:
|
||||||
_restore_from_config(pasted)
|
_restore_from_config(pasted)
|
||||||
else:
|
else:
|
||||||
_popup_message(translator.tr("Clipboard does not contain code copied from jsfxr."))
|
_popup_message(translator.t("Clipboard does not contain code copied from jsfxr."))
|
||||||
|
|
||||||
_:
|
_:
|
||||||
var i := id - ExtraOption.RECENT as int
|
var i := id - ExtraOption.RECENT as int
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
[ext_resource type="Script" path="res://addons/gdfxr/editor/Editor.gd" id="2"]
|
[ext_resource type="Script" path="res://addons/gdfxr/editor/Editor.gd" id="2"]
|
||||||
[ext_resource type="PackedScene" uid="uid://p27e3x3kk5e0" path="res://addons/gdfxr/editor/ParamSlider.tscn" id="3"]
|
[ext_resource type="PackedScene" uid="uid://p27e3x3kk5e0" path="res://addons/gdfxr/editor/ParamSlider.tscn" id="3"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b8wt6fq8w6mxc" path="res://addons/gdfxr/editor/ParamOption.tscn" id="4"]
|
[ext_resource type="PackedScene" uid="uid://b8wt6fq8w6mxc" path="res://addons/gdfxr/editor/ParamOption.tscn" id="4"]
|
||||||
[ext_resource type="PackedScene" path="res://addons/gdfxr/editor/PluginTranslator.tscn" id="5"]
|
[ext_resource type="PackedScene" uid="uid://cewvefxbttrds" path="res://addons/gdfxr/editor/PluginTranslator.tscn" id="5"]
|
||||||
[ext_resource type="PackedScene" path="res://addons/gdfxr/editor/VersionButton.tscn" id="6"]
|
[ext_resource type="PackedScene" path="res://addons/gdfxr/editor/VersionButton.tscn" id="6"]
|
||||||
|
|
||||||
[node name="Editor" type="VBoxContainer"]
|
[node name="Editor" type="VBoxContainer"]
|
||||||
|
@ -9,34 +9,22 @@ offset_bottom = 40.0
|
|||||||
pivot_offset = Vector2(41, -65)
|
pivot_offset = Vector2(41, -65)
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
options = []
|
|
||||||
parameter = ""
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
custom_minimum_size = Vector2i(100, 0)
|
custom_minimum_size = Vector2(100, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_top = 7.0
|
|
||||||
offset_right = 132.0
|
|
||||||
offset_bottom = 33.0
|
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
text = "Waveform"
|
text = "Waveform"
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
[node name="OptionButton" type="OptionButton" parent="."]
|
[node name="OptionButton" type="OptionButton" parent="."]
|
||||||
custom_minimum_size = Vector2i(105, 0)
|
custom_minimum_size = Vector2(105, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = 136.0
|
|
||||||
offset_top = 10.0
|
|
||||||
offset_right = 241.0
|
|
||||||
offset_bottom = 30.0
|
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
clip_text = true
|
clip_text = true
|
||||||
|
|
||||||
[node name="Reset" type="Button" parent="."]
|
[node name="Reset" type="Button" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = 245.0
|
|
||||||
offset_top = 16.0
|
|
||||||
offset_right = 253.0
|
|
||||||
offset_bottom = 24.0
|
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
flat = true
|
flat = true
|
||||||
|
@ -9,35 +9,23 @@ offset_right = 253.0
|
|||||||
offset_bottom = 40.0
|
offset_bottom = 40.0
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
script = ExtResource("1")
|
script = ExtResource("1")
|
||||||
label = ""
|
|
||||||
parameter = ""
|
|
||||||
|
|
||||||
[node name="Label" type="Label" parent="."]
|
[node name="Label" type="Label" parent="."]
|
||||||
custom_minimum_size = Vector2i(100, 0)
|
custom_minimum_size = Vector2(100, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_top = 8.0
|
|
||||||
offset_right = 132.0
|
|
||||||
offset_bottom = 31.0
|
|
||||||
size_flags_horizontal = 3
|
size_flags_horizontal = 3
|
||||||
|
horizontal_alignment = 2
|
||||||
|
|
||||||
[node name="HSlider" type="Control" parent="."]
|
[node name="HSlider" type="Control" parent="."]
|
||||||
clip_contents = true
|
clip_contents = true
|
||||||
custom_minimum_size = Vector2i(105, 0)
|
custom_minimum_size = Vector2(105, 0)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
anchors_preset = 0
|
|
||||||
offset_left = 136.0
|
|
||||||
offset_right = 241.0
|
|
||||||
offset_bottom = 40.0
|
|
||||||
focus_mode = 2
|
focus_mode = 2
|
||||||
mouse_default_cursor_shape = 10
|
mouse_default_cursor_shape = 10
|
||||||
script = ExtResource("3")
|
script = ExtResource("3")
|
||||||
|
|
||||||
[node name="Reset" type="Button" parent="."]
|
[node name="Reset" type="Button" parent="."]
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
offset_left = 245.0
|
|
||||||
offset_top = 16.0
|
|
||||||
offset_right = 253.0
|
|
||||||
offset_bottom = 24.0
|
|
||||||
size_flags_vertical = 4
|
size_flags_vertical = 4
|
||||||
focus_mode = 0
|
focus_mode = 0
|
||||||
flat = true
|
flat = true
|
||||||
|
@ -23,10 +23,10 @@ func set_plugin(v: EditorPlugin) -> void:
|
|||||||
_translation = ResourceLoader.load(path)
|
_translation = ResourceLoader.load(path)
|
||||||
|
|
||||||
if _translation:
|
if _translation:
|
||||||
_translate_node(get_parent())
|
_translate_node.call_deferred(get_parent())
|
||||||
|
|
||||||
|
|
||||||
func tr(message: StringName, context := StringName()) -> String:
|
func t(message: StringName) -> String:
|
||||||
if _translation:
|
if _translation:
|
||||||
var translated := _translation.get_message(message)
|
var translated := _translation.get_message(message)
|
||||||
if translated:
|
if translated:
|
||||||
@ -36,22 +36,22 @@ func tr(message: StringName, context := StringName()) -> String:
|
|||||||
|
|
||||||
func _translate_node(node: Node):
|
func _translate_node(node: Node):
|
||||||
if node is Control:
|
if node is Control:
|
||||||
node.tooltip_text = tr(node.tooltip_text)
|
node.tooltip_text = t(node.tooltip_text)
|
||||||
|
|
||||||
if node is HBoxContainer and node.has_method("set_options"):
|
if node is HBoxContainer and node.has_method("set_options"):
|
||||||
var options = []
|
var options = []
|
||||||
for item in node.options:
|
for item in node.options:
|
||||||
options.append(tr(item))
|
options.append(t(item))
|
||||||
node.options = options
|
node.options = options
|
||||||
|
|
||||||
if node is Button and not node is OptionButton:
|
if node is Button and not node is OptionButton:
|
||||||
node.text = tr(node.text)
|
node.text = t(node.text)
|
||||||
|
|
||||||
if node is Label:
|
if node is Label:
|
||||||
node.text = tr(node.text)
|
node.text = t(node.text)
|
||||||
|
|
||||||
if node is Slider:
|
if node is Slider:
|
||||||
node.tooltip_text = tr(node.tooltip_text)
|
node.tooltip_text = t(node.tooltip_text)
|
||||||
|
|
||||||
for child in node.get_children():
|
for child in node.get_children():
|
||||||
_translate_node(child)
|
_translate_node(child)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=3 uid="uid://cewvefxbttrds"]
|
||||||
|
|
||||||
[ext_resource path="res://addons/gdfxr/editor/PluginTranslator.gd" type="Script" id=1]
|
[ext_resource type="Script" path="res://addons/gdfxr/editor/PluginTranslator.gd" id="1"]
|
||||||
|
|
||||||
[node name="PluginTranslator" type="Node"]
|
[node name="PluginTranslator" type="Node"]
|
||||||
script = ExtResource( 1 )
|
script = ExtResource("1")
|
||||||
|
Loading…
Reference in New Issue
Block a user