Verified Kaydet (Commit) d576f902 authored tarafından Erdem Ersoy's avatar Erdem Ersoy

Some changes:

- Update application name
- Add About dialog
- Implement localization
- Add English and Turkish translations
üst 7c8fd453
......@@ -9,42 +9,55 @@ gi.require_version("GLib", "2.0")
gi.require_version("Gio", "2.0")
from gi.repository import Gtk, GLib, Gio
LOCALE_PATH = "/usr/share/locale"
APP_NAME = "python-gtk-example"
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
LOCALE_PATH = CURRENT_DIR + "/../translations/" + APP_NAME
locale.setlocale(locale.LC_ALL, "")
gettext.bindtextdomain("example", "LOCALE_PATH")
gettext.textdomain("example")
gettext.bindtextdomain(APP_NAME, localedir=LOCALE_PATH)
gettext.textdomain(APP_NAME)
_ = gettext.gettext
gettext.install("example", "LOCALE_PATH")
gettext.install(APP_NAME, localedir=LOCALE_PATH)
class MainWindow:
def __init__(self, application):
self.builder = Gtk.Builder()
self.builder.add_from_file(os.path.dirname(os.path.abspath(__file__)) + "/../ui/MainWindow.glade")
self.builder.connect_signals(self)
self.Builder = Gtk.Builder()
self.Builder.add_from_file(CURRENT_DIR + "/../ui/MainWindow.glade")
self.Builder.connect_signals(self)
self.HeaderBarMain = self.builder.get_object("HeaderMain")
self.HeaderBarMain = self.Builder.get_object("HeaderMain")
self.HeaderBarMain.set_title(_("Hello World"))
self.HeaderBarMain.set_subtitle(_("My Example Python Application"))
self.HeaderBarMain.set_subtitle(_("My Python GTK+ Example Application"))
self.HelloWorldMain = self.builder.get_object("HelloWorldMain")
self.HelloWorldMain = self.Builder.get_object("HelloWorldMain")
self.HelloWorldMain.set_text(_("Hello World!"))
self.ExitButtonMain = self.builder.get_object("ExitButtonMain")
self.ExitButtonMain = self.Builder.get_object("ExitButtonMain")
self.ExitButtonMain.set_label(_("Exit"))
self.ModelButtonAbout = self.builder.get_object("ModelButtonAbout")
self.ModelButtonAbout = self.Builder.get_object("ModelButtonAbout")
self.ModelButtonAbout.set_label(_("About"))
self.ModelButtonExit = self.builder.get_object("ModelButtonExit")
self.ModelButtonExit = self.Builder.get_object("ModelButtonExit")
self.ModelButtonExit.set_label(_("Exit"))
self.WindowMain = self.builder.get_object("WindowMain")
self.WindowMain = self.Builder.get_object("WindowMain")
self.WindowMain.set_application(application)
self.WindowMain.show_all()
def onAbout(self, button):
pass
self.BuilderAbout = Gtk.Builder()
self.BuilderAbout.add_from_file(CURRENT_DIR + "/../ui/AboutWindow.glade")
self.BuilderAbout.connect_signals(self)
self.DialogAbout = self.BuilderAbout.get_object("DialogAbout")
self.DialogAbout.set_comments(_("My Python GTK+ Example Application"))
self.DialogAbout.set_copyright(_("Copyright (C) 2021 Erdem Ersoy"))
self.DialogAbout.set_program_name(_("Python GTK+ Example"))
self.DialogAbout.set_website_label(_("Python GTK+ Example Website"))
self.DialogAbout.run()
self.DialogAbout.hide()
def onExit(self, button):
sys.exit(0)
......@@ -14,7 +14,7 @@ from MainWindow import MainWindow
class ExampleApplication(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(*args,
application_id="net.erdemersoy.example",
application_id="net.erdemersoy.python-gtk-example",
flags=Gio.ApplicationFlags.FLAGS_NONE,
**kwargs)
......
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python-gtk-example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: python-gtk-example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 10:23+0300\n"
"PO-Revision-Date: 2021-05-20 10:02+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:30
msgid "Hello World"
msgstr "Hello World"
#: src/MainWindow.py:31 src/MainWindow.py:55
msgid "My Python GTK+ Example Application"
msgstr "My Python GTK+ Example Application"
#: src/MainWindow.py:34
msgid "Hello World!"
msgstr "Hello World!"
#: src/MainWindow.py:37 src/MainWindow.py:43
msgid "Exit"
msgstr "Exit"
#: src/MainWindow.py:40
msgid "About"
msgstr "About"
#: src/MainWindow.py:56
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Copyright (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:57
msgid "Python GTK+ Example"
msgstr "Python GTK+ Example"
#: src/MainWindow.py:58
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Example Website"
#~ msgid "My Example Python GTK+ Application"
#~ msgstr "My Example Python GTK+ Application"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python-gtk-example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: python-gtk-example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 10:04+0300\n"
"PO-Revision-Date: 2021-05-20 10:02+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:31
msgid "Hello World"
msgstr "Hello World"
#: src/MainWindow.py:32 src/MainWindow.py:56
msgid "My Python GTK+ Example Application"
msgstr "My Python GTK+ Example Application"
#: src/MainWindow.py:35
msgid "Hello World!"
msgstr "Hello World!"
#: src/MainWindow.py:38 src/MainWindow.py:44
msgid "Exit"
msgstr "Exit"
#: src/MainWindow.py:41
msgid "About"
msgstr "About"
#: src/MainWindow.py:57
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Copyright (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:58
msgid "Python GTK+ Example"
msgstr "Python GTK+ Example"
#: src/MainWindow.py:59
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Example Website"
#~ msgid "My Example Python GTK+ Application"
#~ msgstr "My Example Python GTK+ Application"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 09:46+0300\n"
"PO-Revision-Date: 2021-05-20 09:31+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: en\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:29
msgid "Hello World"
msgstr "Hello World"
#: src/MainWindow.py:30
msgid "My Example Python Application"
msgstr "My Example Python Application"
#: src/MainWindow.py:33
msgid "Hello World!"
msgstr "Hello World!"
#: src/MainWindow.py:36 src/MainWindow.py:42
msgid "Exit"
msgstr "Exit"
#: src/MainWindow.py:39
msgid "About"
msgstr "About"
#: src/MainWindow.py:54
msgid "My Python GTK+ Example Application"
msgstr "My Python GTK+ Example Application"
#: src/MainWindow.py:55
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Copyright (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:56
msgid "Python GTK+ Example"
msgstr "Python GTK+ Example"
#: src/MainWindow.py:57
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Example Website"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 09:46+0300\n"
"PO-Revision-Date: 2021-05-20 09:45+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:29
msgid "Hello World"
msgstr "Merhaba Dünya"
#: src/MainWindow.py:30
msgid "My Example Python Application"
msgstr "Örnek Python Uygulamam"
#: src/MainWindow.py:33
msgid "Hello World!"
msgstr "Merhaba Dünya!"
#: src/MainWindow.py:36 src/MainWindow.py:42
msgid "Exit"
msgstr "Çıkış"
#: src/MainWindow.py:39
msgid "About"
msgstr "Hakkında"
#: src/MainWindow.py:54
msgid "My Python GTK+ Example Application"
msgstr "Örnek Python GTK+ Uygulamam"
#: src/MainWindow.py:55
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Telif Hakkı (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:56
msgid "Python GTK+ Example"
msgstr "Python GTK+ Örneği"
#: src/MainWindow.py:57
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Örneği Ağ Sitesi"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python-gtk-example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: python-gtk-example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 10:23+0300\n"
"PO-Revision-Date: 2021-05-20 10:02+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:30
msgid "Hello World"
msgstr "Merhaba Dünya"
#: src/MainWindow.py:31 src/MainWindow.py:55
msgid "My Python GTK+ Example Application"
msgstr "Benim Örnek Python GTK+ Uygulamam"
#: src/MainWindow.py:34
msgid "Hello World!"
msgstr "Merhaba Dünya!"
#: src/MainWindow.py:37 src/MainWindow.py:43
msgid "Exit"
msgstr "Çıkış"
#: src/MainWindow.py:40
msgid "About"
msgstr "Hakkında"
#: src/MainWindow.py:56
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Telif Hakkı (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:57
msgid "Python GTK+ Example"
msgstr "Python GTK+ Örneği"
#: src/MainWindow.py:58
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Örneği Ağ Sitesi"
#, fuzzy
#~ msgid "My Example Python GTK+ Application"
#~ msgstr "Benim Örnek Python Uygulamam"
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the python-gtk-example package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: python-gtk-example 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-05-20 10:04+0300\n"
"PO-Revision-Date: 2021-05-20 10:02+0300\n"
"Last-Translator: Erdem Ersoy <erdemersoy@erdemersoy.net>\n"
"Language-Team: \n"
"Language: tr\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.4.2\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: src/MainWindow.py:31
msgid "Hello World"
msgstr "Merhaba Dünya"
#: src/MainWindow.py:32 src/MainWindow.py:56
msgid "My Python GTK+ Example Application"
msgstr "Benim Örnek Python GTK+ Uygulamam"
#: src/MainWindow.py:35
msgid "Hello World!"
msgstr "Merhaba Dünya!"
#: src/MainWindow.py:38 src/MainWindow.py:44
msgid "Exit"
msgstr "Çıkış"
#: src/MainWindow.py:41
msgid "About"
msgstr "Hakkında"
#: src/MainWindow.py:57
msgid "Copyright (C) 2021 Erdem Ersoy"
msgstr "Telif Hakkı (C) 2021 Erdem Ersoy"
#: src/MainWindow.py:58
msgid "Python GTK+ Example"
msgstr "Python GTK+ Örneği"
#: src/MainWindow.py:59
msgid "Python GTK+ Example Website"
msgstr "Python GTK+ Örneği Ağ Sitesi"
#, fuzzy
#~ msgid "My Example Python GTK+ Application"
#~ msgstr "Benim Örnek Python Uygulamam"
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2
The MIT License (MIT)
Copyright (c) Copyright (C) 2021 Erdem Ersoy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Author: Erdem Ersoy
-->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- interface-license-type mit -->
<!-- interface-name Pyton GTK+ Example -->
<!-- interface-description My Python GTK+ Example Application -->
<!-- interface-copyright Copyright (C) 2021 Erdem Ersoy -->
<!-- interface-authors Erdem Ersoy -->
<object class="GtkAboutDialog" id="DialogAbout">
<property name="can-focus">False</property>
<property name="type-hint">dialog</property>
<property name="program-name">Python GTK+ Example</property>
<property name="version">0.1</property>
<property name="copyright" translatable="yes">Copyright (C) 2021 Erdem Ersoy</property>
<property name="comments" translatable="yes">My Python GTK+ Example Application</property>
<property name="website">https://kod.pardus.org.tr/eersoy93/python-gtk-example</property>
<property name="website-label" translatable="yes">Python GTK+ Example Website</property>
<property name="authors">Erdem Ersoy</property>
<property name="documenters">Erdem Ersoy</property>
<property name="translator-credits" translatable="yes">Erdem Ersoy</property>
<property name="logo-icon-name">application-x-executable</property>
<property name="license-type">mit-x11</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<!-- Generated with glade 3.38.2
The MIT License (MIT)
Copyright (c) Copyright (C) 2021 Erdem Ersoy
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Author: Erdem Ersoy
-->
<interface>
<requires lib="gtk+" version="3.24"/>
<!-- interface-license-type mit -->
<!-- interface-name Python GTK+ Example -->
<!-- interface-description My Python GTK+ Example Application -->
<!-- interface-copyright Copyright (C) 2021 Erdem Ersoy -->
<!-- interface-authors Erdem Ersoy -->
<object class="GtkImage" id="ImageExit">
<property name="visible">True</property>
<property name="can-focus">False</property>
......
#!/bin/sh
APP_NAME=python-gtk-example
APP_VERSION=0.1
xgettext --default-domain=${APP_NAME} \
--lang=Python \
--from-code=utf-8 \
--output=translations/${APP_NAME}.pot \
--package-name=${APP_NAME} \
--package-version=${APP_VERSION} \
src/MainWindow.py
msgmerge --lang=en \
--update \
translations/en.po \
translations/${APP_NAME}.pot
msgmerge --lang=tr \
--update \
translations/tr.po \
translations/${APP_NAME}.pot
msgfmt --check --directory=translations/\
--output-file=translations/${APP_NAME}/en/LC_MESSAGES/${APP_NAME}.mo \
en.po \
msgfmt --check --directory=translations/ \
--output-file=translations/${APP_NAME}/tr/LC_MESSAGES/${APP_NAME}.mo \
tr.po \
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment