Git Product home page Git Product logo

multilang's Introduction

language: English also available in: Spanish - German

multilang

Tools for multilanguage & Markdown multilang

npm-version downloads build coverage climate dependencies qa-control

In a Markdown or HTML-like file is written the documentation in multiple languages.

One of these languages ​​is the main, the others are commented with <!-- and -->

Then with multilang the other languages ​​are extracted to generate one file for each of the other languages ​​defined

Install

$ npm install multilang -g

How to use

$ multilang doc-en.md

A .md file is generated for the other languages written in doc-en.md file

Multilanguage document format

Any HTML or Markdown document is a multilenguage document if it has a main multilanguage directive.

Example

<!--multilang v0 en:README.md es:LEEME.md fr:LISEZMOI.md de:LIESMICH.md -->
<!--multilang buttons-->

language: ![English](https://raw.githubusercontent.com/codenautas/multilang/master/img/lang-en.png)
also available in:
[Spanish](LEEME.md)  [French](LISEZMOI.md)  [German](LIESMICH.md)

<!--lang:en-->
This is a little example
<!--lang:es--]
Este es un pequeño ejemplo
[!--lang:fr--]
Ce est un petit exemple
[!--lang:de--]
Das ist ein Beispiel
[!--lang:*-->

<!--lang:en-->
"*" means all languages
<!--lang:es--]
"*" es para indicar todos los idiomas
[!--lang:fr--]
"*" est d'indiquer toutes les langues
[!--lang:de--]
"*" steht für alle Sprachen
[!--lang:*-->
All you need is multilang!

In this example:

<!--multilanguage v0 en:README.md es:LEEME.md fr:LISEZMOI.md-->

is the directive for declare the languages

<!--multilanguage buttons-->

is the directive for declaring the place for the button section

[!--lang:fr--]

is the directive for declaring the language of the next section (use * for all languages)

API

var fs = require('fs');
var multilang = require('multilang');

var englishText = fs.readFileSync('README.md', {encoding:'utf8'});

var warnings = multilang.getWarnings(englishText);
if(warnings.lengt){
    console.log('WARN', warnings);
}

var spanishText = multilang.changeDoc(englishText,'es');

console.log('spanish.md',spanishText);

(note about the example: do not use Sync functions in production, use async or promise version as you can see in codenautas

function use
changeDoc(text,lang) receives a multilang text and a language code and returns de text of specified lang
warnings(text) receives a list of warnings and returns a multilang text

License

MIT

...................................

multilang's People

Contributors

diegoefe avatar emilioplatzer avatar biancode avatar estefi-capece avatar

Watchers

James Cloos 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.