Code Monkey home page Code Monkey logo

etk's Introduction

etk

Extract translation keys from handlebars, javascript or typescript into key:value pairs, po, or py gettext. Can extract from: .js .jsx .ts. .tsx .handlebars .hbs, .njk, .nunjukcs

output types can be: .json .py .po

output type is determined by the extension of the output file, if i have no parser for the extension, it will be json.

can output multiple files, pass multiple -o arguments. -o output-file.json -o output-file.po

Installation

add this repo to package.json

{
    "devDependencies": {
        "etk": "github:Tnifey/etk#main",  // latest (not stable)
        "etk": "github:Tnifey/etk#v0.1.4" // tag version (production ready)
    }
}

and run yarn to install this dependency

checkout tags for versions

Usage

run as command:

npx etk -o output.json "path-as-glob/**/*.(handlebars|hbs|js|ts|nunjucks|njk)"

# multiple outputs
npx etk -o output.py -o output.po "path-as-glob/**/*.(handlebars|js|ts)"

# with config file (see example.etkrc file)
npx etk -c example.etkrc

in package.json as script:

{
    "scripts": {
        "trans": "npx etk -o .translations.json \"src/**/*.(handlebars|hbs|js|ts|nunjucks|njk)\"",
        "trans:py": "npx etk -o .translations.py \"src/**/*.(js|ts|handlebars)\"",
        "trans:po": "npx etk -o .translations.po \"src/**/*.(js|ts|handlebars)\"",
        "trans:ext": "npx etk -o .translations.po -o .translations.json \"src/**/*.(js|ts|handlebars)\"",
    }
}

Defaults

It search for this:

gettext("translation key") // <- gettext function with string parameter
{{_ "translation key" }}  <!-- _ helper with string parameter >
{{ _("translation key") }} {# <- function with string parameter  #}

Internally using:

License

MIT

etk's People

Contributors

tnifey avatar

Watchers

 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.