comparison sat_website/social_contract.py @ 8:c70038fb98dc

Social Contract (Contrat Social) localisation
author Goffi <goffi@goffi.org>
date Thu, 02 Aug 2012 01:45:18 +0200
parents 9305c6458e2f
children bdd6ccffe149
comparison
equal deleted inserted replaced
7:4bdc81db6282 8:c70038fb98dc
18 18
19 You should have received a copy of the GNU Affero General Public License 19 You should have received a copy of the GNU Affero General Public License
20 along with Foobar. If not, see <http://www.gnu.org/licenses/>. 20 along with Foobar. If not, see <http://www.gnu.org/licenses/>.
21 """ 21 """
22 22
23 from os.path import join, dirname 23 from os.path import join, dirname, exists
24 from django.utils.translation import get_language
25 CONTRAT_SOCIAL = "CONTRAT_SOCIAL"
24 26
25 def get_social_contract(language_code="fr"): 27 def get_social_contract():
26 """Return the localised social contract version""" 28 """Return the localised social contract version"""
27 path = join(dirname(__file__), "CONTRAT_SOCIAL") 29 language_code = get_language()
30 filename = CONTRAT_SOCIAL if language_code == "fr" else "CONTRAT_SOCIAL_%s" % (language_code,)
31 path = join(dirname(__file__), filename)
32 if not exists(path):
33 path = join(dirname(__file__), CONTRAT_SOCIAL) #we default to original version
34
28 with open(path) as f: 35 with open(path) as f:
29 text = f.read() 36 text = f.read()
30 return text 37 return text
31 38