Socket
Socket
Sign inDemoInstall

whi18n

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    whi18n

## Install


Version published
Weekly downloads
1
decreased by-50%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

whi18n

Install

$ npm i whi18n

Usage

How to use

Initialize
  • Synchronized
import whi18n, { init } from 'whi18n';

const langData = {
	"en-US": {
		"version": 1,
		"texts": {
			"marco": "Polo",
			"foo": {
				"bar": "baz"
			}
		}
	},
	"ja-JP": {
		"version": 1,
		"texts": {
			"marco": "ポロ",
			"foo": {
				"bar": "バズ"
			}
		}
	}
};

init('ja-JP', langData);
  • Asynchronized
import whi18n, { init } from 'whi18n';

const getData = async lang => await axios.get(`/lang/${lang}.json`);
// If the data is a function that returns a promise, you need to await it
await init('ja-JP', getData);
Use in code
console.log(whi18n`marco`);		// ポロ
console.log(whi18n`foo.bar`);	// バズ
Use in HTML:
<!-- <span>ポロ</span>  -->
<span>@{marco}</span>	

<!-- <span title="バズ">Hello, world!</span>  -->
<span title="@{foo.bar}">Hello, world!</span>	

Keywords

FAQs

Last updated on 16 Oct 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