Example #1
0
def update_templates():
    """Update template po files"""
    logging.info("Copying english po files to %s" % POT_PATH)

    #  post them to exposed URL
    ensure_dir(POT_PATH)
    shutil.copy(get_po_filepath(lang_code="en", filename="django.po"), os.path.join(POT_PATH, "kalite.pot"))
    shutil.copy(get_po_filepath(lang_code="en", filename="djangojs.po"), os.path.join(POT_PATH, "kalitejs.pot"))
def update_templates():
    """Update template po files"""
    logging.info("Copying english po files to %s" % POT_PATH)

    #  post them to exposed URL
    ensure_dir(POT_PATH)
    shutil.copy(get_po_filepath(lang_code="en", filename="django.po"), os.path.join(POT_PATH, "kalite.pot"))
    shutil.copy(get_po_filepath(lang_code="en", filename="djangojs.po"), os.path.join(POT_PATH, "kalitejs.pot"))
def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None):
    """Unpack zipped language pack into locale directory"""
    lang_code = lcode_to_django_dir(lang_code)

    logging.info("Unpacking new translations")
    ensure_dir(get_po_filepath(lang_code=lang_code))

    ## Unpack into temp dir
    z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data)) or open(zip_filepath, "rb"))
    z.extractall(os.path.join(LOCALE_ROOT, lang_code))
Example #4
0
def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None):
    """Unpack zipped language pack into locale directory"""
    lang_code = lcode_to_django_dir(lang_code)

    logging.info("Unpacking new translations")
    ensure_dir(get_po_filepath(lang_code=lang_code))

    ## Unpack into temp dir
    z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data)) or open(zip_filepath, "rb"))
    z.extractall(os.path.join(LOCALE_ROOT, lang_code))
def run_makemessages(verbosity=0):

    python_package_dirs = glob.glob(os.path.join(test_wrappings.PROJECT_ROOT, 'ka-lite', 'python-packages', '*'))
    ignored_packages = [os.path.join('*/python-packages/', os.path.basename(pp)) for pp in python_package_dirs if os.path.basename(pp) not in ['securesync', 'fle_utils']]

    # Central-specific patterns, added on the distributed versions
    ignore_patterns_py = ignore_patterns_js = ignored_packages + ['*/centralserver/*']

    test_wrappings.run_makemessages(ignore_patterns_py=ignore_patterns_py, ignore_patterns_js=ignore_patterns_js, verbosity=verbosity)

    # Return the list of files created.
    return glob.glob(os.path.join(get_po_filepath(lang_code="en"), "*.po"))
def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None):
    """Unpack zipped language pack into locale directory"""
    lang_code = lcode_to_django_dir(lang_code)

    logging.info("Unpacking new translations")
    ensure_dir(get_po_filepath(lang_code=lang_code))

    # # Unpack into temp dir
    try:
        z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data)) or open(zip_filepath, "rb"))
    except zipfile.BadZipfile as e:
        # Need to add more information on the errror message.
        # See http://stackoverflow.com/questions/6062576/adding-information-to-a-python-exception
        raise type(e), type(e)(e.message + _("Language pack corrupted. Please try downloading the language pack again in a few minutes."))
    z.extractall(os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code))
def unpack_language(lang_code, zip_filepath=None, zip_fp=None, zip_data=None):
    """Unpack zipped language pack into locale directory"""
    lang_code = lcode_to_django_dir(lang_code)

    logging.info("Unpacking new translations")
    ensure_dir(get_po_filepath(lang_code=lang_code))

    # # Unpack into temp dir
    try:
        z = zipfile.ZipFile(zip_fp or (zip_data and StringIO(zip_data))
                            or open(zip_filepath, "rb"))
    except zipfile.BadZipfile as e:
        # Need to add more information on the errror message.
        # See http://stackoverflow.com/questions/6062576/adding-information-to-a-python-exception
        raise type(e), type(e)(e.message + _(
            "Language pack corrupted. Please try downloading the language pack again in a few minutes."
        ))
    z.extractall(os.path.join(settings.USER_WRITABLE_LOCALE_DIR, lang_code))
Example #8
0
def run_makemessages(verbosity=0):

    python_package_dirs = glob.glob(
        os.path.join(test_wrappings.PROJECT_ROOT, 'ka-lite', 'python-packages',
                     '*'))
    ignored_packages = [
        os.path.join('*/python-packages/', os.path.basename(pp))
        for pp in python_package_dirs
        if os.path.basename(pp) not in ['securesync', 'fle_utils']
    ]

    # Central-specific patterns, added on the distributed versions
    ignore_patterns_py = ignore_patterns_js = ignored_packages + [
        '*/centralserver/*'
    ]

    test_wrappings.run_makemessages(ignore_patterns_py=ignore_patterns_py,
                                    ignore_patterns_js=ignore_patterns_js,
                                    verbosity=verbosity)

    # Return the list of files created.
    return glob.glob(os.path.join(get_po_filepath(lang_code="en"), "*.po"))