Giter Club home page Giter Club logo

django-js-translator's Introduction

Django JS Translator

CircleCI

Easily translate your front-end code in your Django project !

This tool outputs an HTML file, using the output body you need, so you can pipe the translation result into a translation helper.

Command-line

usage: django-js-translator [-h] [--dry-run] config_path

Prepare translation files for JS

positional arguments:
  config_path  configuration file path

optional arguments:
  -h, --help   show this help message and exit
  --dry-run    only print output

Configuration

You can configure the translator for your project using a YAML configuration file.
A sample file is included in the project.

This sample configuration will:

  • detect .js and .jsx files,
  • in the ./sample_files folder,
  • show the position and origin of each translation because the debug mode is set,
  • search for the translation directive tr (for example tr('Hello')),
  • and output a test.html file,
  • wrapping the translation in a django.translate.defineTranslations function call.
##########################################
# Django JS Translator configuration file

configuration:

  # Paths to watch
  paths:
    - ./sample_files

  # Activate debug mode: show the origin and position of the text to translate
  debug: True

  # Extensions to watch
  extensions:
    - .jsx
    - .js

  # Translation directive to search
  directive: tr

  # Output configuration
  output:

    # Output path
    path: test.html

    # Output body
    body: |
      {{% load i18n %}}

      <script type="text/javascript">
      django.translate.defineTranslations({{
      {0}
      }});
      </script>

django-js-translator's People

Contributors

srynetix 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.