parent
7e1afd69df
commit
23c302ca70
|
@ -144,10 +144,8 @@ class GajimApplication(Gtk.Application):
|
||||||
|
|
||||||
# Set Application Menu
|
# Set Application Menu
|
||||||
app.app = self
|
app.app = self
|
||||||
path = os.path.join(configpaths.get('GUI'), 'application_menu.ui')
|
from gajim import gtkgui_helpers
|
||||||
builder = Gtk.Builder()
|
builder = gtkgui_helpers.get_gtk_builder('application_menu.ui')
|
||||||
builder.set_translation_domain(i18n.DOMAIN)
|
|
||||||
builder.add_from_file(path)
|
|
||||||
menubar = builder.get_object("menubar")
|
menubar = builder.get_object("menubar")
|
||||||
appmenu = builder.get_object("appmenu")
|
appmenu = builder.get_object("appmenu")
|
||||||
if app.prefers_app_menu():
|
if app.prefers_app_menu():
|
||||||
|
|
|
@ -40,7 +40,6 @@ def initialize():
|
||||||
except locale.Error as error:
|
except locale.Error as error:
|
||||||
print(error)
|
print(error)
|
||||||
|
|
||||||
# initialize_win_translation() broken
|
|
||||||
initialize_lang()
|
initialize_lang()
|
||||||
set_i18n_env()
|
set_i18n_env()
|
||||||
|
|
||||||
|
@ -75,8 +74,7 @@ def initialize_lang():
|
||||||
|
|
||||||
def get_locale_dir():
|
def get_locale_dir():
|
||||||
if os.name == 'nt':
|
if os.name == 'nt':
|
||||||
return "../po"
|
return None
|
||||||
|
|
||||||
# try to find domain in localedir
|
# try to find domain in localedir
|
||||||
path = gettext.find(DOMAIN)
|
path = gettext.find(DOMAIN)
|
||||||
if path:
|
if path:
|
||||||
|
@ -96,44 +94,6 @@ def get_locale_dir():
|
||||||
return localedir
|
return localedir
|
||||||
|
|
||||||
|
|
||||||
def initialize_win_translation():
|
|
||||||
# broken for now
|
|
||||||
return
|
|
||||||
|
|
||||||
if os.name != 'nt':
|
|
||||||
return
|
|
||||||
|
|
||||||
# needed for docutils
|
|
||||||
# sys.path.append('.')
|
|
||||||
APP = 'gajim'
|
|
||||||
DIR = '../po'
|
|
||||||
lang = locale.getdefaultlocale()[0]
|
|
||||||
os.environ['LANG'] = lang
|
|
||||||
gettext.bindtextdomain(APP, DIR)
|
|
||||||
gettext.textdomain(APP)
|
|
||||||
gettext.install(APP, DIR)
|
|
||||||
|
|
||||||
# This is for Windows translation which is currently not
|
|
||||||
# working on GTK 3.18.9
|
|
||||||
# locale.setlocale(locale.LC_ALL, '')
|
|
||||||
# import ctypes
|
|
||||||
# import ctypes.util
|
|
||||||
# libintl_path = ctypes.util.find_library('intl')
|
|
||||||
# if libintl_path == None:
|
|
||||||
# local_intl = os.path.join('gtk', 'bin', 'intl.dll')
|
|
||||||
# if os.path.exists(local_intl):
|
|
||||||
# libintl_path = local_intl
|
|
||||||
# if libintl_path == None:
|
|
||||||
# raise ImportError('intl.dll library not found')
|
|
||||||
# libintl = ctypes.cdll.LoadLibrary(libintl_path)
|
|
||||||
# libintl.bindtextdomain(APP, DIR)
|
|
||||||
# libintl.bind_textdomain_codeset(APP, 'UTF-8')
|
|
||||||
# plugins_locale_dir = os.path.join(common.configpaths[
|
|
||||||
# 'PLUGINS_USER'], 'locale').encode(locale.getpreferredencoding())
|
|
||||||
# libintl.bindtextdomain('gajim_plugins', plugins_locale_dir)
|
|
||||||
# libintl.bind_textdomain_codeset('gajim_plugins', 'UTF-8')
|
|
||||||
|
|
||||||
|
|
||||||
def initialize_direction_mark():
|
def initialize_direction_mark():
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,7 @@ import cairo
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
|
import xml.etree.ElementTree as ET
|
||||||
try:
|
try:
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
except:
|
except:
|
||||||
|
@ -125,14 +126,30 @@ def get_image_button(icon_name, tooltip, toggle=False):
|
||||||
|
|
||||||
def get_gtk_builder(file_name, widget=None):
|
def get_gtk_builder(file_name, widget=None):
|
||||||
file_path = os.path.join(configpaths.get('GUI'), file_name)
|
file_path = os.path.join(configpaths.get('GUI'), file_name)
|
||||||
builder = Gtk.Builder()
|
builder = _translate(file_path, widget)
|
||||||
builder.set_translation_domain(i18n.DOMAIN)
|
builder.set_translation_domain(i18n.DOMAIN)
|
||||||
if widget:
|
|
||||||
builder.add_objects_from_file(file_path, [widget])
|
|
||||||
else:
|
|
||||||
builder.add_from_file(file_path)
|
|
||||||
return builder
|
return builder
|
||||||
|
|
||||||
|
def _translate(gui_file, widget):
|
||||||
|
"""
|
||||||
|
This is a workaround for non working translation on Windows
|
||||||
|
"""
|
||||||
|
if sys.platform == "win32":
|
||||||
|
tree = ET.parse(gui_file)
|
||||||
|
for node in tree.iter():
|
||||||
|
if 'translatable' in node.attrib:
|
||||||
|
node.text = _(node.text)
|
||||||
|
xml_text = ET.tostring(tree.getroot(),
|
||||||
|
encoding='unicode',
|
||||||
|
method='xml')
|
||||||
|
return Gtk.Builder.new_from_string(xml_text, -1)
|
||||||
|
else:
|
||||||
|
if widget is not None:
|
||||||
|
builder = Gtk.Builder()
|
||||||
|
builder.add_objects_from_file(gui_file, [widget])
|
||||||
|
return builder
|
||||||
|
return Gtk.Builder.new_from_file(gui_file)
|
||||||
|
|
||||||
def get_completion_liststore(entry):
|
def get_completion_liststore(entry):
|
||||||
"""
|
"""
|
||||||
Create a completion model for entry widget completion list consists of
|
Create a completion model for entry widget completion list consists of
|
||||||
|
|
Loading…
Reference in New Issue