An open API service indexing awesome lists of open source software.

https://github.com/bitfertig/wmlang.js

Translate months and weekdays.
https://github.com/bitfertig/wmlang.js

Last synced: 4 months ago
JSON representation

Translate months and weekdays.

Awesome Lists containing this project

README

          

# wmlang.js

Translate weekdays and months with "Intl", which is included by your browser.

## Demo

http://tools.bitfertig.de/wmlang.js/

## Install

```bash
npm i @dipser/wmlang.js
```

## Usage

```html

import { month, weekday } from '@dipser/wmlang.js';
console.log( weekday(1, 'de') ); // => Montag
console.log( month(1, 'de') ); // => Januar

```

## How it works

```javascript
function month(month, locale = 'en') {
let intl = new Intl.DateTimeFormat(locale, { month: 'long' });
return intl.format( new Date(1970, Number(month) - 1, 1) );
}
month(2, 'de'); // => Februar
```

## More
* [npm package](https://www.npmjs.com/package/@dipser/wmlang.js)
* [twitter](https://twitter.com/dipser)