예제 #1
0
def buildlanguages():
    import django.core.management.commands.compilemessages as c
    oldpath = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__FILE__), 'transifex',
        'locale'))
    c.compile_messages()
    os.chdir(oldpath)
예제 #2
0
    def handle_noargs(self, *args, **options):
        """Call makemessages' one with better defaults.

        Three big changes:

        - No need to chdir to the app/site's directory, we guess that.

        - Follow symlinks in the app/site's directory for more po files.

        - By default, all existing locales are updated instead of requiring
          you to specify that.

        - All .po files are ALSO compiled.

        """
        app = os.path.basename(os.getcwd())
        app = app.replace('-', '_')
        logger.info("Guessing app module: %s.", app)
        module = __import__(app)
        app_dir = os.path.dirname(os.path.abspath(module.__file__))
        logger.info("App directory: %s.", app_dir)
        os.chdir(app_dir)
        if not options.get('locale'):
            logger.info("No locale specified, updating all existing ones.")
            options['all'] = True
        options['symlinks'] = True
        makemessages.Command.handle_noargs(self, *args, **options)
        logger.info("Also compiling all .po files into .mo.")
        compilemessages.compile_messages(self.stderr)
예제 #3
0
def buildlanguages():
    import django.core.management.commands.compilemessages as c
    oldpath = os.getcwd()
    os.chdir(os.path.join(os.path.dirname(__FILE__), 'transifex',
        'locale'))
    c.compile_messages()
    os.chdir(oldpath)
예제 #4
0
파일: translate.py 프로젝트: emulbreh/ecs
 def handle(self, *args, **kwargs):
     os.system('./manage.py makemessages -a')
     try:
         editor = os.environ['EDITOR']
     except KeyError:
         editor = 'vi'
     os.system('%s locale/de/LC_MESSAGES/django.po' % editor)
     compile_messages()
예제 #5
0
파일: setup.py 프로젝트: 3cky/marcus
 def run(self):
     import os
     import sys
     from django.core.management.commands.compilemessages import compile_messages
     curdir = os.getcwd()
     os.chdir(os.path.join(os.path.dirname(__file__), 'marcus'))
     compile_messages(stderr=sys.stderr)
     os.chdir(curdir)
예제 #6
0
 def test_percent_symbol_in_po_file(self):
     os.chdir(test_dir)
     # We don't use the django.core.management infrastructure (call_command()
     # et al) because CommandError's cause exit(1) there. We test the
     # underlying compile_messages function instead
     out = StringIO()
     compile_messages(out, locale=self.LOCALE)
     self.assertTrue(os.path.exists(self.MO_FILE))
예제 #7
0
 def test_percent_symbol_in_po_file(self):
     os.chdir(test_dir)
     # We don't use the django.core.management infrastructure (call_command()
     # et al) because CommandError's cause exit(1) there. We test the
     # underlying compile_messages function instead
     out = StringIO()
     compile_messages(out, locale=self.LOCALE)
     self.assertTrue(os.path.exists(self.MO_FILE))
예제 #8
0
파일: setup.py 프로젝트: 3cky/marcus
 def run(self):
     import os
     import sys
     from django.core.management.commands.compilemessages import compile_messages
     curdir = os.getcwd()
     os.chdir(os.path.join(os.path.dirname(__file__), 'marcus'))
     compile_messages(stderr=sys.stderr)
     os.chdir(curdir)
예제 #9
0
 def run(self):
     import os
     import sys
     from django.core.management.commands.compilemessages import \
         compile_messages
     curdir = os.getcwd()
     os.chdir(os.path.realpath('djangobb_forum'))
     compile_messages(stderr=sys.stderr)
     os.chdir(curdir)
예제 #10
0
 def run(self):
     import os
     import sys
     from django.core.management.commands.compilemessages import \
         compile_messages
     curdir = os.getcwd()
     os.chdir(os.path.realpath('djangobb_forum'))
     compile_messages(stderr=sys.stderr)
     os.chdir(curdir)
예제 #11
0
def compile_translations():
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'friends'))
    try:
        compile_messages(stderr=sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #12
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'invitation'))
    compile_messages()
    os.chdir(curdir)
예제 #13
0
파일: setup.py 프로젝트: ZaEzzz/IceBB
 def run(self):
     import os
     import sys
     from django.core.management.commands.compilemessages import \
         compile_messages
     curdir = os.getcwd()
     os.chdir(os.path.realpath('djangobb_forum'))
     if django.VERSION[:2] == (1, 6):
         compile_messages(stdout=sys.stdout)
     else:
         compile_messages(stderr=sys.stderr)
     os.chdir(curdir)
    def handle(self, locale=None, **kwargs):
        extensions=['*.py', '*.html']

        if not locale:
            print "Generating translation files for all available locales."
            makemessages.make_messages(all=True, verbosity=2, extensions=extensions)
            compilemessages.compile_messages()
        else:
            try:
                print "Generating translation files for %s" % locale
                makemessages.make_messages(locale=locale, all=False, verbosity=2, extensions=extensions)
                compilemessages.compile_messages(locale=locale)
            except Exception, e:
                print "There was an error generating translation files for %s" % locale
예제 #15
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'invitation'))
    try:
        compile_messages(stderr=sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #16
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'friends'))
    try:
        compile_messages(stderr=sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #17
0
    def run(self):
        import os
        import sys

        from django.core.management.commands.compilemessages import \
            compile_messages
        from djblets.util.filesystem import is_exe_in_path

        if not is_exe_in_path('msgfmt'):
            raise RuntimeError('Could not find the "msgfmt" binary.')

        cwd = os.getcwd()
        os.chdir(os.path.realpath('reviewboard'))
        compile_messages(stderr=sys.stderr)
        os.chdir(cwd)
예제 #18
0
    def run(self):
        import os
        import sys

        from django.core.management.commands.compilemessages import \
            compile_messages
        from djblets.util.filesystem import is_exe_in_path

        if not is_exe_in_path('msgfmt'):
            raise RuntimeError('Could not find the "msgfmt" binary.')

        cwd = os.getcwd()
        os.chdir(os.path.realpath('reviewboard'))
        compile_messages(stderr=sys.stderr)
        os.chdir(cwd)
예제 #19
0
    def test_percent_symbol_escaping(self):
        from django.template import Template, Context
        os.chdir(test_dir)
        # We don't use the django.core.management infrastructure (call_command()
        # et al) because CommandError's cause exit(1) there. We test the
        # underlying compile_messages function instead
        out = StringIO()
        compile_messages(out, locale=self.LOCALE)
        with translation.override(self.LOCALE):
            t = Template('{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}')
            rendered = t.render(Context({}))
            self.assertEqual(rendered, 'IT translation contains %% for the above string')

            t = Template('{% load i18n %}{% trans "Completed 50%% of all the tasks" %}')
            rendered = t.render(Context({}))
            self.assertEqual(rendered, 'IT translation of Completed 50%% of all the tasks')
예제 #20
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'invitation'))
    try:
        # Django >= 1.6 uses 'stdout' as method argument, Django <= 1.5 uses 'stderr'
        # support both by omitting the argument name:
        compile_messages(sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #21
0
파일: setup.py 프로젝트: adieu/authentic2
 def run(self):
     try:
         from django.core.management.commands.compilemessages import \
                 compile_messages
         for path, dirs, files in os.walk('authentic2'):
             if 'locale' not in dirs:
                 continue
             curdir = os.getcwd()
             os.chdir(os.path.realpath(path))
             compile_messages(stderr=sys.stderr)
             os.chdir(curdir)
     except ImportError:
         print
         sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
         print
         print
예제 #22
0
 def run(self):
     try:
         from django.core.management.commands.compilemessages import \
                 compile_messages
         for path in ['entrouvert/djommon/', 'entrouvert/djommon/humantime/']:
             if path.endswith('.py'):
                 continue
             curdir = os.getcwd()
             os.chdir(os.path.realpath(path))
             compile_messages(sys.stderr)
             os.chdir(curdir)
     except ImportError:
         print
         sys.stderr.write('!!! Please install Django >= 1.4 to build translations')
         print
         print
예제 #23
0
파일: po.py 프로젝트: 11craft/django-cms
 def test_po_sanity(self):
     with TemporaryDirectory() as tmpdir:
         shutil.copytree(SOURCE_DIR, os.path.join(tmpdir, 'locale'))
         olddir = os.getcwd()
         os.chdir(tmpdir)
         ok, stderr = compile_messages()
         os.chdir(olddir)
     self.assertTrue(ok, stderr)
예제 #24
0
 def test_po_sanity(self):
     with TemporaryDirectory() as tmpdir:
         shutil.copytree(SOURCE_DIR, os.path.join(tmpdir, 'locale'))
         olddir = os.getcwd()
         os.chdir(tmpdir)
         ok, stderr = compile_messages()
         os.chdir(olddir)
     self.assertTrue(ok, stderr)
예제 #25
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'invitation'))
    # compile_messages will try to import the settings module if its set,
    # but this is not called with manage.py, so we might not have a corerct
    # sys.path
    os.environ["DJANGO_SETTINGS_MODULE"] = ""
    try:
        compile_messages(stderr=sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #26
0
def compile_translations():
    try:
        from django.core.management.commands.compilemessages \
                                                       import compile_messages
    except ImportError:
        return None
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'invitation'))
    # compile_messages will try to import the settings module if its set,
    # but this is not called with manage.py, so we might not have a corerct
    # sys.path
    os.environ["DJANGO_SETTINGS_MODULE"] = ""
    try:
        compile_messages(stderr=sys.stderr)
    except TypeError:
        # compile_messages doesn't accept stderr parameter prior to 1.2.4
        compile_messages()
    os.chdir(curdir)
예제 #27
0
    def run(self):
        import os
        import sys
        import django
        from django.core.management.commands.compilemessages import \
            compile_messages
        from django.core.management.base import CommandError

        curdir = os.getcwd()
        os.chdir(os.path.realpath('djangobb_forum'))
        try:
            if django.VERSION[:2] == (1, 6):
                compile_messages(stdout=sys.stdout)
            else:
                compile_messages(stderr=sys.stderr)
        except CommandError:
            # raised if gettext pkg not installed
            pass
        os.chdir(curdir)
예제 #28
0
파일: setup.py 프로젝트: sundayliu/DjangoBB
    def run(self):
        import os
        import sys
        import django
        from django.core.management.commands.compilemessages import \
            compile_messages
        from django.core.management.base import CommandError

        curdir = os.getcwd()
        os.chdir(os.path.realpath('djangobb_forum'))
        try:
            if django.VERSION[:2] == (1, 6):
                compile_messages(stdout=sys.stdout)
            else:
                compile_messages(stderr=sys.stderr)
        except CommandError:
            # raised if gettext pkg not installed
            pass
        os.chdir(curdir)
    def handle(self, *args, **options):
        locale = options.get('locale')

        # The hacking part is here
        if not locale:
            if os.path.isdir(os.path.join('conf', 'locale')):
                localedir = os.path.abspath(os.path.join('conf', 'locale'))
            elif os.path.isdir('locale'):
                localedir = os.path.abspath('locale')
            else:
                raise CommandError("This script should be run from the Transifex project tree.")

            # Only for directories under the locale dir, compile_messages
            locale_dirs = filter(os.path.isdir, glob.glob('%s/*' % localedir))
            for locale_dir in locale_dirs:
                locale = os.path.basename(locale_dir)
                compile_messages(self.stderr, locale)
        else:
            compile_messages(self.stderr, locale)
예제 #30
0
def updatemessages():
    from django.conf import settings
    from django.core.management.commands.compilemessages import compile_messages
    if any([needs_update(path) for path in settings.LOCALE_PATHS]):
        compile_messages()
    LOCALE_PATHS = settings.LOCALE_PATHS
    settings.LOCALE_PATHS = ()
    cwd = os.getcwdu()
    for app in settings.INSTALLED_APPS:
        path = os.path.dirname(__import__(app, {}, {}, ['']).__file__)
        locale = os.path.join(path, 'locale')
        if os.path.isdir(locale):
            # Copy Python translations into JavaScript translations
            update_js_translations(locale)
            if needs_update(locale):
                os.chdir(path)
                compile_messages()
    settings.LOCALE_PATHS = LOCALE_PATHS
    os.chdir(cwd)
예제 #31
0
def updatemessages():
    from django.conf import settings
    if not settings.USE_I18N:
        return
    from django.core.management.commands.compilemessages import compile_messages
    if any([needs_update(path) for path in settings.LOCALE_PATHS]):
        compile_messages()
    LOCALE_PATHS = settings.LOCALE_PATHS
    settings.LOCALE_PATHS = ()
    cwd = os.getcwdu()
    for app in settings.INSTALLED_APPS:
        path = os.path.dirname(__import__(app, {}, {}, ['']).__file__)
        locale = os.path.join(path, 'locale')
        if os.path.isdir(locale):
            # Copy Python translations into JavaScript translations
            update_js_translations(locale)
            if needs_update(locale):
                os.chdir(path)
                compile_messages()
    settings.LOCALE_PATHS = LOCALE_PATHS
    os.chdir(cwd)
