1.0.2 • Published 2 years ago
@dulysse1/better-intl v1.0.2
Better Intl
Make ECMAScript Internationalization API look like moment
Architecture 🏗
/better-intl
--/@types
--/index.d.ts: typing file
--/dist: Build directory
--/lib
--/decorators.ts : Decorators
--/index.ts: Main file
--/utils.ts: Utils for main
--/tests
--/index.test.js: Testing lib
--/utils
--/check.ts: Check dist directory
--/uglify.ts: Uglify build directory
How to use ? 🤔
With commonJS
const { IntlX } = require("@dulysse1/better-intl");
With ES6 and more
import { IntlX } from "@dulysse1/better-intl";
Documentation 🧗
Get instance current lang
import { IntlX } from "@dulysse1/better-intl";
console.log(IntlX.getLang());
> "en"
Set instance lang
import { IntlX } from "@dulysse1/better-intl";
IntlX.setLang("fr");
console.log(IntlX.getLang());
> "fr"
Get date style
import { IntlX } from "@dulysse1/better-intl";
console.log(IntlX.getStyle());
> "long"
set date style
import { IntlX } from "@dulysse1/better-intl";
IntlX.setStyle("short");
console.log(IntlX.getStyle());
> "short"
Format a date
// Current time: 2023-01-24T09:05:57.767Z
import { IntlX } from "@dulysse1/better-intl";
console.log(IntlX.format(new Date()));
console.log(IntlX.setStyle("short").format(new Date("2020")));
> "January 24, 2023"
> "1/1/20"
Get date from now
// Current time: 2023-01-24T09:05:57.767Z
import { IntlX } from "@dulysse1/better-intl";
console.log(IntlX.setLang("fr").from(new Date("2022-10-12")));
console.log(IntlX.setLang("fr").from(new Date("2023-08-24")));
> "il y a 3 mois"
> "dans 7 mois"
...and more ! ✌️
Information
Author: Ulysse Dupont @Ulysse
Contact: ulysse@euranov.com