@dipser/wmlang.js
v1.0.1
Published
Translate months and weekdays with Intl.
Downloads
7
Maintainers
Readme
wmlang.js
Demo
http://tools.bitfertig.de/wmlang.js/
Install
npm i @dipser/wmlang.js
Usage
<script type="module">
import { month, weekday } from '@dipser/wmlang.js';
console.log( weekday(1, 'de') ); // => Montag
console.log( month(1, 'de') ); // => Januar
</script>
How it works
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