Exemple #1
0
 def set_banner(self):
     if ui_language == "ar":
         self.widget.set_banner_image(get_abs_data_filename(['virtaal', 'welcome_screen_banner_ar.png']))
         return
     if self.widget.get_direction() == gtk.TEXT_DIR_RTL:
         self.widget.set_banner_image(get_abs_data_filename(['virtaal', 'welcome_screen_banner_rtl.png']))
     else:
         self.widget.set_banner_image(get_abs_data_filename(['virtaal', 'welcome_screen_banner.png']))
Exemple #2
0
 def load_glade_file(cls, path_parts, root=None, domain=''):
     gladename = pan_app.get_abs_data_filename(path_parts)
     if os.name == 'nt' and getattr(sys, 'frozen', False):
         try:
             basedirs = [os.getcwd()]
             glade.bindtextdomain(domain, pan_app.get_abs_data_filename('locale', basedirs=basedirs))
         except Exception:
             logging.exception('bindtextdomain()')
     gui = glade.XML(gladename, root=root, domain=domain)
     return gladename, gui
Exemple #3
0
    def _init_plugin(self):
        self.autocorr = AutoCorrector(self.main_controller, acorpath=pan_app.get_abs_data_filename(['virtaal', 'autocorr']))

        def on_cursor_change(cursor):
            def add_widgets():
                self.autocorr.clear_widgets()
                for target in self.main_controller.unit_controller.view.targets:
                    self.autocorr.add_widget(target)
                return False
            gobject.idle_add(add_widgets)

        def on_store_loaded(storecontroller):
            self.autocorr.load_dictionary(lang=self.main_controller.lang_controller.target_lang.code)

            if getattr(self, '_cursor_changed_id', None):
                self.store_cursor.disconnect(self._cursor_changed_id)
            self.store_cursor = storecontroller.cursor
            self._cursor_changed_id = self.store_cursor.connect('cursor-changed', on_cursor_change)
            on_cursor_change(self.store_cursor)

        def on_target_lang_changed(lang_controller, lang):
            self.autocorr.load_dictionary(lang)
            # If the previous language didn't have a correction list, we might
            # have never attached, so let's make sure we attach.
            on_cursor_change(None)


        self._store_loaded_id = self.main_controller.store_controller.connect('store-loaded', on_store_loaded)

        if self.main_controller.store_controller.get_store():
            # Connect to already loaded store. This happens when the plug-in is enabled after loading a store.
            on_store_loaded(self.main_controller.store_controller)

        self._target_lang_changed_id = self.main_controller.lang_controller.connect('target-lang-changed', on_target_lang_changed)
Exemple #4
0
    def update_recent_buttons(self, items):
        # if there are no items (maybe failure in xbel), hide the whole widget
        if not items:
            self.widget.gui.get_object("frame_recent").hide()
        else:
            self.widget.gui.get_object("frame_recent").show_all()

        buttons = [
            self.widget.widgets['buttons']['recent' + str(i)]
            for i in range(1, self.controller.MAX_RECENT + 1)
        ]
        markup = '<span underline="single">%(name)s</span>'

        iconfile = get_abs_data_filename(
            ['icons', 'hicolor', '24x24', 'mimetypes', 'x-translation.png'])
        for i in range(len(items)):
            buttons[i].child.get_children()[0].set_from_file(iconfile)
            name = items[i]['name']
            name = name.replace('&', '&amp;')
            name = name.replace('<', '&lt;')
            buttons[i].child.get_children()[1].set_markup(markup %
                                                          {'name': name})
            buttons[i].set_tooltip_text(items[i]['uri'])
            buttons[i].props.visible = True
        for i in range(len(items), 5):
            buttons[i].props.visible = False
Exemple #5
0
 def load_builder_file(cls, path_parts, root=None, domain=''):
     _id = "/".join(path_parts)
     if _id in _builders:
         return _builders[_id]
     buildername = pan_app.get_abs_data_filename(path_parts)
     builder = Builder()
     builder.add_from_file(buildername)
     builder.set_translation_domain(domain)
     _builders[_id] = builder
     return builder
Exemple #6
0
 def load_builder_file(cls, path_parts, root=None, domain=''):
     _id = "/".join(path_parts)
     if _id in _builders:
         return _builders[_id]
     buildername = pan_app.get_abs_data_filename(path_parts)
     builder = Builder()
     builder.add_from_file(buildername)
     builder.set_translation_domain(domain)
     _builders[_id] = builder
     return builder
