X Tutup
Skip to content

Commit bc588d4

Browse files
committed
i18n: integration.
Translations moved to package dir. This way, --prefix installations work and the package mantainer can install translations to /usr/share with a one-line patch.
1 parent 766931a commit bc588d4

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

bpython/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@
2020
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2121
# THE SOFTWARE.
2222

23+
import os.path
2324

2425
__version__ = '0.9.7.1'
26+
package_dir = os.path.abspath(os.path.dirname(__file__))
2527

2628

2729
def embed(locals_=None, args=['-i', '-q'], banner=None):
File renamed without changes.
File renamed without changes.

setup.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from distutils import cmd
1313
from distutils.command.build import build
1414

15-
from bpython import __version__
15+
from bpython import __version__, package_dir
1616

1717
try:
1818
from setuptools import setup
@@ -30,14 +30,16 @@
3030
from babel.messages.frontend import compile_catalog as _compile_catalog
3131
from babel.messages.frontend import extract_messages
3232

33+
translations_dir = os.path.join(package_dir, 'translations')
34+
3335
class compile_catalog(_compile_catalog):
3436
def initialize_options(self):
3537
"""Simply set default domain and directory attributes to the
3638
correct path for bpython."""
3739
_compile_catalog.initialize_options(self)
3840

3941
self.domain = 'bpython'
40-
self.directory = os.path.join('i18n')
42+
self.directory = translations_dir
4143
self.use_fuzzy = True
4244

4345
build.sub_commands.append(('compile_catalog', None))
@@ -60,9 +62,10 @@ def initialize_options(self):
6062
]
6163
# localization
6264
if using_translations:
63-
for lang in os.listdir('i18n'):
65+
for lang in os.listdir(translations_dir):
6466
data_files.append((os.path.join('share', 'locale', lang, 'LC_MESSAGES'),
65-
['i18n/%s/LC_MESSAGES/bpython.mo' % lang]))
67+
['%s/%s/LC_MESSAGES/bpython.mo' %
68+
(translations_dir, lang)]))
6669

6770
cmdclass = dict(build_py=build_py,
6871
build = build)

0 commit comments

Comments
 (0)
X Tutup