1 # -*- coding: utf-8 -*-
2 #Author: Pierre Ratinaud
3 #Copyright (c) 2008-2020 Pierre Ratinaud
4 #modification pour python 3 : Laurent Mérat, 6x7 - mai 2020
7 #------------------------------------
8 # import des modules python
9 #------------------------------------
11 from configparser import ConfigParser, RawConfigParser
14 #------------------------------------
15 # import des modules wx
16 #------------------------------------
19 #------------------------------------
20 # import des fichiers du projet
21 #------------------------------------
22 from chemins import ConstructConfigPath, ConstructDicoPath, ConstructGlobalPath, PathOut
24 #------------------------------------
26 #------------------------------------
33 # chemin de l'application
34 AppliPath = os.path.abspath(os.path.dirname(os.path.realpath(sys.argv[0])))
35 # preferences par defaut
36 DefaultConf = ConfigParser()
37 DictConfigPath = ConstructGlobalPath(AppliPath)
38 ConfigGlob = ConfigParser()
39 ConfigGlob.read(DictConfigPath['global'])
40 DefaultConf.read(DictConfigPath['preferences'])
41 # repertoire de l'utilisateur
42 user_home = os.getenv('HOME')
43 if user_home is None :
44 user_home = os.path.expanduser('~')
46 # chemin des préférences
47 UserConfigPath = os.path.abspath(os.path.join(user_home, '.iramuteq-%s' % ConfigGlob.get('DEFAULT', 'version_nb')))
48 ConfigPath = ConstructConfigPath(UserConfigPath)
50 # dictionnaires des langues disponibles pour l'interface
51 langues = {'french' : wx.LANGUAGE_FRENCH,
52 'english' : wx.LANGUAGE_ENGLISH,
53 'portuguese' : wx.LANGUAGE_PORTUGUESE,
54 'italian' : wx.LANGUAGE_ITALIAN,
55 'spanish' : wx.LANGUAGE_SPANISH
57 code_langues = {'french' : 'fr_FR',
59 'portuguese' : 'pt_PT',
63 # langue par defaut de l'interface (celle des messages écrits dans le code)
65 # dictionnaire des objets "traduction"
67 for langue in code_langues :
68 preslangue[langue] = gettext.translation('iramuteq',\
69 os.path.join(AppliPath,'locale'),\
70 languages=[code_langues[langue]])
71 ConfigPath = ConstructConfigPath(UserConfigPath)
72 prefGlob = RawConfigParser()
73 prefGlob.read(ConfigPath['preferences'])
74 # guilanguage est l'appelation originale dans iramuteq, renommé en 'langageUI' dans le code en P3
76 langueUI = prefGlob.get('iramuteq', 'guilanguage')
78 langueUI = DefaultConf.get('iramuteq', 'guilanguage')
80 # la fonction appelée depuis tous les fichiers de module qui ont besoin du système de traduction
81 # elle appelle la fonction d'initialisation si il y a lieu
88 preslangue[langueUI].install()
91 #------------------------------------
93 #------------------------------------
95 # fonction présente dans iramuteq.py
96 # self fait référence à une IraFrame, dérivé de wx.Frame
97 #fonction conservée de l'ancienne version pour le cas ou, mais qui n'est pas utilisée en principe
99 self.pref.read(self.ConfigPath['preferences'])
101 langueUI = self.pref.get('iramuteq', 'guilanguage')
103 langueUI = DefaultConf.get('iramuteq', 'guilanguage')
104 self.preslangue.get(langueUI, 'english').install()