Ejemplo n.º 1
0
def initialize(projectdir, languagecode):
    """The first parameter is the path to the project directory, including
    locale.  It's up to this script to know any internal structure of the
    directory"""

    logger = logging.getLogger('scripts.amo')
    logger.info("Initializing language %s of project %s" %
                (languagecode, os.path.basename(projectdir)))

    # extract project root from projectdir
    projectroot = os.path.join(settings.PODIRECTORY,
                               os.path.split(projectdir)[0])

    # Find the files we're working with
    mainfile = os.path.join(projectroot, languagecode, 'LC_MESSAGES',
                            'messages.po')
    combinedfile = os.path.join(projectroot, languagecode, 'LC_MESSAGES',
                                'messages-combined.po')
    sourcefile = os.path.join(projectroot, 'en_US', 'LC_MESSAGES',
                              'messages.po')

    # Build our combined file
    monopo2po.convertpo(open(sourcefile, "r"), open(combinedfile, "w"),
                        open(mainfile, "r"))

    # build .po files from the .thtml files in /pages/
    _init_pages(projectroot, languagecode)
Ejemplo n.º 2
0
def initialize(projectdir, languagecode):
    """The first parameter is the path to the project directory, including
    locale.  It's up to this script to know any internal structure of the
    directory"""

    logger = logging.getLogger('scripts.amo')
    logger.info("Initializing language %s of project %s" %
                (languagecode, os.path.basename(projectdir)))

    # extract project root from projectdir
    projectroot = os.path.join(settings.PODIRECTORY,
                               os.path.split(projectdir)[0])

    # Find the files we're working with
    mainfile = os.path.join(projectroot, languagecode,
                            'LC_MESSAGES', 'messages.po')
    combinedfile = os.path.join(projectroot, languagecode,
                                'LC_MESSAGES', 'messages-combined.po')
    sourcefile = os.path.join(projectroot, 'en_US',
                              'LC_MESSAGES', 'messages.po')

    # Build our combined file
    monopo2po.convertpo(open(sourcefile, "r"),
                        open(combinedfile, "w"),
                        open(mainfile, "r"))

    # build .po files from the .thtml files in /pages/
    _init_pages(projectroot, languagecode)
Ejemplo n.º 3
0
def postupdate(updatedfile):
    logger = logging.getLogger('scripts.amo')

    # Get the files we'll be using
    (combinedfile, mainfile, sourcefile) = _getfiles(updatedfile)

    # Create the new messages-combined.po file
    logger.debug("Converting amo %s to %s with template %s" % (sourcefile, combinedfile, mainfile))
    monopo2po.convertpo(open(sourcefile, "r"), open(combinedfile, "w"), open(mainfile, "r"))
Ejemplo n.º 4
0
def postcommit(committedfile, success):
    if os.path.basename(committedfile) == "messages.po":
        logger = logging.getLogger('scripts.amo')

        # Get the files we'll be using
        (combinedfile, mainfile, sourcefile) = _getfiles(committedfile)

        # Recreate messages-combined.po
        logger.debug("Converting amo %s to %s with template %s" % (sourcefile, combinedfile, mainfile))
        monopo2po.convertpo(open(sourcefile, "r"), open(combinedfile, "w"), open(mainfile, "r"))
Ejemplo n.º 5
0
def postupdate(updatedfile):
    logger = logging.getLogger('scripts.amo')

    # Get the files we'll be using
    (combinedfile, mainfile, sourcefile) = _getfiles(updatedfile)

    # Create the new messages-combined.po file
    logger.debug("Converting amo %s to %s with template %s" %
                 (sourcefile, combinedfile, mainfile))
    monopo2po.convertpo(open(sourcefile, "r"), open(combinedfile, "w"),
                        open(mainfile, "r"))
Ejemplo n.º 6
0
def postcommit(committedfile, success):
    if os.path.basename(committedfile) == "messages.po":
        logger = logging.getLogger('scripts.amo')

        # Get the files we'll be using
        (combinedfile, mainfile, sourcefile) = _getfiles(committedfile)

        # Recreate messages-combined.po
        logger.debug("Converting amo %s to %s with template %s" %
                     (sourcefile, combinedfile, mainfile))
        monopo2po.convertpo(open(sourcefile, "r"), open(combinedfile, "w"),
                            open(mainfile, "r"))