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.
- Host: GitHub
- URL: https://github.com/bitfertig/wmlang.js
- Owner: Bitfertig
- License: mit
- Created: 2020-09-22T23:01:32.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-11-18T15:42:28.000Z (over 5 years ago)
- Last Synced: 2024-04-20T13:35:34.465Z (about 2 years ago)
- Language: HTML
- Size: 8.79 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)