예제 #32
0
    def test_percent_symbol_escaping(self):
        from django.template import Template, Context
        os.chdir(test_dir)
        # We don't use the django.core.management infrastructure (call_command()
        # et al) because CommandError's cause exit(1) there. We test the
        # underlying compile_messages function instead
        out = StringIO()
        compile_messages(out, locale=self.LOCALE)
        with translation.override(self.LOCALE):
            t = Template(
                '{% load i18n %}{% trans "Looks like a str fmt spec %% o but shouldn\'t be interpreted as such" %}'
            )
            rendered = t.render(Context({}))
            self.assertEqual(
                rendered, 'IT translation contains %% for the above string')

            t = Template(
                '{% load i18n %}{% trans "Completed 50%% of all the tasks" %}')
            rendered = t.render(Context({}))
            self.assertEqual(
                rendered, 'IT translation of Completed 50%% of all the tasks')
예제 #33
0
#!/usr/bin/env python
from setuptools import setup, find_packages
from os.path import dirname, join
import sys, os

# When creating the sdist, make sure the django.mo file also exists:
if 'sdist' in sys.argv:
    try:
        os.chdir('fluent_contents')
        from django.core.management.commands.compilemessages import compile_messages
        compile_messages(sys.stderr)
    finally:
        os.chdir('..')


setup(
    name='django-fluent-contents',
    version='0.8.6',
    license='Apache License, Version 2.0',

    install_requires=[
        'django-polymorphic>=0.2',
        'django-tag-parser>=1.0.0',
        'django-template-analyzer>=1.1.0',
    ],
    requires=[
        'Django (>=1.3)',   # Using staticfiles
    ],
    extras_require = {
        'code': ['Pygments'],
        'disquscommentsarea': ['django-disqus'],
예제 #34
0
#!/usr/bin/env python

from __future__ import unicode_literals

import os
import sys

from django.core.management.commands.compilemessages import compile_messages
from djblets.util.filesystem import is_exe_in_path


if __name__ == '__main__':
    if not is_exe_in_path('msgfmt'):
        raise RuntimeError('Could not find the "msgfmt" binary.')

    cwd = os.getcwd()
    os.chdir(os.path.realpath('djblets'))
    compile_messages(stderr=sys.stderr)
    os.chdir(cwd)
예제 #35
0
#!/usr/bin/env python

from __future__ import unicode_literals

import os
import sys

from django.core.management.commands.compilemessages import compile_messages
from djblets.util.filesystem import is_exe_in_path

if __name__ == '__main__':
    if not is_exe_in_path('msgfmt'):
        raise RuntimeError('Could not find the "msgfmt" binary.')

    cwd = os.getcwd()
    os.chdir(os.path.realpath('reviewboard'))
    compile_messages(sys.stdout)
    os.chdir(cwd)
예제 #36
0
 def compilemessages(self):
     saved = os.getcwd()
     os.chdir(LocalePath.get_app_path(self.app))
     compile_messages(locale=cur_lang())
     os.chdir(saved)
예제 #37
0
from setuptools import setup, find_packages

# When creating the sdist, make sure the django.mo file also exists:
if 'sdist' in sys.argv or 'develop' in sys.argv:
    os.chdir('fluentcms_filer')

    for plugin in ['file', 'picture', 'teaser']:
        os.chdir(plugin)
        try:
            from django.core.management.commands.compilemessages import Command
            command = Command()
            command.execute(stdout=sys.stderr, exclude=[], verbosity=1)
        except ImportError:
            # < Django 1.7
            from django.core.management.commands.compilemessages import compile_messages
            compile_messages(sys.stderr, exclude=[])
        finally:
            os.chdir('..')

    os.chdir('..')


def read(*parts):
    file_path = os.path.join(os.path.dirname(__file__), *parts)
    return codecs.open(file_path, encoding='utf-8').read()


def find_version(*parts):
    version_file = read(*parts)
    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file, re.M)
    if version_match:
예제 #38
0
#!/usr/bin/env python

from __future__ import unicode_literals

import os
import sys

from django.core.management.commands.compilemessages import compile_messages
from djblets.util.filesystem import is_exe_in_path


if __name__ == '__main__':
    if not is_exe_in_path('msgfmt'):
        raise RuntimeError('Could not find the "msgfmt" binary.')

    cwd = os.getcwd()
    os.chdir(os.path.realpath('djblets'))
    compile_messages(sys.stdout)
    os.chdir(cwd)
예제 #39
0
def compile_translations():
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'friends'))
    compile_messages(stderr=sys.stderr)
    os.chdir(curdir)
