po-writer

    0.0.3 • Public • Published

    po-writer

    A simple gettext Po file writer.

    Usage

    Create instance

    import Po from 'po-writer';
     
    let po = new Po();

    Add translations:

    po.add({
      id: 'hello world',
      str: '夜露死苦'
    })

    Create write stream and write to file:

    let stream = fs.createWriteStream(targetFilePath);
     
    po.writeToStream(stream);

    API

    constructor(headers)

    headers is an object contains file header. Current support header fields and default values:

    • Project-Id-Version: 'PACKAGE VERSION',
    • POT-Creation-Date: now,
    • PO-Revision-Date: now,
    • Last-Translator: '',
    • Language-Team: 'none',
    • MIME-Version: '1.0',
    • Content-Type: 'text/plain; charset=UTF-8',
    • Content-Transfer-Encoding: '8bit',
    • Plural-Forms: 'nplurals=INTEGER; plural=EXPRESSION;'

    add(msg)

    Add a tranlated message to Po. msg support attributes:

    • translatorComments
    • extractedComments
    • reference
    • flag
    • context
    • id
    • plural
    • str (string|string[])

    remove(id)

    Remove translation message from Po. id is a msg id or an array of msg ids.

    writeToStream(stream)

    Write the content of Po file to writable stream.

    Keywords

    Install

    npm i po-writer

    DownloadsWeekly Downloads

    2

    Version

    0.0.3

    License

    MIT

    Last publish

    Collaborators

    • othree