Socket
Socket
Sign inDemoInstall

@lifund/mulang

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lifund/mulang

render multiple client documents with different languages


Version published
Maintainers
1

Readme

Source

mulang

A simple, multi-language HTML renderer.

Description

When writing a text content of multiple HTML documents with different languages, editing element by element is a pain in the ass. Mulang helps you to render multiple HTML files simultaneously with a single JSON file.

Short Example.

Source HTML

<h1 class="m__landing_title"></h1>

Target JSON

{ "landing_title": "Hello World!" }

Result (String)

<h1 class="m__landing_title">Hello World!</h1>

why mulang?

  1. Cleaner structure for your multi-language projects.
  2. Easy to bind with popular frameworks.
  3. Easy to edit contents for non-coders.

- Coming Soon - Mulang Interactive | JSON editor for non-coder. GUI provided on a browser. HTML file is rendered interactively.


Documentation

Initiation

When initiating, you have to

let mulang = new Mulang({
    // You can pass HTML String and JSON Object directly.  
    sourceHtml='<!DOCTYPE html> ···',targetJson='{m__foo: "text content"}',
    // Or pass file path for HTML and JSON file.
    sourceHtmlPath='/path/to/file',targetJsonPath='/path/to/file',
    
    // One of path/file must be provided. 
    // If both provided, HTML String and JSON Object will be used.

    // ( under update below, not effective yet. Do not edit. )
    documentMode="html",parseMode="class",insertMode="prepend"
});

Render HTML file

Simple! Execute render function, get a result with JSON!

const result = mulang.render();

// { "eng":"<!DOCTYPE html> ···", "kor":"<!DOCTYPE html> ···" }

if(req.body.lang == 'eng') res.send(result.eng);
if(req.body.lang == 'kor') res.send(result.kor);

How to write a target JSON files

"meta" includes

  1. "languages" - An array of language names (ordered).
  2. "linebreak" - A linebreak tag inside an HTML 3. String. (dafalut = ).
  3. "updateHistory" - (only for mulang interactive)

"contents" includes

  1. "mulang tag" - A tag name without m__ prefix.
{
    "meta":
    {
        "languages": ["eng","kor"],
        "linebreak": "<br>",
    },
    "contents":
    {
        "section_1_title": ["title","제목"],
        "section_1_description_1": ["single line","한 줄"],
        "section_1_description_2": ["line1<br>line2","줄1<br>줄2"]
    },
    // added automatically by mulang interactive
    "updateHistory": 
    //[
    //    {"user": "admin", "time": "2020-09-26 01:04:00", "comment":"first commit", "contents": ""}
    //]
}

Keywords

FAQs

Last updated on 18 Nov 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc