Migrate translations to QT translations.

This commit is contained in:
leha-code 2022-08-10 10:46:43 -04:00
parent 77204b6eb5
commit d0a488d03f
No known key found for this signature in database
GPG Key ID: 15227A6455DDF7EE
9 changed files with 256 additions and 346 deletions

View File

@ -1,163 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-04-15 19:08-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: main.py:134
msgid ""
"Please select the executable you downloaded.\n"
"If you installed a DEB, please select the \"Link\" option"
msgstr ""
#: main.py:138 main.py:182
msgid "Select executable"
msgstr ""
#: main.py:143
msgid "Link /usr/bin/minecraft-pi-reborn-client"
msgstr ""
#: main.py:148
msgid "Link flatpak"
msgstr ""
#: main.py:227
msgid "Launched with Planet Launcher"
msgstr ""
#: main.py:228
msgid "Minecraft Pi Edition: Reborn"
msgstr ""
#: main.py:238
msgid "Unable to initalize Discord RPC. Skipping."
msgstr ""
#: main.py:269
msgid "Planet"
msgstr ""
#: main.py:283
msgid "Play"
msgstr ""
#: main.py:288
msgid "Features"
msgstr ""
#: main.py:293
msgid "Servers"
msgstr ""
#: main.py:299
msgid "Settings"
msgstr ""
#: main.py:359
msgid "Banana Launcher"
msgstr ""
#: main.py:363
msgid "Pluto Launcher"
msgstr ""
#: main.py:365
msgid "Planet Launcher"
msgstr ""
#: main.py:378
msgid "Username"
msgstr ""
#: main.py:381
msgid "StevePi"
msgstr ""
#: main.py:384
msgid "Render Distance"
msgstr ""
#: main.py:391
msgid "Profile"
msgstr ""
#: main.py:406
msgid "Hide Launcher"
msgstr ""
#: main.py:535
msgid "Servers are stored in the format of <font color=\"gold\">IP: </font><font color=\"blue\">Port</font>"
msgstr ""
#: main.py:588
msgid "Set the skin"
msgstr ""
#: main.py:590
msgid "Select Skin"
msgstr ""
#: main.py:593
msgid "Reset config"
msgstr ""
#: main.py:595
msgid "Delete config"
msgstr ""
#: main.py:598
msgid "Delete executable"
msgstr ""
#: main.py:600
msgid "Delete"
msgstr ""
#: main.py:603
msgid "Import settings"
msgstr ""
#: main.py:623
msgid "General"
msgstr ""
#: main.py:624
msgid "Changelog"
msgstr ""
#: main.py:625
msgid "MCPIEdit"
msgstr ""
#: main.py:705
msgid "Select skin file"
msgstr ""
#: main.py:719 main.py:736
msgid "Are you sure you want to reset?"
msgstr ""
#: main.py:721
msgid "Are you sure you want to delete the config? This action is unrecoverable."
msgstr ""
#: main.py:738
msgid "Are you sure you want to delete the AppImage? This action is unrecoverable."
msgstr ""
#: main.py:812
msgid "Using /usr/bin as an executable."
msgstr ""

View File

@ -1,124 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2022-04-15 19:08-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: mcpiedit.py:74
msgid ""
"The default built-in NBT editor for Planet.\n"
"\n"
"MCPIedit makes use of Pi-NBT\n"
" from the original MCPIedit project\n"
"by TheBrokenRail, which is\n"
"licensed under the MIT license."
msgstr ""
#: mcpiedit.py:91
msgid ""
"NBT editors allow you to edit your world\n"
"files to change game modes, time,\n"
"and even the world name. Select an NBT\n"
"file to edit using the button below."
msgstr ""
#: mcpiedit.py:95
msgid "Select NBT File"
msgstr ""
#: mcpiedit.py:97
msgid "About"
msgstr ""
#: mcpiedit.py:125
msgid "General"
msgstr ""
#: mcpiedit.py:126
msgid "World"
msgstr ""
#: mcpiedit.py:155
msgid "World name"
msgstr ""
#: mcpiedit.py:158
msgid "OneChunk"
msgstr ""
#: mcpiedit.py:166
msgid "Last Played Timestamp"
msgstr ""
#: mcpiedit.py:171
msgid "Game mode"
msgstr ""
#: mcpiedit.py:181
msgid "Time (In Ticks)"
msgstr ""
#: mcpiedit.py:187
msgid "Back"
msgstr ""
#: mcpiedit.py:189
msgid "Save"
msgstr ""
#: mcpiedit.py:218
msgid "Spawnpoint X"
msgstr ""
#: mcpiedit.py:224
msgid "Spawnpoint Y"
msgstr ""
#: mcpiedit.py:230
msgid "Spawnpoint Z"
msgstr ""
#: mcpiedit.py:236
msgid "Player Spawnpoint X"
msgstr ""
#: mcpiedit.py:242
msgid "Player Spawnpoint Y"
msgstr ""
#: mcpiedit.py:248
msgid "Player Spawnpoint Z"
msgstr ""
#: mcpiedit.py:263
msgid ""
"Note:\n"
"Player spawnpoints are very buggy!\n"
"You might spawn in the wrong\n"
"place or even outside the world!\n"
"Do not use on valuable worlds."
msgstr ""
#: mcpiedit.py:328
msgid "Open NBT File"
msgstr ""
#: mcpiedit.py:330
msgid "Minecraft Pi Level NBT (level.dat)"
msgstr ""
#: mcpiedit.py:349
msgid "MCPIEdit"
msgstr ""

Binary file not shown.

View File

@ -0,0 +1,196 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1" language="en" sourcelanguage="en">
<context>
<name>ConfigPluto</name>
<message>
<location filename="main.py" line="134"/>
<source>Please select the executable you downloaded.
If you installed a DEB, please select the &quot;Link&quot; option</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="183"/>
<source>Select executable</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="145"/>
<source>Link /usr/bin/minecraft-pi-reborn-client</source>
<translation></translation>
</message>
</context>
<context>
<name>Planet</name>
<message>
<location filename="main.py" line="231"/>
<source>Launched with Planet Launcher</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="231"/>
<source>Minecraft Pi Edition: Reborn</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="242"/>
<source>Unable to initalize Discord RPC. Skipping.</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="274"/>
<source>Planet</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="288"/>
<source>Play</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="292"/>
<source>Features</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="298"/>
<source>Servers</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="304"/>
<source>Settings</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="365"/>
<source>Banana Launcher</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="370"/>
<source>Pluto Launcher</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="372"/>
<source>Planet Launcher</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="385"/>
<source>Username</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="390"/>
<source>StevePi</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="392"/>
<source>Render Distance</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="400"/>
<source>Profile</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="416"/>
<source>Hide Launcher</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="545"/>
<source>Servers are stored in the format of &lt;font color=&quot;gold&quot;&gt;IP: &lt;/font&gt;&lt;font color=&quot;blue&quot;&gt;Port&lt;/font&gt;</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="601"/>
<source>Set the skin</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="603"/>
<source>Select Skin</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="606"/>
<source>Reset config</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="608"/>
<source>Delete config</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="611"/>
<source>Delete executable</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="623"/>
<source>Delete</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="616"/>
<source>Install texture pack</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="618"/>
<source>Select file</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="621"/>
<source>Delete texture pack</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="649"/>
<source>General</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="650"/>
<source>Changelog</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="651"/>
<source>MCPIEdit</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="730"/>
<source>Select skin file</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="744"/>
<source>Select pack file</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="776"/>
<source>Are you sure you want to reset?</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="758"/>
<source>Are you sure you want to delete the config? This action is unrecoverable.</source>
<translation></translation>
</message>
<message>
<location filename="main.py" line="777"/>
<source>Are you sure you want to delete the AppImage? This action is unrecoverable.</source>
<translation></translation>
</message>
</context>
</TS>

View File

@ -0,0 +1 @@
en

View File

@ -34,12 +34,12 @@ import json
import pathlib
import gettext
LOCALE = os.getenv("LANG", "en")
#LOCALE = os.getenv("LANG", "en")
# Define the path used for later
absolute_path = pathlib.Path(__file__).parent.absolute()
# ran only if it's in a deb file
# run only if it's in a deb file
if str(absolute_path).startswith("/usr/bin"):
absolute_path = "/usr/lib/planet-launcher/"
@ -48,20 +48,6 @@ sys.path.append(absolute_path)
if os.path.exists("/usr/lib/planet-launcher/"):
sys.path.append("/usr/lib/planet-launcher/")
try:
_ = gettext.translation(
"main",
localedir=str(absolute_path) + "/assets/translations/",
languages=[LOCALE],
).gettext
except:
_ = gettext.translation(
"main",
localedir=str(absolute_path) + "/assets/translations/",
languages=["en_US.UTF-8"],
).gettext
# Local imports
import launcher
from splashes import SPLASHES
@ -146,22 +132,22 @@ class ConfigPluto(QDialog):
# Label with information
info_label = QLabel(
_(
self.tr(
'Please select the executable you downloaded.\nIf you installed a DEB, please select the "Link" option'
)
)
self.executable_btn = QPushButton(_("Select executable")) # Button for AppImage
self.executable_btn = QPushButton(self.tr("Select executable")) # Button for AppImage
self.executable_btn.clicked.connect(
self.get_appimage
) # Connect to the function
self.premade_btn = QPushButton(
_("Link /usr/bin/minecraft-pi-reborn-client")
self.tr("Link /usr/bin/minecraft-pi-reborn-client")
) # Button for Pre-installed debs
self.premade_btn.clicked.connect(self.link_appimage) # Connect to the function
# self.flatpak_btn = QPushButton(_("Link flatpak")) # Button for linking flatpak
# self.flatpak_btn = QPushButton(self.tr("Link flatpak")) # Button for linking flatpak
# self.flatpak_btn.clicked.connect(self.link_flatpak) # Connect to the function
# Adding things to widgets
@ -196,7 +182,7 @@ class ConfigPluto(QDialog):
# Open the file dialog
self.filename = QFileDialog.getOpenFileName(
self,
_("Select executable"),
self.tr("Select executable"),
"/",
"Executable files (*.AppImage *.bin *.sh *)",
)
@ -243,8 +229,8 @@ class Planet(QMainWindow):
RPC.connect() # Connect to Discord
# Set the RPC Status
RPC.update(
state=_("Launched with Planet Launcher"),
details=_("Minecraft Pi Edition: Reborn"),
state=self.tr("Launched with Planet Launcher"),
details=self.tr("Minecraft Pi Edition: Reborn"),
large_image=random.choice(
["revival", "logo"]
), # Randomly select the logo
@ -254,7 +240,7 @@ class Planet(QMainWindow):
)
except:
print(
_("Unable to initalize Discord RPC. Skipping.")
self.tr("Unable to initalize Discord RPC. Skipping.")
) # If it fails, e.g Discord is not found, skip. This doesn't matter much.
if not os.path.exists(
@ -285,7 +271,7 @@ class Planet(QMainWindow):
) as file: # Else, it exists: Read from it.
self.conf = json.loads(file.read())
self.setWindowTitle(_("Planet")) # Set the window title
self.setWindowTitle(self.tr("Planet")) # Set the window title
self.setWindowIcon(
QIcon(f"{absolute_path}/assets/img/full/logo512.png")
@ -299,23 +285,23 @@ class Planet(QMainWindow):
tabs.setMovable(True) # Allow tab movement.
# Tab part. Please check every function for more info
play_tab = tabs.addTab(self.play_tab(), _("Play")) # Add the play tab
play_tab = tabs.addTab(self.play_tab(), self.tr("Play")) # Add the play tab
tabs.setTabIcon(
play_tab, QIcon(f"{absolute_path}/assets/img/full/logo512.png")
) # Set the icon for the tab
features_tab = tabs.addTab(
self.features_tab(), _("Features")
self.features_tab(), self.tr("Features")
) # Add the features tab
tabs.setTabIcon(
features_tab, QIcon(f"{absolute_path}/assets/img/full/heart512.png")
) # set the icon for the tab
servers_tab = tabs.addTab(self.servers_tab(), _("Servers")) # Servers tab
servers_tab = tabs.addTab(self.servers_tab(), self.tr("Servers")) # Servers tab
tabs.setTabIcon(
servers_tab, QIcon(f"{absolute_path}/assets/img/full/portal512.png")
) # Set the icon
# mods_tab = tabs.addTab(self.custom_mods_tab(), "Mods")
# tabs.setTabIcon(mods_tab, QIcon(f"{absolute_path}/assets/portal512.png"))
settings_tab = tabs.addTab(self.settings_tab(), _("Settings")) # Changelog tab
settings_tab = tabs.addTab(self.settings_tab(), self.tr("Settings")) # Changelog tab
tabs.setTabIcon(
settings_tab, QIcon(f"{absolute_path}/assets/img/full/wrench512.png")
)
@ -377,13 +363,13 @@ class Planet(QMainWindow):
# Ester eggs
if date.today().month == 4 and date.today().day == 1:
namelabel.setText(
_("Banana Launcher")
self.tr("Banana Launcher")
) # If the date is april fish, show the banana easter egg
else:
if random.randint(1, 100) == 1:
namelabel.setText(_("Pluto Launcher")) # a 1/100, Pluto launcher
namelabel.setText(self.tr("Pluto Launcher")) # a 1/100, Pluto launcher
else:
namelabel.setText(_("Planet Launcher")) # Else, just set it normal
namelabel.setText(self.tr("Planet Launcher")) # Else, just set it normal
font = namelabel.font() # Font used
font.setPointSize(30) # Set the font size
@ -397,14 +383,14 @@ class Planet(QMainWindow):
splashlabel.setAlignment(Qt.AlignHCenter) # Align the label
usernamelabel = QLabel(
_("Username")
self.tr("Username")
) # Label that is used to direct the line edit
self.usernameedit = QLineEdit() # Line Edit for username
self.usernameedit.setPlaceholderText(_("StevePi")) # Set ghost value
self.usernameedit.setPlaceholderText(self.tr("StevePi")) # Set ghost value
distancelabel = QLabel(
_("Render Distance")
self.tr("Render Distance")
) # Label that is used to direct the combo box
self.distancebox = QComboBox()
@ -412,7 +398,7 @@ class Planet(QMainWindow):
self.distancebox.setCurrentText("Short") # Set the default option
profilelabel = QLabel(
_("Profile")
self.tr("Profile")
) # Label that is used to direct the combo box
self.profilebox = QComboBox()
@ -428,7 +414,7 @@ class Planet(QMainWindow):
self.profilebox.setCurrentText("Modded MCPE") # Set the current selection
self.showlauncher = QRadioButton(
_("Hide Launcher")
self.tr("Hide Launcher")
) # RadioButton used for hiding the launcher
self.versionbox = QComboBox()
@ -557,7 +543,7 @@ class Planet(QMainWindow):
) # Set the text of the text editing area
infolabel = QLabel( # Label with information about the server format
_(
self.tr(
'Servers are stored in the format of <font color="gold">IP: </font><font color="blue">Port</font>'
)
)
@ -612,29 +598,29 @@ class Planet(QMainWindow):
layout = QGridLayout()
skin_label = QLabel(_("Set the skin"))
skin_label = QLabel(self.tr("Set the skin"))
self.skin_button = QPushButton(_("Select Skin"))
self.skin_button = QPushButton(self.tr("Select Skin"))
self.skin_button.clicked.connect(self.select_skin)
config_label = QLabel(_("Reset config"))
config_label = QLabel(self.tr("Reset config"))
self.delete_config_button = QPushButton(_("Delete config"))
self.delete_config_button = QPushButton(self.tr("Delete config"))
self.delete_config_button.clicked.connect(self.delete_config)
appimage_label = QLabel(_("Delete executable"))
appimage_label = QLabel(self.tr("Delete executable"))
self.delete_appimage_button = QPushButton(_("Delete"))
self.delete_appimage_button = QPushButton(self.tr("Delete"))
self.delete_appimage_button.clicked.connect(self.delete_appimage)
mcpit_install_label = QLabel(_("Install texture pack"))
mcpit_install_label = QLabel(self.tr("Install texture pack"))
self.import_mcpit_button = QPushButton(_("Select file"))
self.import_mcpit_button = QPushButton(self.tr("Select file"))
self.import_mcpit_button.clicked.connect(self.install_texture_pack)
mcpit_delete_label = QLabel(_("Delete texture pack"))
mcpit_delete_label = QLabel(self.tr("Delete texture pack"))
self.delete_mcpit_button = QPushButton(_("Delete"))
self.delete_mcpit_button = QPushButton(self.tr("Delete"))
self.delete_mcpit_button.clicked.connect(mcpit.erase_pack)
layout.addWidget(skin_label, 0, 0)
@ -660,9 +646,9 @@ class Planet(QMainWindow):
tabs = QTabWidget()
tabs.setTabPosition(QTabWidget.South)
settings_tab = tabs.addTab(self.settings_widget(), _("General"))
changelog_tab = tabs.addTab(self.changelog_widget(), _("Changelog"))
editor_tab = tabs.addTab(mcpiedit.NBTEditor(), _("MCPIEdit"))
settings_tab = tabs.addTab(self.settings_widget(), self.tr("General"))
changelog_tab = tabs.addTab(self.changelog_widget(), self.tr("Changelog"))
editor_tab = tabs.addTab(mcpiedit.NBTEditor(), self.tr("MCPIEdit"))
tabs.setTabIcon(
settings_tab, QIcon(f"{absolute_path}/assets/img/full/wrench512.png")
@ -742,7 +728,7 @@ class Planet(QMainWindow):
def select_skin(self):
filename = QFileDialog.getOpenFileName(
self, _("Select skin file"), "/", "PNG files (*.png)"
self, self.tr("Select skin file"), "/", "PNG files (*.png)"
)
if not filename == "":
with open(
@ -757,7 +743,7 @@ class Planet(QMainWindow):
def install_texture_pack(self):
pack = QFileDialog.getOpenFileName(
self,
_("Select pack file"),
self.tr("Select pack file"),
"/",
"mcpit files (*.mcpit);;PePack files (*.zip *.pepack)",
)
@ -768,9 +754,9 @@ class Planet(QMainWindow):
def delete_config(self):
dialog = QMessageBox()
dialog.setWindowTitle(_("Are you sure you want to reset?"))
dialog.setWindowTitle(self.tr("Are you sure you want to reset?"))
dialog.setText(
_(
self.tr(
"Are you sure you want to delete the config? This action is unrecoverable."
)
)
@ -787,9 +773,9 @@ class Planet(QMainWindow):
def delete_appimage(self):
dialog = QMessageBox()
dialog.setWindowTitle(_("Are you sure you want to reset?"))
dialog.setWindowTitle(self.tr("Are you sure you want to reset?"))
dialog.setText(
_(
self.tr(
"Are you sure you want to delete the AppImage? This action is unrecoverable."
)
)
@ -858,6 +844,20 @@ if __name__ == "__main__":
else:
app.setPalette(qdarktheme.load_palette(theme))
locale = QLocale()
locale_path = os.path.join("assets", "translations", locale.name())
translator = QTranslator()
translator.load("main", locale_path)
print(locale_path)
#if qVersion() > '4.3.3':
app.installTranslator(translator)
if not os.path.exists(f"/home/{USER}/.planet-launcher/minecraft.AppImage"):
pluto = ConfigPluto()
pluto.show()
@ -865,7 +865,7 @@ if __name__ == "__main__":
if pluto.filename[0] == "":
sys.exit(-1)
elif pluto.filename[0] == False:
print(_("Using /usr/bin as an executable."))
print("Using /usr/bin as an executable.")
else:
with open(pluto.filename[0], "rb") as appimage:
with open(

View File

@ -95,7 +95,7 @@ SPLASHES = [
"Most end with!",
"How am I going to feed jelly those days?",
"There is only one can of cat food left, and that's going to the market",
"We ashk for a shmall donatshion of ten thoushand diamondshs!"
"We ashk for a shmall donatshion of ten thoushand diamondshs!",
"YOU SHPEAK WHEN SHPOKEN TO!",
"SSHHUT UP!",
"You were exclusively banned from the deep dark!",