A Wintersmith plugin to localize dates and times
npm install wintersmith-l10n> A Wintersmith plugin to localize dates and times
Install globally or locally using npm:
``bash`
npm install [-g] wintersmith-l10n
Add wintersmith-l10n to your config.json:
`json`
{
"plugins": [
"wintersmith-l10n"
]
}
Define the locale property:
`json`
{
"locale": "en"
}
Get the current locale:
`javascript`
env.helpers.l10n.get();
Set a new locale:
`javascript`
env.helpers.l10n.set('en-GB');
Localize a date:
`javascript`
env.helpers.l10n.localize(new Date(), 'LL');
Localize a time:
`javascript`
env.helpers.l10n.localize(new Date(), 'HH:mm');
Please note that wintersmith-l10n relies on moment to format dates and times. So, any format supported by moment is also supported by wintersmith-l10n.
wintersmith-l10n` is released under the MIT license.