Socket
Book a DemoInstallSign in
Socket

@freddieridell/glot

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@freddieridell/glot

a tiny, simple, powerful, expressive, i18n library

latest
Source
npmnpm
Version
0.0.8
Version published
Maintainers
1
Created
Source

Glot

min badge minzipped badge

A tiny, simple, powerful, expressive, i18n library

Usage

import createGlot from "@freddieridell/glot";
import { format as formatDate } from "date-fns/fp";

//initalise with dictionary
const glot = createGlot({
	en: {
		greetings: "'ello, govna'",
		date: "yyyy-MM-dd",
		thing_1: "number one",
		thing_2: "number two",
	},
	fra: {
		greetings: "'sup, Monsieur",
	},
})({ lang: "en" });

//basic usage
console.log(glot`greetings`);
console.log(glot`INVALID_KEY`);

//switch language
console.log(glot({ lang: "fra" })`greetings`);
const foreverFrench = glot({ lang: "fra" });
console.log(foreverFrench`greetings`);

//create parameterized functions
const localisedDteFormatter = glot({ mkFn: formatDate })`date`;
console.log(localisedDteFormatter(new Date()));

// interpolate values
new Array(2).fill(null).map((_, i) => console.log(glot`thing_${i + 1}`));

Todo

  • create companion react component
  • think about pluralisation
  • types
    • reasonml
    • flow
    • typescript
  • tune babel config to reduce bundle size
  • write tests, full coverage
  • write better readme
  • write better readme

Keywords

glot

FAQs

Package last updated on 22 Feb 2019

Did you know?

Socket

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