Exemple #7
0
    def __init__(self, parent):
        gtk.AboutDialog.__init__(self)
        self._register_uri_handlers()
        self.set_name("Virtaal")
        self.set_version(__version__.ver)
        self.set_copyright(_(u"Copyright © 2007-2010 Zuza Software Foundation"))
        # l10n: Please retain the literal name "Virtaal", but feel free to
        # additionally transliterate the name and to add a translation of "For Language", which is what the name means.
        self.set_comments(_("Virtaal is a program for doing translation.") + "\n\n" +
            _("The initial focus is on software translation (localization or l10n), but we definitely intend it to be useful as a general purpose tool for Computer Aided Translation (CAT)."))
        self.set_license("""This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.""")
        self.set_website("http://translate.sourceforge.net/wiki/virtaal/index")
        self.set_website_label(_("Virtaal website"))
        authors = [
                "Friedel Wolff",
                "Wynand Winterbach",
                "Dwayne Bailey",
                "Walter Leibbrandt",
        ]
        if pan_app.ui_language == "ar":
            authors.append(u"علاء عبد الفتاح")
        else:
            authors.append(u"Alaa Abd El Fattah")
        authors.extend([
                "",  # just for spacing
                _("We thank our donors:"),
                _("The International Development Research Centre"),
                "\thttp://idrc.ca/",
                _("Mozilla Corporation"),
                "\thttp://mozilla.com/",
                ])
        self.set_authors(authors)
        # l10n: Rather than translating, fill in the names of the translators
        self.set_translator_credits(_("translator-credits"))
        self.set_icon(parent.get_icon())
        self.set_logo(gtk.gdk.pixbuf_new_from_file(pan_app.get_abs_data_filename(["virtaal", "virtaal_logo.png"])))
        self.set_artists([
                "Heather Bailey",
                ])
        # FIXME entries that we may want to add
        #self.set_documenters()
        self.connect ("response", lambda d, r: d.destroy())
        self.show()
    def update_recent_buttons(self, items):
        buttons = [self.widget.widgets["buttons"]["recent" + str(i)] for i in range(1, self.controller.MAX_RECENT + 1)]
        markup = '<span underline="single">%(name)s</span>'

        for i in range(len(items)):
            iconfile = get_abs_data_filename(["icons", "hicolor", "24x24", "mimetypes", "x-translation.png"])
            buttons[i].child.get_children()[0].set_from_file(iconfile)
            buttons[i].child.get_children()[1].set_markup(markup % {"name": items[i]["name"]})
            buttons[i].set_tooltip_text(items[i]["uri"])
            buttons[i].props.visible = True
        for i in range(len(items), 5):
            buttons[i].props.visible = False
Exemple #9
0
 def load_builder_file(cls, path_parts, root=None, domain=''):
     buildername = pan_app.get_abs_data_filename(path_parts)
     if os.name == 'nt' and getattr(sys, 'frozen', False):
         try:
             basedirs = [os.getcwd()]
             # FIXME
             #glade.bindtextdomain(domain, pan_app.get_abs_data_filename('locale', basedirs=basedirs))
         except Exception:
             logging.exception('bindtextdomain()')
     builder = Builder()
     builder.add_from_file(buildername)
     builder.set_translation_domain(domain)
     return buildername, builder
    def update_recent_buttons(self, items):
        # if there are no items (maybe failure in xbel), hide the whole widget
        if not items:
            self.widget.gui.get_widget("frame_recent").hide()
        else:
            self.widget.gui.get_widget("frame_recent").show_all()

        buttons = [
            self.widget.widgets['buttons']['recent' + str(i)] for i in range(1, self.controller.MAX_RECENT+1)
        ]
        markup = '<span underline="single">%(name)s</span>'

        iconfile = get_abs_data_filename(['icons', 'hicolor', '24x24', 'mimetypes', 'x-translation.png'])
        for i in range(len(items)):
            buttons[i].child.get_children()[0].set_from_file(iconfile)
            buttons[i].child.get_children()[1].set_markup(markup % {'name': items[i]['name']})
            buttons[i].set_tooltip_text(items[i]['uri'])
            buttons[i].props.visible = True
        for i in range(len(items), 5):
            buttons[i].props.visible = False
Exemple #11
0
 def open_tutorial(self):
     filename = pan_app.get_abs_data_filename(["virtaal", "tutorial.pot"])
     self.open_file(filename, forget_dir=True)
 def set_banner(self):
     if self.widget.get_direction() == gtk.TEXT_DIR_RTL:
         self.widget.set_banner_image(get_abs_data_filename(["virtaal", "welcome_screen_banner_rtl.png"]))
     else:
         self.widget.set_banner_image(get_abs_data_filename(["virtaal", "welcome_screen_banner.png"]))
Exemple #13
0
    def __init__(self, parent):
        gtk.AboutDialog.__init__(self)
        self._register_uri_handlers()
        self.set_name("Virtaal")
        self.set_version(__version__.ver)
        self.set_copyright(
            _(u"Copyright © 2007-2010 Zuza Software Foundation"))
        # l10n: Please retain the literal name "Virtaal", but feel free to
        # additionally transliterate the name and to add a translation of "For Language", which is what the name means.
        self.set_comments(
            _("Virtaal is a program for doing translation.") + "\n\n" +
            _("The initial focus is on software translation (localization or l10n), but we definitely intend it to be useful as a general purpose tool for Computer Aided Translation (CAT)."
              ))
        self.set_license(
            """This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Library General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.""")
        self.set_website("http://translate.sourceforge.net/wiki/virtaal/index")
        self.set_website_label(_("Virtaal website"))
        authors = [
            "Friedel Wolff",
            "Wynand Winterbach",
            "Dwayne Bailey",
            "Walter Leibbrandt",
        ]
        if pan_app.ui_language == "ar":
            authors.append(u"علاء عبد الفتاح")
        else:
            authors.append(u"Alaa Abd El Fattah")
        authors.extend([
            "",  # just for spacing
            _("We thank our donors:"),
            _("The International Development Research Centre"),
            "\thttp://idrc.ca/",
            _("Mozilla Corporation"),
            "\thttp://mozilla.com/",
        ])
        self.set_authors(authors)
        # l10n: Rather than translating, fill in the names of the translators
        self.set_translator_credits(_("translator-credits"))
        self.set_icon(parent.get_icon())
        self.set_logo(
            gtk.gdk.pixbuf_new_from_file(
                pan_app.get_abs_data_filename(["virtaal",
                                               "virtaal_logo.png"])))
        self.set_artists([
            "Heather Bailey",
        ])
        # FIXME entries that we may want to add
        #self.set_documenters()
        self.connect("response", lambda d, r: d.destroy())
        self.show()
Exemple #14
0
 def open_tutorial(self):
     filename = pan_app.get_abs_data_filename(["virtaal", "tutorial.pot"])
     self.open_file(filename, forget_dir=True)