Changeset 11

Show
Ignore:
Timestamp:
09/22/07 12:34:48 (1 year ago)
Author:
baptiste
Message:

* A lot of code was written twice or even more, so here is a cleanup.
* Removed the file fontypython.py which was unused... I got fooled, and started to translate it before I understood :-(
* Version passed to 0.2.0B (B for beta and also Baptiste ;-)
* FP can be fully translated, using gettext. I'll add a file that describes how to do it, and later I'll upload the French translation.

Note: Do not use this branche, unless you want to test. It may becomes unstable. That is all for today !

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/baptiste/fontypython/cli.py

    r6 r11  
    1919 
    2020import sys 
     21import os 
    2122import strings 
    2223import pathcontrol 
     
    2526import fontybugs 
    2627 
     28## i18n imports 
     29import gettext 
     30from gettext import gettext as _ 
     31## i18n configuration 
     32gettext.bindtextdomain("cli", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     33gettext.textdomain("cli") 
     34 
    2735from pog import * 
    2836 
     
    3745parser = OptionParser() 
    3846use = strings.use() 
    39 parser = OptionParser(usage=use, version="Fonty Python %s Copyright (C) 2006 Donn.C.Ingle" % fpversion.version
    40 parser.add_option("-e", "--examples", action="store_const", dest="examples", const=True, help="show some %$@#$ examples!"
    41 parser.add_option("-i", "--install", dest="install", metavar="pog", help="install the fonts in this pog to your fonts folder"
    42 parser.add_option("-u", "--uninstall", dest="uninstall", metavar="pog", help="uninstall the fonts in this pog"
    43 parser.add_option("-l", "--list", action="store_const", const=True, help="list the names of all the pogs"
    44 parser.add_option("-s", "--size", action="store", metavar="num", dest="points", help="set a new default point size. 64 is best"
    45 parser.add_option("-v", "--view", action="store", metavar="num", dest="numinpage", help="set a new default for how many fonts to view at one go. 10 is good"
    46 parser.add_option("-t", "--text", action="store", metavar="\"text\"", dest="text", type="string", help="set a new default sample text. \"This is an ex-parrot!\" is good. Be sure to use the quotes"
    47 parser.add_option("-p", "--purge", action="store", metavar="pog", dest="purge", help="purge the pog of ttf files that are no longer really there"
     47parser = OptionParser(usage=use, version="Fonty Python %s Copyright (C) 2006 Donn.C.Ingle" % fpversion.__version__
     48parser.add_option("-e", "--examples", action="store_const", dest="examples", const=True, help=_("show some %$@#$ examples!")
     49parser.add_option("-i", "--install", dest="install", metavar="pog", help=_("install the fonts in this pog to your fonts folder")
     50parser.add_option("-u", "--uninstall", dest="uninstall", metavar="pog", help=_("uninstall the fonts in this pog")
     51parser.add_option("-l", "--list", action="store_const", const=True, help=_("list the names of all the pogs")
     52parser.add_option("-s", "--size", action="store", metavar="num", dest="points", help=_("set a new default point size. 64 is best")
     53parser.add_option("-v", "--view", action="store", metavar="num", dest="numinpage", help=_("set a new default for how many fonts to view at one go. 10 is good")
     54parser.add_option("-t", "--text", action="store", metavar="\"text\"", dest="text", type="string", help=_("set a new default sample text. \"This is an ex-parrot!\" is good. Be sure to use the quotes")
     55parser.add_option("-p", "--purge", action="store", metavar="pog", dest="purge", help=_("purge the pog of ttf files that are no longer really there")
    4856#parser.add_option("-g", "--gui", action="store", metavar="(wxgui OR qtgui)", dest="gui", help="choose a graphical interface, one of wxgui or qtgui. Only one that is available and working on your system will be used. The default is wxgui") 
    49 parser.add_option("--min", action="store_const", const=True, help="only show the minimal interface. This will be set as the default for next time."
    50 parser.add_option("--max", action="store_const", const=True, help="show the entire interface. This will be set as the default for next time."
     57parser.add_option("--min", action="store_const", const=True, help=_("only show the minimal interface. This will be set as the default for next time.")
     58parser.add_option("--max", action="store_const", const=True, help=_("show the entire interface. This will be set as the default for next time.")
    5159 
    5260(options, args) = parser.parse_args() 
     
    6169    poglist = iPC.getPogNames() 
    6270    if len(poglist) == 0: 
    63         print "There are no pogs available." 
     71        print _("There are no pogs available.") 
    6472        sys.exit() 
    65     print "Listing %d pog(s) " % len(poglist) 
    66     print " (*) indicates installed pogs" 
     73    print _("Listing %d pog(s) ") % len(poglist) 
     74    print _(" (*) indicates installed pogs") 
    6775    for pog in poglist: 
    6876        paf = iPC.appPath() + pog + ".pog" 
     
    7280            f.close() 
    7381        except: 
    74             print "Could not open %s." % paf 
     82            print _("Could not open %s.") % paf 
    7583        s = "" 
    7684        if installed.upper() == "INSTALLED": 
     
    106114    fpsys.config.text = options.text 
    107115    fpsys.config.Save()         
    108     print "Your text has been set to \"%s\"" % options.text 
    109     print "Tip: Did you use quotes to surround your text?" 
    110     print "Start FontyPython again to see the result." 
     116    print _("Your text has been set to \"%s\"") % options.text 
     117    print _("Tip: Did you use quotes to surround your text?") 
     118    print _("Start FontyPython again to see the result.") 
    111119    sys.exit() 
    112120     
     
    133141            print str(e) 
    134142    else: 
    135         sys.exit("%s cannot be found. Try -l to see the names." % pogtopurge) 
     143        sys.exit(_("%s cannot be found. Try -l to see the names.") % pogtopurge) 
    136144    fpsys.config.Save() 
    137145    sys.exit(strings.done) 
     
    157165            ##          PogAllFontsFailedToInstall 
    158166            ##          PogSomeFontsDidNotInstall             
    159             print "Installing %s" % pogtoinstall 
     167            print _("Installing %s") % pogtoinstall 
    160168            pog.install() # will use progressCallBack to print each font name. 
    161169        except (fontybugs.PogEmpty,  
     
    165173            print str(e) 
    166174    else: # not a pogname 
    167         sys.exit("%s cannot be found. Try -l to see the names." % pogtoinstall) 
     175        sys.exit(_("%s cannot be found. Try -l to see the names.") % pogtoinstall) 
    168176    fpsys.config.Save() 
    169177    sys.exit(strings.done) 
     
    184192            ##          PogLinksRemain 
    185193            ##          PogNotInstalled             
    186             print "Removing %s" % pogtouninstall 
     194            print _("Removing %s") % pogtouninstall 
    187195            pog.uninstall() 
    188196        except (fontybugs.PogEmpty, 
     
    191199            print str(e) 
    192200    else: 
    193         sys.exit("Sorry, can't find %s. Try -l to see the names." % pogtouninstall) 
     201        sys.exit(_("Sorry, can't find %s. Try -l to see the names.") % pogtouninstall) 
    194202    fpsys.config.Save() 
    195203    sys.exit(strings.done) 
     
    199207if len(args) > 2: 
    200208    ## The user may have chosen a pogname with spaces and no quotes 
    201     print """Please check your arguments, there seem to be too many. 
     209    print _("""Please check your arguments, there seem to be too many. 
    202210(Remember: it's one pound for a five-minute argument, but only  
    203211eight pounds for a course of ten.) 
    204212     
    205213NB: If you wanted to use spaces in a pogname or folder then 
    206 please put quotes around them.""" 
     214please put quotes around them.""") 
    207215    sys.exit()  
    208216     
     
    228236if not fpsys.isFolder(A) and not fpsys.isPog(A) and not fakearg: 
    229237    ## It's a non starter: 
    230     sys.exit("%s does not exist. Try --list" % A) 
     238    sys.exit(_("%s does not exist. Try --list") % A) 
    231239 
    232240## Disallow Folder in arg B 
    233241if B and fpsys.isFolder(B): 
    234     sys.exit("You cannot use a folder as the target argument. Try --help"
     242    sys.exit(_("You cannot use a folder as the target argument. Try --help")
    235243     
    236244## Let's ensure that B exists, else we must make it. 
     
    274282        except fontybugs.PogInvalid, e: 
    275283             sys.exit(str(e)) 
    276         if installed: sys.exit("The target pog (%s) is currently installed,\nyou can't use it as a target." % B
     284        if installed: sys.exit(_("The target pog (%s) is currently installed,\nyou can't use it as a target." % B)
    277285         
    278286    if fpsys.isPog(A)and fpsys.isPog(B): 
    279287        ## "PP" 
    280288        if A == B: 
    281             sys.exit("Your pogs are the same! Try -e"
     289            sys.exit(_("Your pogs are the same! Try -e")
    282290        try: 
    283291            empty = fpsys.validateViewPog(A) 
    284292        except fontybugs.PogInvalid, e: 
    285293            sys.exit(str(e)) 
    286         if empty: sys.exit("This pog is empty"
     294        if empty: sys.exit(_("This pog is empty")
    287295  
    288296        try: 
     
    291299            sys.exit(str(e)) 
    292300        if installed: 
    293             sys.exit("The target pog (%s) is currently installed,\nyou can't use it as a target." % B) 
     301            sys.exit(_("The target pog (%s) is currently installed,\nyou can't use it as a target.") % B) 
    294302 
    295303## sys.exit("Your arguments amuse me :) Please try -h") 
  • branches/baptiste/fontypython/config.py

    r6 r11  
    1818## 
    1919 
    20 import sys, os, pickle 
     20import sys 
     21import os 
     22import pickle 
    2123import strings 
    2224import pathcontrol 
    2325 
     26## i18n imports 
     27import gettext 
     28from gettext import gettext as _ 
     29## i18n configuration 
     30gettext.bindtextdomain("config", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     31gettext.textdomain("config") 
    2432 
    2533#### 
     
    3341        self.pos = (10, 10) 
    3442        self.numinpage = 10 
    35         self.text = "Jump the lazy dog fox" 
     43        self.text = _("Jump the lazy dog fox") 
    3644        self.points = 64       
    3745        self.lastview = "" # a pog name or a folder path. 
    3846        self.usegui = None 
     47        self.max = True 
     48        self.lastdir = None 
    3949        ## Private vars 
    4050        self.__dontSaveNumInPage = False 
     
    4757                pf.close() 
    4858            except: 
    49                 sys.exit("%s file appears to be damaged.\nPlease delete it and start again" % self.ipc.appConf()) 
     59                sys.exit(_("%s file appears to be damaged.\nPlease delete it and start again") % self.ipc.appConf()) 
    5060        else: 
    51             print "No config file found, creating it with defaults." 
     61            print _("No config file found, creating it with defaults.") 
    5262            self.__write() 
    5363        ## Now get them into the instance vars: 
    5464        try: 
    5565            self.size = self.__data['size'] 
     66            self.usegui = self.__data['usegui'] 
    5667            self.pos= self.__data['pos'] 
    5768            self.numinpage = self.__data['numinpage'] 
    5869            self.text = self.__data['text'] 
    5970            self.points= self.__data['points'] 
    60             self.lastview = self.__data['lastview']                
     71            self.lastview = self.__data['lastview']  
     72            self.max = self.__data['max'] 
     73            self.lastdir = self.__data['lastdir']              
    6174        except KeyError: 
    6275            ## The conf file has keys that don't work for this version, chances are it's old. 
     
    6578                os.unlink(self.ipc.appConf()) 
    6679            except: 
    67                 sys.exit("The fontypython config file is damaged.\nPlease remove it and start again"
     80                sys.exit(_("The fontypython config file is damaged.\nPlease remove it and start again")
    6881            self.__write() 
    6982    def dontSaveNumInPage(self, flag): 
     
    7588                                "text":self.text, 
    7689                                "points":self.points, 
    77                                 "lastview" : self.lastview 
     90                                "lastview": self.lastview, 
     91                                "usegui": self.usegui, 
     92                                "max": self.max, 
     93                                "lastdir": self.lastdir 
    7894                                } 
    7995    def __write(self): 
     
    87103            pf.close() 
    88104        except IOError: 
    89             print "Could not write to the config file." 
     105            print _("Could not write to the config file.") 
    90106    def save(self): 
    91107        self.__write()  #Go write the file 
    92  
    93108 
    94109## Our config instance - it will have one instance across 
  • branches/baptiste/fontypython/dialogues.py

    r6 r11  
    1818## 
    1919 
     20import sys 
     21import os 
    2022import fpsys 
    2123import strings 
     
    2325 
    2426import wx.html as html 
     27 
     28## i18n imports 
     29import gettext 
     30from gettext import gettext as _ 
     31## i18n configuration 
     32gettext.bindtextdomain("dialogues", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     33gettext.textdomain("dialogues") 
    2534 
    2635class DialogHelp(wx.Dialog): 
     
    8392 
    8493    def __set_properties(self): 
    85         self.SetTitle("About FontyPython"
     94        self.SetTitle(_("About FontyPython")
    8695        _icon = wx.EmptyIcon() 
    8796        _icon.CopyFromBitmap(wx.Bitmap(fpsys.mythingsdir + 'fplogo.png', wx.BITMAP_TYPE_ANY)) 
     
    116125        sizer_3.Fit(self.notebook_1_pane_2) 
    117126        sizer_3.SetSizeHints(self.notebook_1_pane_2) 
    118         self.nb.AddPage(self.notebook_1_pane_1, "About"
    119         self.nb.AddPage(self.notebook_1_pane_2, "Licence"
     127        self.nb.AddPage(self.notebook_1_pane_1, _("About")
     128        self.nb.AddPage(self.notebook_1_pane_2, _("Licence")
    120129        sizer_1.Add(self.nb, 1, wx.EXPAND, 0) 
    121130 
     
    132141        #-1 , "Settings", size = wx.DefaultSize, ,  
    133142        #     style = wx.DEFAULT_DIALOG_STYLE): 
    134         wx.Dialog.__init__(self, parent, -1, "Settings", pos = wx.DefaultPosition, size =(450,-1)) 
     143        wx.Dialog.__init__(self, parent, -1, _("Settings"), pos = wx.DefaultPosition, size =(450,-1)) 
    135144         
    136145        ## The layout begins: 
    137146        font = wx.Font(16, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD) 
    138         self.labelHeading = wx.StaticText(self, -1, "Settings"
     147        self.labelHeading = wx.StaticText(self, -1, _("Settings")
    139148        self.labelHeading.SetFont(font) 
    140149 
    141         self.label_1 = wx.StaticText(self, -1, "Sample text:"
     150        self.label_1 = wx.StaticText(self, -1, _("Sample text:")
    142151        self.inputSampleString = wx.TextCtrl(self, -1, fpsys.config.text) #, size = (200, -1))  
    143152        self.inputSampleString.SetFocus() 
    144153         
    145         self.label_2 = wx.StaticText(self, -1, "Point size:")  
     154        self.label_2 = wx.StaticText(self, -1, _("Point size:")) 
    146155        self.inputPointSize = wx.SpinCtrl(self, -1, "") 
    147156        self.inputPointSize.SetRange(1, 500) 
    148157        self.inputPointSize.SetValue(fpsys.config.points) 
    149158         
    150         self.label_3 = wx.StaticText(self, -1, "Page length:"
     159        self.label_3 = wx.StaticText(self, -1, _("Page length:")
    151160        self.inputPageLen = wx.SpinCtrl(self, -1, "") 
    152161        self.inputPageLen.SetRange(1, 5000) # It's your funeral! 
  • branches/baptiste/fontypython/folder.py

    r8 r11  
    2323import fontybugs 
    2424import sys 
     25import os 
     26 
     27## i18n imports 
     28import gettext 
     29from gettext import gettext as _ 
     30## i18n configuration 
     31gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     32gettext.textdomain("misc") 
    2533 
    2634class Folder(BasicFontList): 
     
    4250                    fi = FontItem(os.path.join(self.path, f), False)  
    4351                except UnicodeDecodeError, e: 
    44                     sys.exit("The file %s has caused a unicode error.\nPlease rename it, removing any strange characters, and try again." % f) 
     52                    sys.exit(_("The file %s has caused a unicode error.\nPlease rename it, removing any strange characters, and try again.") % f) 
    4553                self.append(fi)  
    4654        if len(self) == 0: 
  • branches/baptiste/fontypython/fontybugs.py

    r4 r11  
    2323## I want a single file which contains all the errors. 
    2424 
     25import sys 
     26import os 
     27 
     28## i18n imports 
     29import gettext 
     30from gettext import gettext as _ 
     31## i18n configuration 
     32gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     33gettext.textdomain("misc") 
     34 
    2535class Errors ( Exception ): 
    26     checkperms = "Also check your file permissions" 
     36    checkperms = _("Also check your file permissions") 
    2737    messages = { 
    28                             001 : "Bad voodoo error. I give up."
    29                             100 : "There is no such item"
    30                             200 : "Pog is empty"
    31                             300 : "Pog is already installed"
    32                             #400 : "Pog cannot be read", 
    33                             500 : "Pog cannot be written to.\nCheck your filesystem.\n%s" % checkperms, 
    34                             600 : "Pog is invalid, please hand-edit it"
    35                             700 : "Some fonts did not install.\nPerhaps the original fonts folder has moved or been renamed.\nYou should purge or hand-edit"
    36                             800 : "Pog is not installed."
    37                             900 : "Some fonts could not be uninstalled.\nPlease check your home .fonts (with a dot in front) folder for broken links.\n%s" % checkperms, 
    38                             1000 : "Cannot delete the Pog. %s" % checkperms, 
    39                             1010 : "Not a single font in this pog could be installed.\nThe original font folder has probably moved or been renamed."
    40                             1020 : "Not a single font in this pog could be uninstalled.\nNone of the fonts were in your fonts folder, please check your home .fonts (with a dot in front) folder for broken links.\nThe pog has been marked as \"not installed\""
    41                             1030 : "This folder has not ttf fonts in it" 
     38                            001 : _("Bad voodoo error. I give up.")
     39                            100 : _("There is no such item")
     40                            200 : _("Pog is empty")
     41                            300 : _("Pog is already installed")
     42                            #400 : _("Pog cannot be read", 
     43                            500 : _("Pog cannot be written to.\nCheck your filesystem.\n%s") % checkperms, 
     44                            600 : _("Pog is invalid, please hand-edit it")
     45                            700 : _("Some fonts did not install.\nPerhaps the original fonts folder has moved or been renamed.\nYou should purge or hand-edit")
     46                            800 : _("Pog is not installed.")
     47                            900 : _("Some fonts could not be uninstalled.\nPlease check your home .fonts (with a dot in front) folder for broken links.\n%s") % checkperms, 
     48                            1000 : _("Cannot delete the Pog. %s") % checkperms, 
     49                            1010 : _("Not a single font in this pog could be installed.\nThe original font folder has probably moved or been renamed.")
     50                            1020 : _("Not a single font in this pog could be uninstalled.\nNone of the fonts were in your fonts folder, please check your home .fonts (with a dot in front) folder for broken links.\nThe pog has been marked as \"not installed\"")
     51                            1030 : _("This folder has not ttf fonts in it") 
    4252                        } 
    4353    def __str__ ( self ): 
     
    4858        self._item = item 
    4959        self._id = 001 
    50          
     60 
    5161class ErrNoSuchItem ( Errors ): 
    5262    def __init__ ( self, item = None):  
     
    5868        self._item = item 
    5969        self._id = 200 
    60          
     70 
    6171class PogInstalled ( Errors ): 
    6272    def __init__ ( self, item = None):  
    6373        self._item = item 
    6474        self._id = 300         
    65   
     75 
    6676class PogWriteError ( Errors ): 
    6777    def __init__ ( self, item = None):  
    6878        self._item = item 
    6979        self._id = 500          
    70          
     80 
    7181class PogInvalid ( Errors ): 
    7282    def __init__ ( self, item = None):  
     
    7888        self._item = item 
    7989        self._id = 700   
    80          
     90 
    8191#FontNotInstalled 
    8292class PogNotInstalled ( Errors ): 
     
    8494        self._item = item 
    8595        self._id = 800   
    86          
     96 
    8797class PogLinksRemain ( Errors ): 
    8898    def __init__ ( self, item = None):  
    8999        self._item = item 
    90100        self._id = 900         
    91          
     101 
    92102#PogCannotDelete 
    93103class PogCannotDelete ( Errors ): 
     
    95105        self._item = item 
    96106        self._id = 1000 
    97          
     107 
    98108class PogAllFontsFailedToInstall ( Errors ): 
    99109    def __init__ ( self, item = None):  
     
    104114    def __init__ ( self, item = None):  
    105115        self._item = item 
    106         self._id = 1020          
    107          
     116        self._id = 1020 
     117 
    108118class FolderHasNoFonts ( Errors ): 
    109119    def __init__ ( self, item = None):  
    110120        self._item = item 
    111         self._id = 1030             
    112          
    113          
    114          
    115          
    116          
    117          
    118          
    119          
    120          
     121        self._id = 1030 
  • branches/baptiste/fontypython/fpsys.py

    r6 r11  
    1818## 
    1919 
    20 import sys, os, pickle 
     20import sys 
     21import os 
    2122import pathcontrol 
    2223import strings 
     
    2526from folder import * 
    2627from emptyview import * 
     28 
     29## i18n imports 
     30import gettext 
     31from gettext import gettext as _ 
     32## i18n configuration 
     33gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     34gettext.textdomain("misc") 
    2735 
    2836## fpsys : fonty python system. 
     
    4351        return os.path.dirname(os.path.abspath(root))  
    4452    except: 
    45         print "I'm sorry, but something is wrong." 
    46         print "There is no __file__ variable. Please contact the author." 
     53        print _("I'm sorry, but something is wrong.") 
     54        print _("There is no __file__ variable. Please contact the author.") 
    4755        sys.exit()  
    4856 
     
    8694mythingsdir = determine_fontypython_path()  + "/things/" #point it at things/ folder 
    8795 
    88 #### 
    89 ## Save and Load the conf file 
    90 class Configure: 
    91     """Makes/Loads the conf file. 
    92     Supplies size, pos, numinpage, text string and point size to other objects.""" 
    93     def __init__(self) : 
    94         ## Private vars 
    95         self.__dontSaveNumInPage = False 
    96         self.ipc = pathcontrol.PathControl() 
    97         ## PUBLIC vars :  Set some defaults: 
    98         self.size = (400,600)  
    99         self.pos = (10, 10) 
    100         self.numinpage = 10 
    101         self.text = "Jump the lazy dog fox" 
    102         self.points = 64       
    103         self.lastview = "EMPTY" # a pog name or a folder path. 
    104         self.usegui = "wxgui" 
    105         self.max = True 
    106         self.lastdir = self.ipc.home() 
    107          
    108         self.__setData() 
    109          
    110         if os.path.exists(self.ipc.appConf()): 
    111             try: 
    112                 pf = open(self.ipc.appConf(), "r")  #Using global self.ipc object! 
    113                 self.__data = pickle.load(pf)  
    114                 pf.close()  
    115             except: 
    116                 sys.exit("%s file appears to be damaged.\nPlease delete it and start again" %  self.ipc.appConf()) 
    117         else: 
    118             print "No config file found, creating it with defaults." 
    119             self.__write()  
    120         ## Now get them into the instance vars: 
    121         try: 
    122             self.size = self.__data['size'] 
    123             self.pos = self.__data['pos'] 
    124             self.numinpage = self.__data['numinpage'] 
    125             self.text = self.__data['text'] 
    126             self.points= self.__data['points'] 
    127             self.lastview = self.__data['lastview']             
    128             self.usegui = self.__data['usegui'] 
    129             self.max = self.__data['max'] 
    130             self.lastdir = self.__data['lastdir'] 
    131              
    132         except KeyError: 
    133             ## The conf file has keys that don't work for this version, chances are it's old. 
    134             ## Let's delete and re-make it. 
    135             try: 
    136                 os.unlink(self.ipc.appConf()) 
    137             except: 
    138                 sys.exit("The fontypython config file is damaged.\nPlease remove it and start again") 
    139             self.__write() 
    140     def dontSaveNumInPage(self, flag): 
    141         self.__dontSaveNumInPage = flag 
    142     def __setData(self): 
    143         self.__data = {"size" : self.size, 
    144                                 "pos" : self.pos, 
    145                                 "numinpage" : self.numinpage, 
    146                                 "text" : self.text, 
    147                                 "points" : self.points, 
    148                                 "lastview" : self.lastview, 
    149                                 "usegui" : self.usegui, 
    150                                 "max" : self.max, 
    151                                 "lastdir" : self.lastdir 
    152                                 } 
    153     def __write(self) : 
    154         #If we are NOT to save the numinpage, then fetch it from what was there before. 
    155         if self.__dontSaveNumInPage: 
    156             self.numinpage = self.__data["numinpage"] 
    157         self.__setData() 
    158         try: 
    159             pf = open(self.ipc.appConf(), "w")  
    160             pickle.dump(self.__data, pf)  
    161             pf.close()  
    162         except IOError: 
    163             print "Could not write to the config file." 
    164     def Save(self) : 
    165         self.__write()  #Go write the file 
    166  
    167  
    16896## Our config instance - it will have one instance across 
    16997## all the modules that use it. 
    170 config = Configure() 
     98import config as configure_parent 
     99config = configure_parent.instance 
    171100 
    172101def validateViewFolder(foldername): 
     
    248177        for iA in state.viewobject: 
    249178            if iA.paf in pafBlist: 
    250                 iA.msg = "Already in %s" % state.targetobject.name 
     179                iA.msg = _("Already in %s") % state.targetobject.name 
    251180                iA.inactive = True 
    252181        del pafBlist 
  • branches/baptiste/fontypython/fpversion.py

    r4 r11  
    1818## 
    1919 
    20 version = "0.2.0" #Full GUI version 
     20__version__ = "0.2.0B" #Full GUI version 
  • branches/baptiste/fontypython/pathcontrol.py

    r6 r11  
    2020##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    2121## 
     22 
     23import sys 
    2224import os 
     25 
     26## i18n imports 
     27import gettext 
     28from gettext import gettext as _ 
     29## i18n configuration 
     30gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     31gettext.textdomain("misc") 
    2332 
    2433class PathControl: 
     
    4049                    os.mkdir(self.__HOME + "/.fonts") 
    4150                except: 
    42                     print "Couldn't make the .fonts folder in %s" % self.__HOME 
    43                     print "Please check your write permissions and try again." 
     51                    print _("Couldn't make the .fonts folder in %s") % self.__HOME 
     52                    print _("Please check your write permissions and try again.") 
    4453                    sys.exit () 
    4554            self.__userfontpath = self.__HOME + "/.fonts" 
     
    4857            self.__fpconffile = self.__HOME + "\\fontypython\\fp.conf" 
    4958        else: 
    50             sys.exit("Unsupported O/S"
     59            sys.exit(_("Unsupported O/S")
    5160         
    5261        #Make ~/.fontypython or ?:\Documents and Settings\blah\blah\fontypython 
     
    5564                os.makedirs(self.__fphomepath) #using makedirS - just in case. 
    5665            except: 
    57                 print "Couldn't make the folder in %s" % self.__fphomepath 
    58                 print "Please check your write permissions and try again." 
     66                print _("Couldn't make the folder in %s") % self.__fphomepath 
     67                print _("Please check your write permissions and try again.") 
    5968                sys.exit () 
    6069             
  • branches/baptiste/fontypython/pog.py

    r6 r11  
    2020## 
    2121 
     22import sys 
     23import os 
    2224from basicfontlist import * 
    2325from pathcontrol import *  
    2426import fontybugs 
     27 
     28## i18n imports 
     29import gettext 
     30from gettext import gettext as _ 
     31## i18n configuration 
     32gettext.bindtextdomain("misc", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     33gettext.textdomain("misc") 
    2534 
    2635class Pog(BasicFontList): 
     
    5867        line1 = f.readline()[:-1] 
    5968        self.__installed = "dirty" # unsure as to the status 
    60         if line1.upper() == "INSTALLED": self.__installed = "yes" 
    61         if line1.upper() == "NOT INSTALLED": self.__installed = "no" 
     69        if line1.upper() == "INSTALLED": self.__installed = _("yes") 
     70        if line1.upper() == "NOT INSTALLED": self.__installed = _("no") 
    6271        if self.__installed == "dirty": 
    6372            ## We have a bad pog. 
     
    7281    def isInstalled(self): 
    7382        """Will ONLY raise a PogInvalid error. Any other will abort app.""" 
    74         if self.__installed == "yes": return True 
    75         if self.__installed == "no": return False 
     83        if self.__installed == _("yes"): return True 
     84        if self.__installed == _("no"): return False 
    7685        ## Else it == "dirty" and: 
    7786        ## We must open the file to discover the status: 
     
    7988        f = self.__openfile() #sets __installed flag 
    8089        f.close() 
    81         if self.__installed == "yes": return True 
    82         if self.__installed == "no": return False         
     90        if self.__installed == _("yes"): return True 
     91        if self.__installed == _("no"): return False         
    8392         
    8493    def __renameBadPog(self): 
     
    113122            raise fontybugs.PogEmpty # RAISED :: PogEmpty 
    114123        ## can't purge an installed pog 
    115         if self.__installed == "yes"
     124        if self.__installed == _("yes")
    116125            raise fontybugs.PogInstalled # RAISED :: PogInstalled 
    117126        else: 
     
    141150    def install(self): 
    142151        ## We start thinking all is rosey: 
    143         self.__installed = "yes" 
     152        self.__installed = _("yes") 
    144153        self.__badpog = False 
    145154        ## Now we make sure ... 
    146155        if len(self) == 0:  
    147             self.__installed = "no" 
     156            self.__installed = _("no") 
    148157            raise fontybugs.PogEmpty(self.name) # RAISED :: PogEmpty 
    149158        ## Now we go through the guts of the pog, font by font: 
     
    155164                if os.path.exists(fi.paf): 
    156165                    os.symlink(fi.paf, linkDestination)  #Should do the trick. 
    157                     self.__doProgressCallback("installed : %s" % fi.paf) 
     166                    self.__doProgressCallback(_("installed : %s") % fi.paf) 
    158167                else: 
    159                     self.__doProgressCallback("Could not find %s" % fi.paf) 
     168                    self.__doProgressCallback(_("Could not find %s") % fi.paf) 
    160169                    bugs += 1 
    161170        if bugs == len(self): # There was 100% failure to install fonts. 
     
    188197        if len(self) == 0: raise fontybugs.PogEmpty # RAISED :: PogEmpty 
    189198        bugs = 0 
    190         if self.__installed == "yes"
     199        if self.__installed == _("yes")
    191200            for fi in self: 
    192201                link = os.path.join(self.__pc.userFontPath(), fi.name) #Point at the link in .fonts folder. 
     
    195204                    try: 
    196205                        os.unlink(link)  
    197                         self.__doProgressCallback("removed : %s" % fi.paf) 
     206                        self.__doProgressCallback(_("removed: %s") % fi.paf) 
    198207                    except: # e.g. Permission denied [err 13] 
    199208                        ## Only bugs that imply that the file is THERE but CANNOT BE REMOVED 
    200209                        ## are classified as bugs. We are making a sweeping assumption here. 
    201                         self.__doProgressCallback("Could not remove %s" % link) 
     210                        self.__doProgressCallback(_("Could not remove %s") % link) 
    202211                        bugs += 1 
    203212            ## Okay, we are currently INSTALLED, so what is the result of the loop? 
     
    207216            else: 
    208217                ## Okay - there were no problems, so we are now done. 
    209                 self.__installed = "no" 
     218                self.__installed = _("no") 
    210219                self.write() #save to disk 
    211220        else: 
     
    218227        try: 
    219228            f = open(self.paf, "w")  
    220             i = "not installed\n" 
    221             if self.__installed == "yes"
    222                 i = "installed\n" 
     229            i = _("not installed\n") 
     230            if self.__installed == _("yes")
     231                i = _("installed\n") 
    223232            f.write(i)  
    224233            #Now write the font pafs 
     
    237246            raise fontybugs.PogCannotDelete(self.paf) 
    238247        self.clear() 
    239         self.__installed = "no" 
     248        self.__installed = _("no") 
  • branches/baptiste/fontypython/start.py

    r6 r11  
    6262 
    6363## End, clean up 
    64 fpsys.config.Save() 
     64fpsys.config.save() 
  • branches/baptiste/fontypython/strings.py

    r6 r11  
    1919##    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
    2020## 
     21 
     22import sys 
     23import os 
    2124import pathcontrol  
    2225import fpversion 
    2326 
    24 copyright = "Fonty Python Copyright (C) 2006 Donn.C.Ingle" 
    25 contact = "email: donn.ingle@gmail.com" 
    26 done = "Done." 
     27## i18n imports 
     28import gettext 
     29from gettext import gettext as _ 
     30## i18n configuration 
     31gettext.bindtextdomain("main", os.path.abspath(os.path.dirname(sys.argv[0])) + "/locale/") 
     32gettext.textdomain("main") 
     33 
     34copyright = _("Fonty Python Copyright (C) 2007 Donn.C.Ingle") 
     35contact = _("email: donn.ingle@gmail.com. website: http://fontypython.webfactional.com/") 
     36done = _("Done.") 
    2737_pc = pathcontrol.PathControl() 
    2838 
    29 warranty = """Fonty Python comes with ABSOLUTELY NO WARRANTY; for details 
     39warranty = _("""Fonty Python comes with ABSOLUTELY NO WARRANTY; for details 
    3040see the COPYING file.  This is free software, and you are welcome to redistribute 
    3141it under certain conditions; see the COPYING file or the Licence tab in the 
    32 About menu for details.""" 
     42About menu for details.""") 
    3343 
    3444def  AboutText(): 
    35     return "%s\nVersion %s.\nWritten on Gnu\Linux, using wxPython.\n\n%s" % (copyright, fpversion.version, warranty) 
     45    return _("%(copyright)s\nVersion %(version)s.\nWritten on Gnu\Linux, using wxPython.\n\n%(warranty)s") % {'copyright': copyright, 'version': fpversion.__version__, 'warranty': warranty} 
    3646     
    3747def use(): 
    38     use = """fp [OPTIONS] VIEW [TARGET] 
     48    use = _("""fp [OPTIONS] VIEW [TARGET] 
    3949     
    4050VIEW   : A place where fonts are. A pog or a folder someplace. 
     
    6676 
    6777Manage your ttf fonts on Gnu/Linux! 
    68 """ + copyright + """ 
    69 """ + warranty + """ 
    70 """ + contact 
     78%(copyright)s  
     79%(warranty)s 
     80%(contact)s""") % {'copyright': copyright, 'warranty': warranty, 'contact': contact} 
    7181    return use 
    7282     
    7383def examples(): 
    74     s = """The basic format is: fp VIEW [TARGET] 
     84    s = _("""The basic format is: fp VIEW [TARGET] 
    7585  VIEW   = A place where fonts are. A pog or a folder 
    7686           someplace. 
     
    155165     
    156166Your fontypython folder is: 
    157 """ + _pc.appPath() + """ 
     167%(path)s 
    158168If you want to backup your pogs, that's where ya go. 
    159  
    160 """ + contact + """ 
    161 """ + copyright 
     169%(contact)s 
     170 
     171%(copyright)s""") % {'path': _pc.appPath(), 'contact': contact, 'copyright': copyright} 
    162172             
    163173    return s 
    164174     
    165175def wxVersionError(): 
    166     return """I cannot find python-wxversion, this 
     176    return _("""I cannot find python-wxversion, this 
    167177            may mean you have some missing dependencies. 
    168178            Fonty Python will try to start anyway ... 
     
    174184            install python-wxgtk2.6 or better. 
    175185            Go to http://wxpython.sourceforge.net/download.php 
    176             """ 
    177              
     186            """)             
    178187     
    179188def wxError(): 
    180     return """Fonty Python depends on "wxPython". 
     189    return _("""Fonty Python depends on "wxPython". 
    181190            Please install "python-wxgtk2.6" (or better) here are the details: 
    182191 
     
    185194             
    186195            Go to http://wxpython.sourceforge.net/download.php 
    187             """ 
     196            """) 
    188197 
    189198def PILError(): 
    190     return """Fonty Python depends on "PIL" - Python Imaging Library. 
    &n