Exemple #1
0
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# 
# 
# This program checks which language is being used in RUR-PLE and
# launches the lessons in the default web browser in that 
# language. If no language is found, it defaults to English.
# 
# TODO: take a command line parameter to overwrite the default settings


import os
import webbrowser
import conf

url = os.getcwd() + "/lessons/" + conf.getLanguage() + "/lessons_toc.htm"

# Open URL in a new tab, if a browser window is already open. 
webbrowser.open_new_tab(url)
Exemple #2
0
"""
# 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, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
# This program checks which language is being used in RUR-PLE and
# launches the lessons in the default web browser in that
# language. If no language is found, it defaults to English.
#
# TODO: take a command line parameter to overwrite the default settings

import os
import webbrowser
import conf

url = os.getcwd() + "/lessons/" + conf.getLanguage() + "/lessons_toc.htm"

# Open URL in a new tab, if a browser window is already open.
webbrowser.open_new_tab(url)
Exemple #3
0
    def __init__(self, parent, grand_parent):

        wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
        self.lessons_dir = conf.getLessonsNlDir()

        self.parent = parent
        self.grand_parent = grand_parent

        self.html = html.HtmlWindow(self,
                                    -1,
                                    style=wx.NO_FULL_REPAINT_ON_RESIZE)

        btn_size = (32, 32)
        spacer_large = (125, 36)
        spacer_small = (4, 4)
        tip_list = [
            _("Open local html file"),
            _("Go back in browser history"),
            _("Home"),
            _("Go forward in browser history"),
            _("Select a language")
        ]
        button_list = [[None, False, None, None, spacer_small, None],
                       [
                           wx.NewId(), True, self.OnLoadFile,
                           getImage(images.OPEN_HTML), btn_size, tip_list[0]
                       ], [None, False, None, None, spacer_large, None],
                       [
                           wx.NewId(), True, self.OnBack,
                           getImage(images.BACK), btn_size, tip_list[1]
                       ], [None, False, None, None, spacer_small, None],
                       [
                           wx.NewId(), True, self.OnHome,
                           getImage(images.HOME), btn_size, tip_list[2]
                       ], [None, False, None, None, spacer_small, None],
                       [
                           wx.NewId(), True, self.OnForward,
                           getImage(images.FORWARD), btn_size, tip_list[3]
                       ], [None, False, None, None, spacer_large, None],
                       [
                           wx.NewId(), True, None,
                           getImage(images.LANGUAGES), (58, 34), tip_list[4]
                       ], [None, False, None, None, spacer_small, None]]

        self.box = wx.BoxSizer(wx.VERTICAL)
        subbox = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_list = []
        for id, button, action, img, size, tip in button_list:
            if button:
                name = wx.lib.buttons.GenBitmapButton(self, id, img, size=size)
                name.SetToolTipString(tip)
                wx.EVT_BUTTON(self, id, action)
                subbox.Add(name, 0, wx.SHAPED)
                self.btn_list.append(name)  # create a list for later reference
            else:
                subbox.Add(size, 0, wx.EXPAND)

        languageList = []
        for language in conf.getAvailableLanguages():
            languageList.append(translation.languages[language][2])
        languageList.sort()
        self.ch = wx.Choice(self, -1, choices=languageList)

        # set index of current language
        try:
            langnum = languageList.index(
                translation.languages[conf.getLanguage()][2])
        except ValueError:
            langnum = languageList.index(translation.languages['en'][2])

        self.ch.SetSelection(langnum)

        self.Bind(wx.EVT_CHOICE, self.ChooseLanguage, self.ch)
        subbox.Add(self.ch, 0, wx.SHAPED)

        self.box.Add(subbox, 0, wx.GROW)
        self.box.Add(self.html, 1, wx.GROW)
        self.SetSizer(self.box)
        self.SetAutoLayout(True)

        name = os.path.join(self.lessons_dir, 'rur.htm')
        self.html.LoadPage(name)
Exemple #4
0
rur_locale = conf.getSettings().LOCALE_DIR

for lang in conf.getAvailableLanguages():
    filename = os.path.join(rur_locale, lang, languages[lang][0]+'.po')
    languages[lang][1] = build_dict(filename)

def _select_code(langCode):
    global _selected
    for lang in  conf.getAvailableLanguages():
        if lang == langCode:
            _selected = languages[lang][1]
            conf.setLanguage(langCode)

def select(language):
    for lang in  conf.getAvailableLanguages():
        if language == languages[lang][2]:
            _select_code(lang)

def _(message):
    global _selected
    if _selected is None:
        _selected = 'en'
    key = message.replace("\n","")  # message is a key in a dict
    if key in _selected:
        return _selected[key]
    else:
        return message

# import the default language at the start
_select_code(conf.getLanguage())
Exemple #5
0
    languages[lang][1] = build_dict(filename)


def _select_code(langCode):
    global _selected
    for lang in conf.getAvailableLanguages():
        if lang == langCode:
            _selected = languages[lang][1]
            conf.setLanguage(langCode)


def select(language):
    for lang in conf.getAvailableLanguages():
        if language == languages[lang][2]:
            _select_code(lang)


def _(message):
    global _selected
    if _selected is None:
        _selected = 'en'
    key = message.replace("\n", "")  # message is a key in a dict
    if key in _selected:
        return _selected[key]
    else:
        return message


# import the default language at the start
_select_code(conf.getLanguage())
Exemple #6
0
    def __init__(self, parent, grand_parent):

        wx.Panel.__init__(self, parent, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE)
        self.lessons_dir = conf.getLessonsNlDir()
        
        self.parent = parent
        self.grand_parent = grand_parent

        self.html = html.HtmlWindow(self, -1, style=wx.NO_FULL_REPAINT_ON_RESIZE)

        btn_size = (32, 32)
        spacer_large = (125, 36)
        spacer_small = (4, 4)
        tip_list = [_("Open local html file"), _("Go back in browser history"),
                     _("Home"), _("Go forward in browser history"),
                     _("Select a language")]
        button_list = [
            [None,      False, None, None, spacer_small, None],
            [wx.NewId(), True, self.OnLoadFile, getImage(images.OPEN_HTML),
                btn_size, tip_list[0]],
            [None,      False, None, None, spacer_large, None],
            [wx.NewId(), True, self.OnBack, getImage(images.BACK),
                btn_size, tip_list[1]],
            [None,      False, None, None, spacer_small, None],
            [wx.NewId(), True, self.OnHome, getImage(images.HOME),
                btn_size, tip_list[2]],
            [None,      False, None, None, spacer_small, None],
            [wx.NewId(), True, self.OnForward, getImage(images.FORWARD),
                btn_size, tip_list[3]],
            [None,      False, None, None, spacer_large, None],
            [wx.NewId(), True, None, getImage(images.LANGUAGES),
                (58,34), tip_list[4]],
            [None,      False, None, None, spacer_small, None]
            ]

        self.box = wx.BoxSizer(wx.VERTICAL)
        subbox = wx.BoxSizer(wx.HORIZONTAL)

        self.btn_list = []
        for id, button, action, img, size, tip in button_list:
            if button:
                name = wx.lib.buttons.GenBitmapButton(self, id, img, size=size)
                name.SetToolTipString(tip)
                wx.EVT_BUTTON(self, id, action)
                subbox.Add(name, 0, wx.SHAPED)
                self.btn_list.append(name)  # create a list for later reference
            else:
                subbox.Add(size, 0, wx.EXPAND)

        languageList = []
        for language in conf.getAvailableLanguages():
            languageList.append(translation.languages[language][2])
        languageList.sort()
        self.ch = wx.Choice(self, -1, choices = languageList)

        # set index of current language
        try:
            langnum = languageList.index(translation.languages[
                conf.getLanguage()][2])
        except ValueError:
            langnum = languageList.index(translation.languages['en'][2])

        self.ch.SetSelection(langnum)

        self.Bind(wx.EVT_CHOICE, self.ChooseLanguage, self.ch)
        subbox.Add(self.ch, 0, wx.SHAPED)

        self.box.Add(subbox, 0, wx.GROW)
        self.box.Add(self.html, 1, wx.GROW)
        self.SetSizer(self.box)
        self.SetAutoLayout(True)

        name = os.path.join(self.lessons_dir, 'rur.htm')
        self.html.LoadPage(name)