# HG changeset patch # User Goffi # Date 1343864718 -7200 # Node ID c70038fb98dc2f1c4da48ddfb835a071df22b98d # Parent 4bdc81db6282717578d81e6518df724300736d38 Social Contract (Contrat Social) localisation diff -r 4bdc81db6282 -r c70038fb98dc sat_website/social_contract.py --- a/sat_website/social_contract.py Thu Aug 02 01:44:52 2012 +0200 +++ b/sat_website/social_contract.py Thu Aug 02 01:45:18 2012 +0200 @@ -20,11 +20,18 @@ along with Foobar. If not, see . """ -from os.path import join, dirname +from os.path import join, dirname, exists +from django.utils.translation import get_language +CONTRAT_SOCIAL = "CONTRAT_SOCIAL" -def get_social_contract(language_code="fr"): +def get_social_contract(): """Return the localised social contract version""" - path = join(dirname(__file__), "CONTRAT_SOCIAL") + language_code = get_language() + filename = CONTRAT_SOCIAL if language_code == "fr" else "CONTRAT_SOCIAL_%s" % (language_code,) + path = join(dirname(__file__), filename) + if not exists(path): + path = join(dirname(__file__), CONTRAT_SOCIAL) #we default to original version + with open(path) as f: text = f.read() return text