Code Monkey home page Code Monkey logo

gettext-handlebars's Introduction

gettext-handlebars build status

Extract translatable strings from Handlebars template strings.

It can be used stand-alone or through gmarty/gettext.

API

new Parser(keywordspec)

Creates a new parser. The keywordspec parameter is optional, with the default being:

{
  gettext: ['msgid'],
  _: ['msgid'],

  ngettext: ['msgid', 'msgid_plural'],
  n_: ['msgid', 'msgid_plural'],

  pgettext: ['msgctxt', 'msgid'],
  p_: ['msgctxt', 'msgid'],

  npgettext: ['msgctxt', 'msgid', 'msgid_plural'],
  np_: ['msgctxt', 'msgid', 'msgid_plural']
}

Each keyword (key) requires array of strings indicating the order of expected PO fields. For example npgettext: ['msgctxt', 'msgid', 'msgid_plural'] indicates that the npgettext handlebars helper takes arguments of form {{npgettext "context" "string" "plural" ...}}

.parse(template)

Parses the template string for Handlebars expressions using the keywordspec. It returns an object with this structure:

{
  msgid1: {
    line: [1, 3]
  },
  msgid2: {
    line: [2],
    plural: 'msgid_plural'
  },
  context\u0004msgid2: {
    line: [4]
  }
}

Development

Install

git clone [email protected]:smhg/gettext-handlebars.git
npm i

Test

npm run lint
npm test

gettext-handlebars's People

Contributors

gabegorelick avatar patrickfournier avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.