예제 #40
0
    @copyright: 2011 by Jean-Philippe Braun <*****@*****.**>
    @license: GNU GPL, see COPYING for details.
"""

import os, sys
from setuptools import setup, find_packages
from django import VERSION
from django.core.management.commands.compilemessages import compile_messages

sys.path.insert(0, os.path.abspath('txsubmissions'))
os.environ['DJANGO_SETTINGS_MODULE'] = 'txsubmissions.settings'

# compile language files at installation
if VERSION[1] > 2:
    compile_messages(sys.stderr)
else:
    compile_messages()

setup(
    name='txsubmissions',
    version='0.1',
    description="Transifex submissions",
    author="Jean-Philippe Braun",
    author_email="*****@*****.**",
    maintainer="Jean-Philippe Braun",
    maintainer_email="*****@*****.**",
    url="http://www.mandriva.com",
    packages=find_packages(),
    include_package_data=True,
)
예제 #41
0
def compile_translations():
    curdir = os.getcwdu()
    os.chdir(os.path.join(os.path.dirname(__file__), 'friends'))
    compile_messages()
    os.chdir(curdir)
예제 #42
0
파일: views.py 프로젝트: HiPiH/life
 def compilemessages(self):
     saved = os.getcwd()
     os.chdir(LocalePath.get_app_path(self.app))
     compile_messages(locale = cur_lang())
     os.chdir(saved)
예제 #43
0
파일: L10n.py 프로젝트: xuanxu11/PyLucid
    def handle(self, *args, **options):
        self.verbosity = int(options.get('verbosity'))
        locale = options.get('locale')
        if locale is None:
            process_all = True
        else:
            process_all = False

        if len(args) == 0:
            raise CommandError("missing '%s' or '%s' argument!" % (MAKE_MESSAGES, COMPILE_MESSAGES))

        cmd_type = args[0]
        if cmd_type not in (MAKE_MESSAGES, COMPILE_MESSAGES):
            raise CommandError("First argument must be '%s' or '%s' !" % (MAKE_MESSAGES, COMPILE_MESSAGES))

        pylucid_app_names = self._pylucid_app_names()

        if len(args) > 1:
            only_apps = args[1:]
            sys.stdout.write("%s only the apps: %s" % (cmd_type, repr(only_apps)))

            app_names = []
            for app_name in only_apps:
                if app_name in pylucid_app_names:
                    app_names.append(app_name)
                else:
                    app_name = ".%s" % app_name
                    full_app_name = None
                    for app_name2 in pylucid_app_names:
                        if app_name2.endswith(app_name):
                            full_app_name = app_name2
                            break
                    if full_app_name is None:
                        sys.stderr.write("App with name %r is unknown or not a PyLucid app!" % app_name)
                    else:
                        app_names.append(full_app_name)
            if not app_names:
                raise CommandError("No valid PyLucid apps found!")
        else:
            app_names = pylucid_app_names

        for app_name in app_names:
            print "_"*79
            print "%s: %s" % (cmd_type, app_name)
            app_module = import_module(app_name)
            app_path = os.path.dirname(app_module.__file__)

            os.chdir(app_path)

            if cmd_type == COMPILE_MESSAGES:
                try:
                    compile_messages(self.stderr)
                except Exception:
                    print traceback.format_exc()
            elif cmd_type == MAKE_MESSAGES:
                try:
                    make_messages(
                        locale=locale,
                        domain="django",
                        verbosity=self.verbosity,
                        all=process_all,
                        extensions=[".html", ],
                        symlinks=True,
                        ignore_patterns=['CVS', '.*', '*~'],
                        no_wrap=False,
                        no_obsolete=True,
                    )
                except Exception:
                    print traceback.format_exc()
            else:
                raise
예제 #44
0
 def run(self):
     from django.core.management.commands.compilemessages \
         import compile_messages
     os.chdir('bingo_autotopic')
     compile_messages(sys.stderr)
     os.chdir("..")