diff --git a/Main.tscn b/Main.tscn index 8fa5b34..4820a9a 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1294,7 +1294,7 @@ margin_bottom = 42.0 margin_top = 5.0 margin_right = 46.0 margin_bottom = 19.0 -text = "Width: " +text = "Width:" [node name="WidthValue" type="SpinBox" parent="CreateNewImage/VBoxContainer/WidthCont"] margin_left = 50.0 @@ -1402,7 +1402,6 @@ margin_right = 200.0 margin_bottom = 114.0 [node name="VBoxContainer" type="VBoxContainer" parent="ScaleImage"] -editor/display_folded = true margin_left = 8.0 margin_top = 8.0 margin_right = 192.0 @@ -1414,7 +1413,6 @@ margin_bottom = 14.0 text = "Image Size" [node name="WidthCont" type="HBoxContainer" parent="ScaleImage/VBoxContainer"] -editor/display_folded = true margin_top = 18.0 margin_right = 184.0 margin_bottom = 42.0 @@ -1423,7 +1421,7 @@ margin_bottom = 42.0 margin_top = 5.0 margin_right = 46.0 margin_bottom = 19.0 -text = "Width: " +text = "Width:" [node name="WidthValue" type="SpinBox" parent="ScaleImage/VBoxContainer/WidthCont"] margin_left = 50.0 @@ -1474,6 +1472,30 @@ text = "Nearest" items = [ "Nearest", null, false, 0, null, "Bilinear", null, false, 1, null, "Cubic", null, false, 2, null, "Trilinear", null, false, 3, null, "Lanczos", null, true, 4, null ] selected = 0 +[node name="PreferencesDialog" type="AcceptDialog" parent="."] +editor/display_folded = true +margin_right = 200.0 +margin_bottom = 70.0 +window_title = "Preferences" + +[node name="LanguageContainer" type="HBoxContainer" parent="PreferencesDialog"] +margin_right = 40.0 +margin_bottom = 40.0 + +[node name="LanguageLabel" type="Label" parent="PreferencesDialog/LanguageContainer"] +margin_top = 12.0 +margin_right = 57.0 +margin_bottom = 27.0 +text = "Language:" + +[node name="LanguageOption" type="OptionButton" parent="PreferencesDialog/LanguageContainer"] +margin_left = 61.0 +margin_right = 142.0 +margin_bottom = 40.0 +text = "English" +items = [ "System Language", null, false, 0, null, "Greek", null, false, 1, null, "English", null, false, 2, null ] +selected = 0 + [node name="AboutDialog" type="AcceptDialog" parent="."] editor/display_folded = true margin_right = 284.0 @@ -1610,6 +1632,8 @@ dialog_text = "Are you sure you want to exit Pixelorama?" [connection signal="popup_hide" from="ExportSprites" to="." method="_can_draw_true"] [connection signal="confirmed" from="ScaleImage" to="." method="_on_ScaleImage_confirmed"] [connection signal="popup_hide" from="ScaleImage" to="." method="_can_draw_true"] +[connection signal="popup_hide" from="PreferencesDialog" to="." method="_can_draw_true"] +[connection signal="item_selected" from="PreferencesDialog/LanguageContainer/LanguageOption" to="." method="_on_LanguageOption_item_selected"] [connection signal="popup_hide" from="AboutDialog" to="." method="_can_draw_true"] [connection signal="pressed" from="AboutDialog/AboutUI/Links/LinkButtons/Website" to="AboutDialog" method="_on_Website_pressed"] [connection signal="pressed" from="AboutDialog/AboutUI/Links/LinkButtons/GitHub" to="AboutDialog" method="_on_GitHub_pressed"] diff --git a/Scripts/Main.gd b/Scripts/Main.gd index 8723dce..145478b 100644 --- a/Scripts/Main.gd +++ b/Scripts/Main.gd @@ -1,6 +1,7 @@ extends Control -var config_cache : ConfigFile = ConfigFile.new() +var config_cache := ConfigFile.new() +var loaded_locales : Array var current_save_path := "" var current_export_path := "" var opensprite_file_selected := false @@ -23,9 +24,25 @@ func _ready() -> void: # This property is only available in 3.2alpha or later, so use `set()` to fail gracefully if it doesn't exist. OS.set("min_window_size", Vector2(1152, 648)) - # Restore the window position/size if values are present in the configuration cache + #Make sure locales are always sorted, in the same order + loaded_locales = TranslationServer.get_loaded_locales() + loaded_locales.sort() + + # Load settings from the config file config_cache.load("user://cache.ini") + # Load language + if config_cache.has_section_key("preferences", "locale"): + var saved_locale : String = config_cache.get_value("preferences", "locale") + TranslationServer.set_locale(saved_locale) + + # Set the language option menu's default selected option to the loaded locale + var locale_index := loaded_locales.find(saved_locale) + $PreferencesDialog/LanguageContainer/LanguageOption.selected = locale_index + 1 + else: # If the user doesn't have a language preference, set it to their OS' locale + TranslationServer.set_locale(OS.get_locale()) + + # Restore the window position/size if values are present in the configuration cache if config_cache.has_section_key("window", "screen"): OS.current_screen = config_cache.get_value("window", "screen") if config_cache.has_section_key("window", "maximized"): @@ -38,32 +55,33 @@ func _ready() -> void: OS.window_size = config_cache.get_value("window", "size") var file_menu_items := { - "New..." : KEY_MASK_CTRL + KEY_N, - "Open..." : KEY_MASK_CTRL + KEY_O, - "Save..." : KEY_MASK_CTRL + KEY_S, - "Save as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S, - "Import..." : KEY_MASK_CTRL + KEY_I, - "Export PNG..." : KEY_MASK_CTRL + KEY_E, - "Export PNG as..." : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E, - "Quit" : KEY_MASK_CTRL + KEY_Q + tr("New...") : KEY_MASK_CTRL + KEY_N, + tr("Open...") : KEY_MASK_CTRL + KEY_O, + tr("Save...") : KEY_MASK_CTRL + KEY_S, + tr("Save as...") : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_S, + tr("Import PNG...") : KEY_MASK_CTRL + KEY_I, + tr("Export PNG...") : KEY_MASK_CTRL + KEY_E, + tr("Export PNG as...") : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_E, + tr("Quit") : KEY_MASK_CTRL + KEY_Q } var edit_menu_items := { - "Undo" : KEY_MASK_CTRL + KEY_Z, - "Redo" : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Z, - "Scale Image" : 0, - "Crop Image" : 0, - "Clear Selection" : 0, - "Flip Horizontal": KEY_MASK_SHIFT + KEY_H, - "Flip Vertical": KEY_MASK_SHIFT + KEY_V + tr("Undo") : KEY_MASK_CTRL + KEY_Z, + tr("Redo") : KEY_MASK_SHIFT + KEY_MASK_CTRL + KEY_Z, + tr("Scale Image") : 0, + tr("Crop Image") : 0, + tr("Clear Selection") : 0, + tr("Flip Horizontal") : KEY_MASK_SHIFT + KEY_H, + tr("Flip Vertical") : KEY_MASK_SHIFT + KEY_V, + tr("Preferences") : 0 } var view_menu_items := { - "Tile Mode" : KEY_MASK_CTRL + KEY_T, - "Show Grid" : KEY_MASK_CTRL + KEY_G, - "Show Rulers": KEY_MASK_CTRL + KEY_R, - "Show Guides": KEY_MASK_CTRL + KEY_Y + tr("Tile Mode") : KEY_MASK_CTRL + KEY_T, + tr("Show Grid") : KEY_MASK_CTRL + KEY_G, + tr("Show Rulers") : KEY_MASK_CTRL + KEY_R, + tr("Show Guides") : KEY_MASK_CTRL + KEY_Y } var help_menu_items := { - "About Pixelorama" : 0 + tr("About Pixelorama") : 0 } var file_menu : PopupMenu = Global.file_menu.get_popup() var edit_menu : PopupMenu = Global.edit_menu.get_popup() @@ -259,6 +277,9 @@ func edit_menu_id_pressed(id : int) -> void: canvas.layers[canvas.current_layer_index][0].flip_y() canvas.layers[canvas.current_layer_index][0].lock() canvas.handle_redo("Draw") + 7: #Preferences + $PreferencesDialog.popup_centered() + Global.can_draw = false func view_menu_id_pressed(id : int) -> void: match id: @@ -588,6 +609,15 @@ func _on_ScaleImage_confirmed() -> void: Global.undo_redo.add_do_method(Global, "redo", [Global.canvas]) Global.undo_redo.commit_action() +func _on_LanguageOption_item_selected(ID : int) -> void: + if ID == 0: + TranslationServer.set_locale(OS.get_locale()) + else: + TranslationServer.set_locale(loaded_locales[ID - 1]) + + config_cache.set_value("preferences", "locale", TranslationServer.get_locale()) + config_cache.save("user://cache.ini") + func _on_ImportSprites_popup_hide() -> void: if !opensprite_file_selected: Global.can_draw = true @@ -973,3 +1003,4 @@ func _exit_tree() -> void: config_cache.set_value("window", "position", OS.window_position) config_cache.set_value("window", "size", OS.window_size) config_cache.save("user://cache.ini") + diff --git a/Translations/#Translations.csv b/Translations/#Translations.csv new file mode 100644 index 0000000..c117c30 --- /dev/null +++ b/Translations/#Translations.csv @@ -0,0 +1,41 @@ +id en el +OK OK Εντάξει +Cancel Cancel Άκυρο +Open Open Άνοιγμα +Please Confirm... Please Confirm... Παρακαλώ επιβεβαιώστε... +Width: Width: Πλάτος: +Height: Height: Ύψος: +File File Αρχείο +Edit Edit Επεξεργασία +View View Προβολή +Help Help Βοήθεια +New... New... Νέο... +Open... Open... Άνοιγμα... +Save... Save... Αποθήκευση... +Save as... Save as... Αποθήκευση ως... +Import PNG... Import PNG... Εισαγωγή PNG... +Export PNG... Export PNG... Εξαγωγή PNG... +Export PNG as... Export PNG as... Εξαγωγή PNG ως... +Quit Quit Έξοδος +Undo Undo Αναίρεση +Redo Redo Ακύρωση αναίρεσης +Scale Image Scale Image Κλιμάκωση εικόνας +Crop Image Crop Image Περικοπή +Clear Selection Clear Selection Καθαρισμός επιλογής +Flip Horizontal Flip Horizontal Οριζόντια αναστροφή +Flip Vertical Flip Vertical Κάθετη αναστροφή +Preferences Preferences Προτιμήσεις +Language: Language: Γλώσσα: +System Language System Language Γλώσσα Συστήματος +English English Αγγλικά +Greek Greek Ελληνικά +Tile Mode Tile Mode Λειτουργία μοτίβου +Show Grid Show Grid Εμφάνιση πλέγματος +Show Rulers Show Rulers Εμφάνιση χαράκων +Show Guides Show Guides Εμφάνιση οδηγών +About Pixelorama About Pixelorama Σχετικά με το Pixelorama +Utility Tools Utility Tools Βοηθητικά Εργαλεία +Draw Tools Draw Tools Εργαλεία Ζωγραφικής +Left tool options Left tool options Επιλογές αριστερού εργαλείου +Right tool options Right tool options Επιλογές δεξιού εργαλείου +Layers Layers Στρώσεις \ No newline at end of file diff --git a/Translations/#Translations.csv.import b/Translations/#Translations.csv.import new file mode 100644 index 0000000..5e632a1 --- /dev/null +++ b/Translations/#Translations.csv.import @@ -0,0 +1,16 @@ +[remap] + +importer="csv_translation" +type="Translation" + +[deps] + +files=[ "res://Translations/#Translations.en.translation", "res://Translations/#Translations.el.translation" ] + +source_file="res://Translations/#Translations.csv" +dest_files=[ "res://Translations/#Translations.en.translation", "res://Translations/#Translations.el.translation" ] + +[params] + +compress=true +delimiter=2 diff --git a/Translations/#Translations.el.translation b/Translations/#Translations.el.translation new file mode 100644 index 0000000..795e17d Binary files /dev/null and b/Translations/#Translations.el.translation differ diff --git a/Translations/#Translations.en.translation b/Translations/#Translations.en.translation new file mode 100644 index 0000000..37e58d5 Binary files /dev/null and b/Translations/#Translations.en.translation differ diff --git a/project.godot b/project.godot index 8516337..c54c6f4 100644 --- a/project.godot +++ b/project.godot @@ -178,6 +178,11 @@ right_colorpicker_tool={ ] } +[locale] + +translations=PoolStringArray( "res://Translations/#Translations.en.translation", "res://Translations/#Translations.el.translation" ) +locale_filter=[ 0, [ ] ] + [rendering] quality/driver/driver_name="GLES2"