Skip to content

Commit 947439c

Browse files
committed
i18n: move to babel
Configure setup.py to handle environments without babel installed, Create a README for documenting how to write translations.
1 parent 1e64450 commit 947439c

File tree

2 files changed

+50
-4
lines changed

2 files changed

+50
-4
lines changed

i18n/README

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
Dependencies
2+
============
3+
babel (http://babel.edgewall.org/)
4+
(pip install babel)
5+
6+
Internationalization
7+
====================
8+
bPython delegates to babel most of the job for creating .po and .mo files, so
9+
you may want to check also its documentation for more informations
10+
http://babel.edgewall.org/wiki/Documentation/0.9/index.html .
11+
12+
In order to create a new language translation, first of all you need to know
13+
that translations follow this path template: i18n/locale/<locale>/LC_MESSAGES/bpython.po
14+
15+
To create a new template .po file, you just need to follow 4steps:
16+
1. Set up the correct directory structure:
17+
18+
$ mkdir i18n/locale/fo_FO/ # assuming fo_FO is your desidered locale
19+
$ mkdir i18n/locale/fo_FO/LC_MESSAGES
20+
21+
2. Extract messages from the source using babel:
22+
23+
$ python setup.py extract_messages -o i18n/locale/fo_FO/LC_MESSAGES/bpython.po
24+
running extract_messages
25+
extracting messages from bpdb/__init__.py
26+
extracting messages from bpdb/debugger.py
27+
extracting messages from bpython/__init__.py
28+
...
29+
writing PO template file to i18n/locale/fo_FO/LC_MESSAGES/bpython.po
30+
31+
3. Edit bpython.po
32+
33+
4. Compile the bpython.po file jsut created using babel:
34+
$ python setup.py compile_catalog -f
35+
running compile_catalog
36+
compiling catalog 'i18n/locale/fo_FO/LC_MESSAGES/bpython.po' to 'i18n/locale/fo_FO/LC_MESSAGES/bpython.mo'
37+
38+
bPython will take care to install generated locales to /usr/share/locale, so
39+
just type
40+
$ python setup.py install
41+
to enjoy internationalization!
42+

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def initialize_options(self):
4949
else:
5050
man_dir = 'share/man'
5151

52+
5253
data_files = [
5354
# man pages
5455
(os.path.join(man_dir, 'man1'), ['doc/bpython.1']),
@@ -62,6 +63,12 @@ def initialize_options(self):
6263
lang_path = os.path.join('', 'locale', lang, 'LC_MESSAGES', 'bpython.mo')
6364
data_files.append(('share'+lang_path, ['i18n'+lang_path]))
6465

66+
cmdclass = dict(build_py=build_py,
67+
build = build)
68+
# localization options: see i18n/README for more informations
69+
if using_translations:
70+
cmdclass['compile_catalog'] = compile_catalog
71+
cmdclass['extract_messages'] = extract_messages
6572

6673
setup(
6774
name="bpython",
@@ -87,10 +94,7 @@ def initialize_options(self):
8794
},
8895
scripts = ([] if using_setuptools else ['data/bpython',
8996
'data/bpython-gtk']),
90-
cmdclass = dict(build_py=build_py,
91-
build = build,
92-
compile_catalog = compile_catalog,
93-
extract_messages = extract_messages)
97+
cmdclass = cmdclass
9498
)
9599

96100
# vim: encoding=utf-8 sw=4 ts=4 sts=4 ai et sta

0 commit comments

Comments
 (0)