Page MenuHomec4science

messages.py.wml
No OneTemporary

File Metadata

Created
Sat, Jul 6, 05:18

messages.py.wml

## $Id$
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
#include "config.wml"
#include "cdswmllib.wml"
<protect>## -*- coding: utf-8 -*-</protect>
<protect>## $Id$
<protect>## DO NOT EDIT THIS FILE! IT WAS AUTOMATICALLY GENERATED FROM CDS Invenio WML SOURCES.</protect>
"""CDS Invenio international messages functions, to be used by all
I18N interfaces. Typical usage in the caller code is:
from messages import gettext_set_language
[...]
def square(x, ln=cdslang):
_ = gettext_set_language(ln)
print _("Hello there!")
print _("The square of %s is %s.") % (x, x*x)
In the caller code, all output strings should be made translatable via
the _() convention.
For more information, see ABOUT-NLS file.
"""
__revision__ = "$Id$"
import gettext
from invenio.config import localedir
lang = {}
for ln in <: print generate_language_list_for_python(); :>:
lang[ln] = gettext.translation('cds-invenio', localedir, languages = [ln], fallback = True)
def gettext_set_language(ln):
"""
Set the _ gettext function in every caller function
Usage::
_ = gettext_set_language(ln)
"""
return lang[ln].gettext
def wash_language(ln):
"""Look at LN and check if it is one of allowed languages for the interface.
Return it in case of success, return the default language otherwise."""
if ln in <: print generate_language_list_for_python(); :>:
return ln
else:
return '<CDSLANG>'
def language_list_long():
return <: print generate_language_list_for_python("long"); :>

Event Timeline