Skip to content

Commit 00f16f9

Browse files
committed
Import of initial code base.
1 parent 3a6d9c9 commit 00f16f9

24 files changed

+2384
-0
lines changed

COPYING

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Copyright (C) 2007 Edgewall Software
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions
6+
are met:
7+
8+
1. Redistributions of source code must retain the above copyright
9+
notice, this list of conditions and the following disclaimer.
10+
2. Redistributions in binary form must reproduce the above copyright
11+
notice, this list of conditions and the following disclaimer in
12+
the documentation and/or other materials provided with the
13+
distribution.
14+
3. The name of the author may not be used to endorse or promote
15+
products derived from this software without specific prior
16+
written permission.
17+
18+
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
19+
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21+
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24+
GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
26+
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
27+
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
28+
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nothing so far, not even public yet.

INSTALL.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Installing Babel
2+
================
3+
4+
Prerequisites
5+
-------------
6+
7+
* Python 2.3 or later (2.4 or later is recommended)
8+
* Optional: setuptools 0.6b1 or later
9+
10+
11+
Installation
12+
------------
13+
14+
Once you've downloaded and unpacked a Babel source release, enter the
15+
directory where the archive was unpacked, and run:
16+
17+
$ python setup.py install
18+
19+
Note that you may need administrator/root privileges for this step, as
20+
this command will by default attempt to install Babel to the Python
21+
site-packages directory on your system.
22+
23+
For advanced options, please refer to the easy_install and/or the distutils
24+
documentation:
25+
26+
http://peak.telecommunity.com/DevCenter/EasyInstall
27+
http://docs.python.org/inst/inst.html
28+
29+
30+
Support
31+
-------
32+
33+
If you encounter any problems with Babel, please don't hesitate to ask
34+
questions on the Babel mailing list or IRC channel:
35+
36+
http://babel.edgewall.org/wiki/MailingList
37+
http://babel.edgewall.org/wiki/IrcChannel

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include babel/localedata/*.dat
2+
include doc/api/*.*
3+
include doc/*.html

README.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
About Babel
2+
===========
3+
4+
Babel is a Python library that provides an integrated collection of
5+
utilities that assist with internationalizing and localizing Python
6+
applications (in particular web-based applications.)
7+
8+
Details can be found in the HTML files in the `doc` folder.
9+
10+
For more information please visit the Babel web site:
11+
12+
<http://babel.edgewall.org/>

babel/__init__.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2006 Edgewall Software
4+
# All rights reserved.
5+
#
6+
# This software is licensed as described in the file COPYING, which
7+
# you should have received as part of this distribution. The terms
8+
# are also available at http://babel.edgewall.org/wiki/License.
9+
#
10+
# This software consists of voluntary contributions made by many
11+
# individuals. For the exact contribution history, see the revision
12+
# history and logs, available at http://babel.edgewall.org/log/.
13+
14+
"""Integrated collection of utilities that assist in internationalizing and
15+
localizing applications.
16+
17+
This package is basically composed of two major parts:
18+
19+
* tools to build and work with ``gettext`` message catalogs
20+
* a Python interface to the CLDR (Common Locale Data Repository), providing
21+
access to various locale display names, localized number and date
22+
formatting, etc.
23+
24+
:see: http://www.gnu.org/software/gettext/
25+
:see: http://docs.python.org/lib/module-gettext.html
26+
:see: http://www.unicode.org/cldr/
27+
"""
28+
29+
from babel.core import Locale
30+
31+
__docformat__ = 'restructuredtext en'
32+
__version__ = __import__('pkg_resources').get_distribution('Babel').version

babel/catalog/__init__.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Copyright (C) 2007 Edgewall Software
4+
# All rights reserved.
5+
#
6+
# This software is licensed as described in the file COPYING, which
7+
# you should have received as part of this distribution. The terms
8+
# are also available at http://babel.edgewall.org/wiki/License.
9+
#
10+
# This software consists of voluntary contributions made by many
11+
# individuals. For the exact contribution history, see the revision
12+
# history and logs, available at http://babel.edgewall.org/log/.
13+
14+
"""Support for ``gettext`` message catalogs."""
15+
16+
import gettext
17+
18+
__all__ = ['Translations']
19+
20+
DEFAULT_DOMAIN = 'messages'
21+
22+
23+
class Translations(gettext.GNUTranslations):
24+
"""An extended translation catalog class."""
25+
26+
def __init__(self, fileobj=None):
27+
"""Initialize the translations catalog.
28+
29+
:param fileobj: the file-like object the translation should be read
30+
from
31+
"""
32+
GNUTranslations.__init__(self, fp=fileobj)
33+
self.files = [getattr(fileobj, 'name')]
34+
35+
def load(cls, dirname=None, locales=None, domain=DEFAULT_DOMAIN):
36+
"""Load translations from the given directory.
37+
38+
:param dirname: the directory containing the ``MO`` files
39+
:param locales: the list of locales in order of preference (items in
40+
this list can be either `Locale` objects or locale
41+
strings)
42+
:param domain: the message domain
43+
:return: the loaded catalog, or a ``NullTranslations`` instance if no
44+
matching translations were found
45+
:rtype: `Translations`
46+
"""
47+
locales = [str(locale) for locale in locales]
48+
filename = gettext.find(domain, dirname, locales)
49+
if not filename:
50+
return NullTranslations()
51+
return cls(open(filename, 'rb'))
52+
load = classmethod(load)
53+
54+
def merge(self, translations):
55+
"""Merge the given translations into the catalog.
56+
57+
Message translations in the specfied catalog override any messages with
58+
the same identifier in the existing catalog.
59+
60+
:param translations: the `Translations` instance with the messages to
61+
merge
62+
:return: the `Translations` instance (``self``) so that `merge` calls
63+
can be easily chained
64+
:rtype: `Translations`
65+
"""
66+
if isinstance(translations, Translations):
67+
self._catalog.update(translations._catalog)
68+
self.files.extend(translations.files)
69+
return self
70+
71+
def __repr__(self):
72+
return "<%s %r>" % (type(self).__name__)

0 commit comments

Comments
 (0)