1.2.0 • Published 2 years ago

multilang v1.2.0

Weekly downloads
7
License
MIT
Repository
github
Last release
2 years ago

multilang

Tools for multilanguage & Markdown multilang

npm-version downloads build coverage

language: English also available in: Spanish - German

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 open and close

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

functionuse
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

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

1.2.0

2 years ago

1.1.0

3 years ago

1.0.23

5 years ago

1.0.21

6 years ago

1.0.20

7 years ago

1.0.19

7 years ago

1.0.18

7 years ago

1.0.17

7 years ago

1.0.16

7 years ago

1.0.15

7 years ago

1.0.14

8 years ago

1.0.13

8 years ago

1.0.12

8 years ago

1.0.11

9 years ago

1.0.10

9 years ago

1.0.9

9 years ago

1.0.8

9 years ago

1.0.7

9 years ago

1.0.6

9 years ago

1.0.5

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.1.0

9 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago