some changes for translation

This commit is contained in:
DYefremov
2019-12-28 09:03:12 -08:00
committed by DYefremov
parent 9d4b507559
commit c2d3cb7673
4 changed files with 23 additions and 12 deletions

View File

@@ -11,7 +11,8 @@ block_cipher = None
ui_files = [('app/ui/*.glade', 'ui'),
('app/ui/*.css', 'ui'),
('app/ui/*.ui', 'ui')
('app/ui/*.ui', 'ui'),
('app/ui/lang*', 'share/locale')
]
a = Analysis([EXE_NAME],

View File

@@ -94,17 +94,21 @@ def get_chooser_dialog(transient, settings, pattern, name):
def get_file_chooser_dialog(transient, text, settings, action_type, file_filter):
dialog = Gtk.FileChooserDialog(get_message(text) if text else "", transient,
action_type if action_type is not None else Gtk.FileChooserAction.SELECT_FOLDER,
(Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK),
use_header_bar=IS_GNOME_SESSION)
dialog = Gtk.FileChooserNative()
dialog.set_title(get_message(text) if text else "")
dialog.set_transient_for(transient)
dialog.set_action(action_type if action_type is not None else Gtk.FileChooserAction.SELECT_FOLDER)
dialog.set_create_folders(False)
dialog.set_modal(True)
if file_filter is not None:
dialog.add_filter(file_filter)
path = settings.data_dir_path
dialog.set_current_folder(path)
response = dialog.run()
if response == Gtk.ResponseType.OK:
if response == Gtk.ResponseType.ACCEPT:
if dialog.get_filename():
path = dialog.get_filename()
if action_type is not Gtk.FileChooserAction.OPEN:

View File

@@ -1,4 +1,7 @@
import gettext
import locale
import os
import sys
import gi
from enum import Enum, IntEnum
@@ -6,19 +9,22 @@ from enum import Enum, IntEnum
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, Gdk
GTK_PATH = os.environ.get("GTK_PATH", None)
# For launching from the bundle.
if os.getcwd() == "/":
try:
os.chdir(os.environ["GTK_PATH"])
except KeyError:
pass
if os.getcwd() == "/" and GTK_PATH:
os.chdir(GTK_PATH)
# path to *.glade files
# path to *.glade files
UI_RESOURCES_PATH = "app/ui/" if os.path.exists("app/ui/") else "ui/"
IS_GNOME_SESSION = int(bool(os.environ.get("GNOME_DESKTOP_SESSION_ID")))
# translation
os.environ["LANG"] = "{}.{}".format(*locale.getlocale())
TEXT_DOMAIN = "demon-editor"
LANG_PATH = GTK_PATH + "/share/locale" if GTK_PATH else UI_RESOURCES_PATH + "lang"
gettext.bindtextdomain(TEXT_DOMAIN, LANG_PATH)
if sys.platform != "darwin":
locale.bindtextdomain(TEXT_DOMAIN, LANG_PATH)
theme = Gtk.IconTheme.get_default()
_IMAGE_MISSING = theme.load_icon("image-missing", 16, 0) if theme.lookup_icon("image-missing", 16, 0) else None

Binary file not shown.