mathmaker
0.6(alpha)
|
00001 # -*- coding: utf-8 -*- 00002 00003 # Mathmaker creates automatically maths exercises sheets 00004 # with their answers 00005 # Copyright 2006-2014 Nicolas Hainaux <nico_h@users.sourceforge.net> 00006 00007 # This file is part of Mathmaker. 00008 00009 # Mathmaker is free software; you can redistribute it and/or modify 00010 # it under the terms of the GNU General Public License as published by 00011 # the Free Software Foundation; either version 3 of the License, or 00012 # any later version. 00013 00014 # Mathmaker is distributed in the hope that it will be useful, 00015 # but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 # GNU General Public License for more details. 00018 00019 # You should have received a copy of the GNU General Public License 00020 # along with Mathmaker; if not, write to the Free Software 00021 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 00023 import gettext, os, sys 00024 from lib import error 00025 from lib.common import software 00026 from lib.common import default 00027 from lib.common.cst import * 00028 00029 pathname = os.path.dirname(sys.argv[0]) 00030 localdir = os.path.abspath(pathname) + "/locale" 00031 00032 try: 00033 gettext.translation(software.NAME, 00034 localdir, 00035 [default.LANGUAGE]).install() 00036 except IOError as msg: 00037 error.write_warning("gettext returned the following message :\n" \ 00038 + str(msg) + "\n" \ 00039 + "It means the language indicated either \ 00040 in the command line or read from the configuration file isn't available yet \ 00041 in %(software_ref)s which will try to produce output in the language of your \ 00042 system." % {'software_ref' : software.NAME} + "\n" ) 00043 try: 00044 gettext.install(software.NAME, 00045 localdir) 00046 except IOError as msg: 00047 error.write_warning("gettext returned the following message :\n" \ 00048 + str(msg) + "\n" \ 00049 + "It means the language of your system isn't \ 00050 available yet in %(software_ref)s which will produce output in \ 00051 english. If this results in producing an error, then your installation isn't \ 00052 complete." % {'software_ref' : software.NAME} + "\n") 00053 gettext.translation(software.NAME, 00054 localdir, 00055 ['en']).install() 00056 00057 00058 PRECISION_IDIOMS = { UNIT : _("to the unit"), 00059 TENTH : _("to the tenth"), 00060 HUNDREDTH : _("to the hundreth"), 00061 THOUSANDTH : _("to the thousandth"), 00062 TEN_THOUSANDTH : _("to the ten thousandth") 00063 } 00064